Refactor modal reopening logic to streamline URL parameter handling and improve code clarity

This commit is contained in:
Ross
2026-03-23 10:35:07 +00:00
parent 077bd3ed87
commit b17774aa7c
+11 -19
View File
@@ -1333,34 +1333,26 @@
window.history.replaceState({}, '', url.toString());
}
// On load: reopen modals if URL params present
// On load: reopen modals if URL params present — call loader functions directly
(function reopenModalsFromUrl() {
const params = new URL(window.location.href).searchParams;
const dsId = params.get('displayset');
const dsFull = params.get('displayset_full');
const findingId = params.get('finding');
if (dsId) {
// try to find a button for this displayset and click it
// prefer to use existing button url if present, otherwise construct endpoint
const btn = document.querySelector(`.view-displayset-modal[data-ds-id="${dsId}"]`);
if (btn) {
// open fullscreen if requested
if (dsFull) {
// ensure the modal content is loaded then trigger fullscreen
btn.click();
// wait for content then trigger fullscreen button
setTimeout(function () {
const fs = document.querySelector('.displayset-fullscreen-btn');
if (fs) fs.click();
}, 800);
} else {
btn.click();
}
return;
const url = btn ? btn.dataset.url : null;
if (dsFull) {
loadDisplaysetFullscreen(url, dsId);
} else {
loadDisplaysetModal(url, dsId);
}
}
if (findingId) {
} else if (findingId) {
// open finding modal
const fbtn = document.querySelector(`.view-finding-modal[data-finding-id="${findingId}"]`);
if (fbtn) fbtn.click();
const url = fbtn ? fbtn.getAttribute('data-url') : null;
loadFindingModal(findingId, url);
}
})();