diff options
| author | Taras Madan <tarasmadan@google.com> | 2024-11-07 15:26:18 +0100 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2024-11-08 08:01:17 +0000 |
| commit | d40c056e1b030bd4e89a1a467118b6a821aba3bb (patch) | |
| tree | c3e4c6584ea4ff91bf884934fed28eaea21165ac /pkg | |
| parent | 179b040e9d2068ccf2d0e0d3b084dd2293d85e04 (diff) | |
pkg/cover: heatmap starts to use jquery
Bonus - remove html template we don't need anymore.
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/cover/templates/heatmap.html | 47 |
1 files changed, 13 insertions, 34 deletions
diff --git a/pkg/cover/templates/heatmap.html b/pkg/cover/templates/heatmap.html index 14c2aad2f..72d38058a 100644 --- a/pkg/cover/templates/heatmap.html +++ b/pkg/cover/templates/heatmap.html @@ -1,44 +1,23 @@ -<!DOCTYPE html> -<html> -<head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> - <style> - {{ .Style }} - </style> -</head> -<body> - {{ .Body }} -</body> -{{ .JS }} -</html> - {{ define "js" }} <script> - var togglers = document.getElementsByClassName("caret"); - for (var i = 0; i < togglers.length; i++) { - togglers[i].addEventListener("click", function() { - this.classList.toggle("caret-down"); - this.parentElement.parentElement.parentElement.querySelector(".nested").classList.toggle("active"); - }); - } + $(".caret").on("click", function() { + $(this).toggleClass("caret-down"); + $(this).closest("li").find(".nested").first().toggleClass("active"); + }); function setContent(url, htmlContent) { - document.getElementById("file-content-prev").innerHTML = document.getElementById("file-content-curr").innerHTML; - document.getElementById("file-details-prev").innerHTML = document.getElementById("file-details-curr").innerHTML; + $("#file-content-prev").html($("#file-content-curr").html()); + $("#file-details-prev").html($("#file-details-curr").html()); - document.getElementById("file-content-curr").innerHTML = htmlContent; - details = url.split("?")[1].split("&") - document.getElementById("file-details-curr").innerHTML = "Source information:\n" + details.join("\n"); + $("#file-content-curr").html(htmlContent); + details = url.split("?")[1].split("&"); + $("#file-details-curr").html("Source information:\n" + details.join("\n")); } - function onShowFileContent(url){ - var reqListener = function() { - setContent(url, this.responseText) - } - const req = new XMLHttpRequest(); - req.addEventListener("load", reqListener); - req.open("GET", url); - req.send(); + function onShowFileContent(url) { + $.get(url, function(response) { + setContent(url, response); + }); } </script> {{ end }} |
