From d13d4860f3d5b51d659379aa8a38742bfe49bf37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tuomas=20Klav=C3=A9r?= Date: Mon, 20 Nov 2023 02:04:12 +0200 Subject: Questions now shows up. DB -> JSON -> JS -> DOM --- static/menu.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'static/menu.js') diff --git a/static/menu.js b/static/menu.js index ee8f977..5256ef2 100644 --- a/static/menu.js +++ b/static/menu.js @@ -145,6 +145,16 @@ hashToPage = async () => { pageElement.loaded = false; window.location.assign( pageElement.innerHTML.slice( 11 ) ); } + + // https://plnkr.co/edit/MMegiu by Allen Kim + Array.from(pageElement.querySelectorAll("script")).forEach(oldScript => { + const newScript = document.createElement("script"); + Array.from(oldScript.attributes).forEach(attr => + newScript.setAttribute(attr.name, attr.value)); + newScript.appendChild(document.createTextNode(oldScript.innerHTML)); + oldScript.parentNode.replaceChild(newScript, oldScript); + }); + document.getElementById(`${currentPage}_menuEntry`) .className = 'menuItem' document.getElementById(`${p}_menuEntry`) -- cgit v1.2.3