1 | /** |
||
2 | * SEOmatic plugin for Craft CMS 3.x |
||
3 | * |
||
4 | * A turnkey SEO implementation for Craft CMS that is comprehensive, powerful, |
||
5 | * and flexible |
||
6 | * |
||
7 | * @link https://nystudio107.com |
||
8 | * @copyright Copyright (c) 2017 nystudio107 |
||
9 | */ |
||
10 | |||
11 | /** |
||
12 | * @author nystudio107 |
||
13 | * @package SEOmatic |
||
14 | * @since 3.0.0 |
||
15 | */ |
||
16 | |||
17 | // JavaScript |
||
18 | import Tokenfield from 'tokenfield'; |
||
19 | |||
20 | // Tokenize any seomatic-keywords fields |
||
21 | for (const el of document.querySelectorAll('.seomatic-keywords')) { |
||
22 | let keywords = undefined; |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
Loading history...
|
|||
23 | |||
24 | if (el.value) { |
||
25 | keywords = el.value.split(',').map((value, index) => { |
||
26 | if (value !== '') { |
||
0 ignored issues
–
show
There is no return statement if
value !== "" is false . Are you sure this is correct? If so, consider adding return; explicitly.
This check looks for functions where a Consider this little piece of code function isBig(a) {
if (a > 5000) {
return "yes";
}
}
console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined
The function This behaviour may not be what you had intended. In any case, you can add a
Loading history...
|
|||
27 | return {id: index, name: value}; |
||
28 | } |
||
29 | }); |
||
30 | } |
||
31 | let options = { |
||
32 | el: el, |
||
33 | addItemOnBlur: true, |
||
34 | addItemsOnPaste: true, |
||
35 | delimiters: [','], |
||
36 | }; |
||
37 | if (keywords !== undefined && keywords[0] !== undefined) { |
||
38 | options.setItems = keywords; |
||
39 | } |
||
40 | let tf = new Tokenfield(options); |
||
41 | let resetting = false; |
||
42 | tf.on('change', (tokenField) => { |
||
43 | if (!resetting && el.disabled) { |
||
44 | resetting = true; |
||
45 | tokenField._onReset(); |
||
46 | resetting = false; |
||
47 | return; |
||
48 | } |
||
49 | |||
0 ignored issues
–
show
|
|||
50 | let values = tokenField._vars.setItems.map((value) => { |
||
51 | return value.name; |
||
52 | }); |
||
53 | |||
0 ignored issues
–
show
|
|||
54 | tokenField.el.value = values.join(','); |
||
55 | }); |
||
56 | } |
||
57 |