diff options
author | Martin Fischer <martin@push-f.com> | 2021-06-22 22:14:19 +0200 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2021-06-22 23:54:36 +0200 |
commit | d6d71d1693cb7d798bdf2b12c5fa6eea0a5860df (patch) | |
tree | 73e54182d77c4923f244b145b05c61ae67970d62 /src/static/edit_script.js |
publish
Diffstat (limited to 'src/static/edit_script.js')
-rw-r--r-- | src/static/edit_script.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/static/edit_script.js b/src/static/edit_script.js new file mode 100644 index 0000000..a73898f --- /dev/null +++ b/src/static/edit_script.js @@ -0,0 +1,15 @@ +const textarea = document.forms[0].text; +textarea.addEventListener('keydown', (e) => { + if (e.key == 'Escape') { + e.preventDefault(); + location.search = ''; + } +}); +if (location.hash) { + let match = location.hash.match(/L([0-9]+)-L([0-9]+)/); + if (match) { + textarea.setSelectionRange(match[1], match[2]); + } + // workaround for Chromium bug (https://crbug.com/1046357) + textarea.focus(); +}
\ No newline at end of file |