Skip to content

Commit

Permalink
pkg/cover: heatmap starts to use jquery
Browse files Browse the repository at this point in the history
  • Loading branch information
tarasmadan committed Nov 7, 2024
1 parent 2dd6d2b commit 1623449
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
1 change: 1 addition & 0 deletions dashboard/app/templates/custom_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<!doctype html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
{{template "head" .Header}}
<style>
Expand Down
34 changes: 14 additions & 20 deletions pkg/cover/templates/heatmap.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
{{ .Style }}
Expand All @@ -14,31 +15,24 @@

{{ 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").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 }}
Expand Down

0 comments on commit 1623449

Please sign in to comment.