Reintroduce site link transformer for Beamline elements

This commit is contained in:
mathis_s committed 2026-09-10 10:53:58 +02:00
1 parent 8036061357
commit de8f9ea63b
2 files changed
+27 -23

No files matched your search

@@ -1,3 +1,25 @@
/**
* Monitor the MIDAS side navigation for changes and reapply the URL fix.
*
* mhttpd may rebuild the side navigation after initial page loading.
* A MutationObserver ensures that newly created menu links are corrected
* automatically without modifying the standard mhttpd.js library using
* fixMenuLinks()
*/
export function watchMenuLinks() {
const menu = document.getElementById("msidenav");
const observer = new MutationObserver(() => {
fixMenuLinks();
});
observer.observe(menu, {
childList: true,
subtree: true
});
fixMenuLinks();
}
/**
* Fix MIDAS side navigation links for standalone custom pages.
@@ -22,27 +44,4 @@ function fixMenuLinks() {
document.querySelectorAll("#msidenav a[href^='?cmd=']").forEach(link => {
link.href = "/" + link.getAttribute("href");
});
}
/**
* Monitor the MIDAS side navigation for changes and reapply the URL fix.
*
* mhttpd may rebuild the side navigation after initial page loading.
* A MutationObserver ensures that newly created menu links are corrected
* automatically without modifying the standard mhttpd.js library using
* fixMenuLinks()
*/
function watchMenuLinks() {
const menu = document.getElementById("msidenav");
const observer = new MutationObserver(() => {
fixMenuLinks();
});
observer.observe(menu, {
childList: true,
subtree: true
});
fixMenuLinks();
}
+5
View File
@@ -15,6 +15,8 @@
// stefan.mathis@psi.ch
//**************************************************************************//
import watchMenuLinks from "./Beamline_elements/Beamline_overview_images.js";
/**
* Stop the current run, after user confirmation.
*
@@ -153,6 +155,9 @@ export async function init(instrTabs, instrODB, instrName, instrColor, elogLink)
used by experts only.\nBy continuing, you agree to take
responsibility for any damage to the experiment or loss of beam time.`);
};
// Initialize site link transformer for Beamline_elements
watchMenuLinks();
}
// Global variables