aboutsummaryrefslogtreecommitdiff
path: root/src/static/edit_script.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/static/edit_script.js')
-rw-r--r--src/static/edit_script.js15
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