Skip to content

Commit

Permalink
only update on ctrl+enter
Browse files Browse the repository at this point in the history
  • Loading branch information
felixroos committed Dec 1, 2024
1 parent 8e9c173 commit 45b6d00
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions _/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<details>
<summary>edit HTML</summary>
<textarea id="editor" rows="16" spellcheck="false"></textarea>
<span>press ctrl+enter to update</span>
</details>
</body>
<script>
Expand All @@ -66,17 +67,21 @@
editor.value = code;
render();

editor.addEventListener("input", () => {
window.location.hash = "#" + html_base64(editor.value);
// render();
});

window.addEventListener("hashchange", function () {
const urlCode = getCodeFromHash();
if (urlCode) {
editor.value = urlCode;
}
render();
});

editor.addEventListener("keydown", (e) => {
if ((e.ctrlKey || e.altKey) && e.key === "Enter") {
window.location.hash = "#" + html_base64(editor.value);
}
});
/* editor.addEventListener("input", () => {
window.location.hash = "#" + html_base64(editor.value);
}); */
</script>
</html>

0 comments on commit 45b6d00

Please sign in to comment.