diff --git a/index.html b/index.html index ad64589..b2b5952 100644 --- a/index.html +++ b/index.html @@ -141,33 +141,41 @@ document.body.appendChild(currentScript); } + + let lastLoadedScript = 'dp0.js'; + let lastTextMode = true; - function loadScript(scriptName, txt = true) { - if (window.cleanup) { - window.cleanup(); - } + function loadScript(scriptName, txt = true) { + if (window.cleanup) { + window.cleanup(); + } - const container = document.getElementById("canvasContainer"); - container.innerHTML = ``; + const container = document.getElementById("canvasContainer"); + container.innerHTML = ``; - const timestamp = new Date().getTime(); + const timestamp = new Date().getTime(); - currentScript = document.createElement("script"); - currentScript.type = "module"; - currentScript.src = `build/${scriptName}?t=${timestamp}`; + currentScript = document.createElement("script"); + currentScript.type = "module"; + currentScript.src = `build/${scriptName}?t=${timestamp}`; - document.body.appendChild(currentScript); + document.body.appendChild(currentScript); + + lastLoadedScript = scriptName; + lastTextMode = txt; - if (txt) { - const number = scriptName.substring(2, scriptName.length - 3); - loadText("txt" + number + ".js"); - } + if (txt) { + const number = scriptName.substring(2, scriptName.length - 3); + loadText("txt" + number + ".js"); + } } - - //tests - loadScript('test.js', false); - //script initial + document.addEventListener('keydown', function(event) { + if (event.keyCode === 13 || event.key === 'Enter') { + loadScript(lastLoadedScript, lastTextMode); + } + }); + loadScript('dp0.js');