diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-11-05 19:08:38 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-11-05 19:14:17 +0100 |
commit | 8a1ce1da15fdbae99b24700b06f2008c7a657603 (patch) | |
tree | 8e8ea3ba2dd4bc9b25e4cf7e23a17838df3cc396 | |
parent | df9aac5b6406bf192f2e4e0987e25d0de88480df (diff) | |
download | Shaarli-8a1ce1da15fdbae99b24700b06f2008c7a657603.tar.gz Shaarli-8a1ce1da15fdbae99b24700b06f2008c7a657603.tar.zst Shaarli-8a1ce1da15fdbae99b24700b06f2008c7a657603.zip |
ESLint
-rw-r--r-- | assets/default/js/base.js | 3 | ||||
-rw-r--r-- | assets/vintage/js/base.js | 10 |
2 files changed, 8 insertions, 5 deletions
diff --git a/assets/default/js/base.js b/assets/default/js/base.js index 37069d69..dd532bb7 100644 --- a/assets/default/js/base.js +++ b/assets/default/js/base.js | |||
@@ -55,7 +55,8 @@ function createAwesompleteInstance(element, separator, tags = []) { | |||
55 | // Highlight found items | 55 | // Highlight found items |
56 | awesome.item = (text, input) => Awesomplete.ITEM(text, input.match(new RegExp(`[^${separator}]*$`))[0]); | 56 | awesome.item = (text, input) => Awesomplete.ITEM(text, input.match(new RegExp(`[^${separator}]*$`))[0]); |
57 | // Don't display already selected items | 57 | // Don't display already selected items |
58 | const reg = new RegExp(`/(\w+)${separator}/g`); | 58 | // WARNING: pseudo classes does not seem to work with string litterals... |
59 | const reg = new RegExp(`([^${separator}]+)${separator}`, 'g'); | ||
59 | let match; | 60 | let match; |
60 | awesome.data = (item, input) => { | 61 | awesome.data = (item, input) => { |
61 | while ((match = reg.exec(input))) { | 62 | while ((match = reg.exec(input))) { |
diff --git a/assets/vintage/js/base.js b/assets/vintage/js/base.js index 15b664ce..55f1c37d 100644 --- a/assets/vintage/js/base.js +++ b/assets/vintage/js/base.js | |||
@@ -4,7 +4,7 @@ import 'awesomplete/awesomplete.css'; | |||
4 | (() => { | 4 | (() => { |
5 | const autocompleteFields = document.querySelectorAll('input[data-multiple]'); | 5 | const autocompleteFields = document.querySelectorAll('input[data-multiple]'); |
6 | const tagsSeparatorElement = document.querySelector('input[name="tags_separator"]'); | 6 | const tagsSeparatorElement = document.querySelector('input[name="tags_separator"]'); |
7 | const tagsSeparator = tagsSeparatorElement ? tagsSeparatorElement.value || " " : " "; | 7 | const tagsSeparator = tagsSeparatorElement ? tagsSeparatorElement.value || ' ' : ' '; |
8 | 8 | ||
9 | [...autocompleteFields].forEach((autocompleteField) => { | 9 | [...autocompleteFields].forEach((autocompleteField) => { |
10 | const awesome = new Awesomplete(Awesomplete.$(autocompleteField)); | 10 | const awesome = new Awesomplete(Awesomplete.$(autocompleteField)); |
@@ -12,8 +12,8 @@ import 'awesomplete/awesomplete.css'; | |||
12 | // Tags are separated by separator | 12 | // Tags are separated by separator |
13 | awesome.filter = (text, input) => Awesomplete.FILTER_CONTAINS( | 13 | awesome.filter = (text, input) => Awesomplete.FILTER_CONTAINS( |
14 | text, | 14 | text, |
15 | input.match(new RegExp(`[^${tagsSeparator}]*$`))[0]) | 15 | input.match(new RegExp(`[^${tagsSeparator}]*$`))[0], |
16 | ; | 16 | ); |
17 | // Insert new selected tag in the input | 17 | // Insert new selected tag in the input |
18 | awesome.replace = (text) => { | 18 | awesome.replace = (text) => { |
19 | const before = awesome.input.value.match(new RegExp(`^.+${tagsSeparator}+|`))[0]; | 19 | const before = awesome.input.value.match(new RegExp(`^.+${tagsSeparator}+|`))[0]; |
@@ -21,8 +21,10 @@ import 'awesomplete/awesomplete.css'; | |||
21 | }; | 21 | }; |
22 | // Highlight found items | 22 | // Highlight found items |
23 | awesome.item = (text, input) => Awesomplete.ITEM(text, input.match(new RegExp(`[^${tagsSeparator}]*$`))[0]); | 23 | awesome.item = (text, input) => Awesomplete.ITEM(text, input.match(new RegExp(`[^${tagsSeparator}]*$`))[0]); |
24 | |||
24 | // Don't display already selected items | 25 | // Don't display already selected items |
25 | const reg = new RegExp(`/(\w+)${tagsSeparator}/g`); | 26 | // WARNING: pseudo classes does not seem to work with string litterals... |
27 | const reg = new RegExp(`([^${tagsSeparator}]+)${tagsSeparator}`, 'g'); | ||
26 | let match; | 28 | let match; |
27 | awesome.data = (item, input) => { | 29 | awesome.data = (item, input) => { |
28 | while ((match = reg.exec(input))) { | 30 | while ((match = reg.exec(input))) { |