mirror of
https://github.com/healthchecks/healthchecks.git
synced 2025-04-08 14:40:05 +00:00
Simplify JS that sets the favicon
* look up the favicon DOM element only once * update the favicon only if title changes, not on every refresh * details.js: use the base URL when constructing favicon URL
This commit is contained in:
parent
ab639e6cfd
commit
9f5cec1c7a
2 changed files with 8 additions and 22 deletions
static/js
|
@ -1,5 +1,6 @@
|
|||
$(function () {
|
||||
var base = document.getElementById("base-url").getAttribute("href").slice(0, -1);
|
||||
var favicon = document.querySelector('link[rel="icon"]');
|
||||
|
||||
$(".rw .my-checks-name").click(function() {
|
||||
var code = $(this).closest("tr.checks-row").attr("id");
|
||||
|
@ -240,19 +241,10 @@ $(function () {
|
|||
}
|
||||
});
|
||||
|
||||
if(data.title.includes('down')){
|
||||
// Get the favicon element
|
||||
var favicon = document.querySelector('link[rel="icon"]');
|
||||
//replace the favicon with the down favicon
|
||||
favicon.href = base + "/static/img/favicon_down.svg";
|
||||
}
|
||||
else{
|
||||
var favicon = document.querySelector('link[rel="icon"]');
|
||||
favicon.href = base + "/static/img/favicon.svg";
|
||||
}
|
||||
|
||||
if (document.title != data.title) {
|
||||
document.title = data.title;
|
||||
var downPostfix = data.title.includes("down") ? "_down" : "";
|
||||
favicon.href = `${base}/static/img/favicon${downPostfix}.svg`;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
$(function () {
|
||||
var base = document.getElementById("base-url").getAttribute("href").slice(0, -1);
|
||||
var favicon = document.querySelector('link[rel="icon"]');
|
||||
|
||||
$("#edit-name").click(function() {
|
||||
$('#update-name-modal').modal("show");
|
||||
$("#update-name-input").focus();
|
||||
|
@ -110,19 +113,10 @@ $(function () {
|
|||
$("#downtimes").html(data.downtimes);
|
||||
}
|
||||
|
||||
if(data.status == "down"){
|
||||
// Get the favicon element
|
||||
var favicon = document.querySelector('link[rel="icon"]');
|
||||
//replace the favicon with the down favicon
|
||||
favicon.href = "/static/img/favicon_down.svg";
|
||||
}
|
||||
else{
|
||||
var favicon = document.querySelector('link[rel="icon"]');
|
||||
favicon.href = "/static/img/favicon.svg";
|
||||
}
|
||||
|
||||
if (document.title != data.title) {
|
||||
document.title = data.title;
|
||||
var downPostfix = data.status == "down" ? "_down" : "";
|
||||
favicon.href = `${base}/static/img/favicon${downPostfix}.svg`;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue