From 6b856513c13bbdf86191190923fb64438219ea68 Mon Sep 17 00:00:00 2001 From: Taras Madan Date: Fri, 8 Nov 2024 11:49:29 +0100 Subject: [PATCH] dashboard/app: move coverage page js code to static file Chrome devtools allow to edit js code directly in browser. This change will speed up further development. --- dashboard/app/static/coverage.js | 28 ++++++++++++++++++++++++++++ pkg/cover/templates/heatmap.html | 22 +++++----------------- 2 files changed, 33 insertions(+), 17 deletions(-) create mode 100644 dashboard/app/static/coverage.js diff --git a/dashboard/app/static/coverage.js b/dashboard/app/static/coverage.js new file mode 100644 index 000000000000..16eb4fcd7e1f --- /dev/null +++ b/dashboard/app/static/coverage.js @@ -0,0 +1,28 @@ +// Copyright 2024 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +initTogglers(); + +// Initializes the file tree onClick collapse logic. +function initTogglers(){ + $(".caret").on("click", function() { + $(this).toggleClass("caret-down"); + $(this).closest("li").find(".nested").first().toggleClass("active"); + }); +} + +// This handler is called when user clicks on the coverage percentage. +// It downloads the kernel file coverage html block and adjust page to show it. +// "#file-content-prev" and "#file-content-curr" are the file content
s. +// "#file-details-prev" and "#file-details-curr" are the corresponding
s used to show per-file details. +function onShowFileContent(url) { + $.get(url, function(response) { + $("#file-content-prev").html($("#file-content-curr").html()); + $("#file-content-curr").html(response); + + $("#file-details-prev").html($("#file-details-curr").html()); + // It looks hacky but costs nothing. Let's show all the url parameters as a source description. + details = url.split("?")[1].split("&"); + $("#file-details-curr").html("Source information:\n" + details.join("\n")); + }); +} diff --git a/pkg/cover/templates/heatmap.html b/pkg/cover/templates/heatmap.html index 72d38058a63c..fc1b457c9998 100644 --- a/pkg/cover/templates/heatmap.html +++ b/pkg/cover/templates/heatmap.html @@ -1,24 +1,12 @@ {{ define "js" }} {{ end }}