2 var inputs_to_ignore = ['and_tag', 'not_tag', 'filter'];
3 var update_button_names = ['update'];
4 var sending_commits = false;
5 var changes_to_commit = false;
6 var form_to_watch = document.getElementById('form_to_watch');
7 for (let i = 0; i < form_to_watch.elements.length; i++) {
8 let el = form_to_watch.elements[i];
9 if (['INPUT', 'TEXTAREA', 'SELECT'].includes(el.tagName)) {
10 el.addEventListener('change', function(event) {
11 if (!inputs_to_ignore.includes(event.target.name)) {
12 changes_to_commit = true;
17 form_to_watch.addEventListener('keydown', function(event) {
18 let el = document.activeElement;
19 if ('Enter' === event.key
20 && ['INPUT', 'SELECT'].includes(el.tagName)
21 && (el.tagName !== 'INPUT' || el.type !== 'submit')) {
22 event.preventDefault();
23 if (inputs_to_ignore.includes(el.name)) {
24 document.getElementById('filter_button').click();
26 document.getElementById('update_button').click();
30 form_to_watch.addEventListener('submit', function(event) {
31 if (update_button_names.includes(event.submitter.name)) {
32 sending_commits = true;
35 window.addEventListener('beforeunload', function(event) {
36 if (changes_to_commit && !sending_commits) {
37 var warning = 'about to lose unsaved changes, continue?';
38 event.returnValue = warning;