possibilité de reaload avec "entrée"
This commit is contained in:
parent
4c65bb0a65
commit
95706a42c2
1 changed files with 27 additions and 19 deletions
14
index.html
14
index.html
|
|
@ -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>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue