1 Commits

View File

@@ -33,11 +33,12 @@
}); });
}; };
// load client_details for the client specified in the URL hash // load client_details for the client specified in the URL
const hash = window.location.hash; const urlParams = new URLSearchParams(window.location.search);
if (hash) { const clientId = urlParams.get("client");
const clientId = hash.substring(1); if (clientId) {
loadClientDetails(clientId); loadClientDetails(clientId);
$(`#client-list a[href="?client=${clientId}"]`).addClass("active");
} }
$("#notify").hide(); $("#notify").hide();
@@ -141,7 +142,7 @@
li.append(iconElement); li.append(iconElement);
const a = $("<a></a>") const a = $("<a></a>")
.text(statusText) .text(statusText)
.attr("href", `#${clientId}`); .attr("href", `?client=${clientId}`);
li.attr( li.attr(
"title", "title",
@@ -164,19 +165,19 @@
$("#client-list li > a") $("#client-list li > a")
.off("click") .off("click")
.on("click", function (e) { .on("click", function (e) {
const href = $(this).attr("href"); let clientId = $(this).attr("href").substring(1);
if (href.startsWith("#")) { // this is client=clientId
const clientId = href.substring(1);
loadClientDetails(clientId);
$("#client-list li > a").removeClass("active");
$(this).addClass("active");
}
});
if (window.location.hash) { clientId = clientId.replace("client=", "");
const clientId = window.location.hash.substring(1);
loadClientDetails(clientId); loadClientDetails(clientId);
} $("#client-list a").removeClass("active");
$(this).addClass("active");
e.preventDefault();
let newUrl = `${window.location.pathname}?client=${clientId}`;
window.history.pushState({ path: newUrl }, "", newUrl);
});
}); });
}); });
</script> </script>