possibilité de reaload avec "entrée"

This commit is contained in:
Didictateur 2025-04-15 22:39:53 +02:00
parent 4c65bb0a65
commit 95706a42c2

View file

@ -142,6 +142,9 @@
document.body.appendChild(currentScript); document.body.appendChild(currentScript);
} }
let lastLoadedScript = 'dp0.js';
let lastTextMode = true;
function loadScript(scriptName, txt = true) { function loadScript(scriptName, txt = true) {
if (window.cleanup) { if (window.cleanup) {
window.cleanup(); window.cleanup();
@ -158,16 +161,21 @@
document.body.appendChild(currentScript); document.body.appendChild(currentScript);
lastLoadedScript = scriptName;
lastTextMode = txt;
if (txt) { if (txt) {
const number = scriptName.substring(2, scriptName.length - 3); const number = scriptName.substring(2, scriptName.length - 3);
loadText("txt" + number + ".js"); loadText("txt" + number + ".js");
} }
} }
//tests document.addEventListener('keydown', function(event) {
loadScript('test.js', false); if (event.keyCode === 13 || event.key === 'Enter') {
loadScript(lastLoadedScript, lastTextMode);
}
});
//script initial
loadScript('dp0.js'); loadScript('dp0.js');
</script> </script>
</body> </body>