aboutsummaryrefslogtreecommitdiff
path: root/src/static/edit_script.js
blob: a73898f13170d8a521c7481cf13ae212db0a1cac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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();
}