major bug fix
Marco Andronaco andronacomarco@gmail.com
Mon, 19 Sep 2022 15:09:34 +0200
4 files changed,
23 insertions(+),
12 deletions(-)
M
res/js/frame-link.js
→
res/js/frame-link.js
@@ -34,13 +34,23 @@ setMainFrame();
} }); +function goToPageInitial(page) { + +} + //Checks to see if a page parameter exists and sets the mainframe src to that page. function setMainFrame() { let params = new URLSearchParams(window.location.search); let page = params.get(pageParam); - if (page != null) { - mainFrame.src = page; - } + if (page == null) return; + + music.pause() + controlsEnabled = false; + iframe.src = page; + + page_key = page.split("/")[2].split(".")[0]; + currentPage = page_key; + } //Updates the browser history with the current page, causing the URL bar to update.
M
res/js/iframe.js
→
res/js/iframe.js
@@ -1,2 +1,1 @@
-hide_all(); -parent.loadIFrame(parent.frameLoadedCallback);+hide_all();
M
res/js/main.js
→
res/js/main.js
@@ -24,9 +24,9 @@ function firstClickPlay(element) {
const overlay = document.getElementById("overlay"); if(overlay) { overlay.remove(); + // load this window hide_all(); start_loading(speed=loadSpeed, not_allowed, () => { loadIFrame(firstPlay) }); - //slow_load(speed=loadSpeed, not_allowed, () => { loadIFrame(firstPlay) }); } click1 = clickAudio1 || parent.clickAudio1;@@ -48,6 +48,7 @@
music.pause() controlsEnabled = false; iframe.src = "pages/" + page + ".html"; + iframe.onload = () => { loadIFrame(frameLoadedCallback); }; currentPage = page; }
M
res/js/slow_load.js
→
res/js/slow_load.js
@@ -21,7 +21,7 @@ const all = document.getElementsByTagName("*");
let total = 0; function hide_all() { - + total = 0; for (i in all) { const node = all[i]; if((node.childElementCount == 0) && (not_allowed.indexOf(node.tagName) === -1) && node.style){@@ -34,23 +34,24 @@ }
function start_loading(speed, not_allowed=[], callback) { + let counter = 0; + let i = 0; + function onNodeLoaded(node){ + node.style.display = node.getAttribute("data-display"); counter++; - ratio = counter / total * 100; + const ratio = counter / total * 100; playAudio(loadAudio[getRandomInt(0, loadAudio.length - 1)]); - + if (ratio >= 100 && callback) callback() } - let counter = 0; - let i = 0; for (element in all) { const node = all[element]; if((node.childElementCount == 0) && (not_allowed.indexOf(node.tagName) === -1) && node.style){ - i += getRandomInt(250 / speed, 500 / speed); setTimeout(() => { onNodeLoaded(node);}, i); }