1
- var _componentSvg = {
1
+ const _componentSvg = {
2
2
'trash' : `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash" viewBox="0 0 16 16">
3
3
<path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6z"/>
4
4
<path fill-rule="evenodd" d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118zM2.5 3V2h11v1h-11z"/>
@@ -38,7 +38,7 @@ function _componentRequest(url, method = "GET", data = {}, callback = function (
38
38
token = document . querySelector ( 'meta[name="csrf-token"]' ) . getAttribute ( 'content' ) ;
39
39
}
40
40
xhr . setRequestHeader ( "X-CSRF-TOKEN" , token ) ;
41
- if ( method == 'GET' ) {
41
+ if ( method === 'GET' ) {
42
42
xhr . setRequestHeader ( "Content-type" , "application/text;charset=UTF-8" ) ;
43
43
xhr . responseType = "text" ;
44
44
xhr . send ( null ) ;
@@ -48,7 +48,7 @@ function _componentRequest(url, method = "GET", data = {}, callback = function (
48
48
xhr . send ( data ) ;
49
49
}
50
50
xhr . onreadystatechange = function ( ) {
51
- if ( xhr . readyState == xhr . DONE && xhr . status == 200 ) {
51
+ if ( xhr . readyState === xhr . DONE && xhr . status = == 200 ) {
52
52
var response = xhr . response ;
53
53
callback ( response ) ;
54
54
}
@@ -107,7 +107,7 @@ class ComponentDot {
107
107
let selected_dom = '' ;
108
108
let select_dom = '' ;
109
109
for ( let i in select ) {
110
- if ( selected . indexOf ( parseInt ( i ) ) != - 1 ) {
110
+ if ( selected . indexOf ( parseInt ( i ) ) !== - 1 ) {
111
111
selected_dom += `<div class='dlp dlp-text dlp-label' data-id='${ i } ' title="${ select [ i ] } ">${ select [ i ] } </div>` ;
112
112
continue ;
113
113
}
@@ -143,34 +143,34 @@ class ComponentDot {
143
143
144
144
tagCal ( cdom , operate ) {
145
145
let id = parseInt ( cdom . getAttribute ( 'data-id' ) ) ;
146
- if ( operate == this . MODE . insert ) {
147
- if ( this . select_data . indexOf ( id ) == - 1 ) {
146
+ if ( operate === this . MODE . insert ) {
147
+ if ( this . select_data . indexOf ( id ) === - 1 ) {
148
148
this . select_data . push ( id ) ;
149
149
this . selectInputDOM . value = JSON . stringify ( this . select_data ) ;
150
150
}
151
- if ( this . selected_data . indexOf ( id ) == - 1 && this . insert_data . indexOf ( id ) == - 1 ) {
151
+ if ( this . selected_data . indexOf ( id ) === - 1 && this . insert_data . indexOf ( id ) = == - 1 ) {
152
152
this . insert_data . push ( id ) ;
153
153
this . insertInputDOM . value = JSON . stringify ( this . insert_data ) ;
154
154
}
155
155
let index = this . delete_data . indexOf ( id ) ;
156
- if ( index != - 1 ) {
156
+ if ( index !== - 1 ) {
157
157
this . delete_data . splice ( index , 1 ) ;
158
158
this . deleteInputDOM . value = JSON . stringify ( this . delete_data ) ;
159
159
}
160
160
return ;
161
161
}
162
- if ( operate == this . MODE . delete ) {
162
+ if ( operate === this . MODE . delete ) {
163
163
let index = this . select_data . indexOf ( id ) ;
164
- if ( index != - 1 ) {
164
+ if ( index !== - 1 ) {
165
165
this . select_data . splice ( index , 1 ) ;
166
166
this . selectInputDOM . value = JSON . stringify ( this . select_data ) ;
167
167
}
168
- if ( this . selected_data . indexOf ( id ) != - 1 && this . delete_data . indexOf ( id ) == - 1 ) {
168
+ if ( this . selected_data . indexOf ( id ) !== - 1 && this . delete_data . indexOf ( id ) = == - 1 ) {
169
169
this . delete_data . push ( id ) ;
170
170
this . deleteInputDOM . value = JSON . stringify ( this . delete_data ) ;
171
171
}
172
172
index = this . insert_data . indexOf ( id ) ;
173
- if ( index != - 1 ) {
173
+ if ( index !== - 1 ) {
174
174
this . insert_data . splice ( index , 1 ) ;
175
175
this . insertInputDOM . value = JSON . stringify ( this . insert_data ) ;
176
176
}
@@ -181,11 +181,11 @@ class ComponentDot {
181
181
var object = this ;
182
182
document . querySelector ( `#${ this . name } .dot-search` ) . addEventListener ( 'input' , function ( ) {
183
183
let search = this . value ;
184
- if ( search == '' ) {
184
+ if ( search === '' ) {
185
185
return ;
186
186
}
187
187
for ( let element of object . CONTENT_DOM . getElementsByClassName ( "dlp-label" ) ) {
188
- if ( element . innerText . indexOf ( search ) != - 1 ) {
188
+ if ( element . innerText . indexOf ( search ) !== - 1 ) {
189
189
object . CONTENT_DOM . insertBefore ( element , object . CONTENT_DOM . firstChild ) ;
190
190
}
191
191
}
@@ -332,10 +332,8 @@ class ComponentCascadeDot {
332
332
} ) ;
333
333
this . selectToChildren ( stack + 1 , data . nodes ) ;
334
334
}
335
- if ( Array . isArray ( data . parentNodes ) ) {
336
- for ( let stack in data . parentNodes ) {
337
- this . selectToParent ( data . parentNodes [ stack ] , parseInt ( stack ) , data . parentNodes [ stack - 1 ] ) ;
338
- }
335
+ if ( Array . isArray ( data . parentNodes ) && data . parentNodes . length > 0 ) {
336
+ this . selectToParent ( data . parentNodes ) ;
339
337
}
340
338
}
341
339
@@ -352,29 +350,19 @@ class ComponentCascadeDot {
352
350
this . SELECTED_DOM . append ( div ) ;
353
351
}
354
352
355
- selectToParent ( node , stack , parent_node , checked ) {
353
+ selectToParent ( nodes ) {
354
+ let stack = nodes . length - 1 ;
355
+ let node = nodes . pop ( ) ;
356
+ let parentNode = nodes [ stack - 1 ] ;
356
357
let currentStackDocuments = this . STACKS [ stack ] . childNodes ;
357
358
currentStackDocuments . forEach ( ( D , index ) => {
358
- /*if (checked == 'true') {
359
- if (node == parseInt(D.getAttribute('data-id'))) {
360
- let check = false;
361
- this.STACKS[stack + 1].childNodes.forEach((D) => {
362
- if (D.querySelector('i')) {
363
- check = true;
364
- }
365
- });
366
- !check && D.querySelector('i') != null && D.querySelector('i').remove();
367
- }
368
- return;
369
- }*/
370
- let parents = JSON . parse ( D . getAttribute ( 'data-parent-nodes-id' ) ) ;
359
+ let parents = this . dimensional_data [ stack ] [ index ] . parentNodes ;
371
360
currentStackDocuments [ index ] . classList . remove ( 'dlp-label-silence' ) ;
372
- if ( parents . length > 0 && ( parents [ stack - 1 ] != parent_node ) ) {
361
+ if ( parents . length > 0 && ( parents [ stack - 1 ] !== parentNode ) ) {
373
362
let D = currentStackDocuments [ index ] ;
374
363
D . classList . add ( 'dlp-label-silence' ) ;
375
364
}
376
- if ( node == parseInt ( D . getAttribute ( 'data-id' ) ) ) {
377
- if ( D . getAttribute ( 'checked' ) == 'true' || ( D . querySelector ( 'i' ) instanceof HTMLElement ) ) return ;
365
+ if ( node === parseInt ( D . getAttribute ( 'data-id' ) ) ) {
378
366
D . insertAdjacentHTML ( 'beforeend' , `<i>${ _componentSvg . check_circle } </i>` ) ;
379
367
}
380
368
} ) ;
@@ -405,34 +393,34 @@ class ComponentCascadeDot {
405
393
}
406
394
407
395
tagCal ( id , operate ) {
408
- if ( operate == this . MODE . insert ) {
409
- if ( this . select_data . indexOf ( id ) == - 1 ) {
396
+ if ( operate === this . MODE . insert ) {
397
+ if ( this . select_data . indexOf ( id ) === - 1 ) {
410
398
this . select_data . push ( id ) ;
411
399
this . selectInputDOM . value = JSON . stringify ( this . select_data ) ;
412
400
}
413
- if ( this . selected_data . indexOf ( id ) == - 1 && this . insert_data . indexOf ( id ) == - 1 ) {
401
+ if ( this . selected_data . indexOf ( id ) === - 1 && this . insert_data . indexOf ( id ) = == - 1 ) {
414
402
this . insert_data . push ( id ) ;
415
403
this . insertInputDOM . value = JSON . stringify ( this . insert_data ) ;
416
404
}
417
405
let index = this . delete_data . indexOf ( id ) ;
418
- if ( index != - 1 ) {
406
+ if ( index !== - 1 ) {
419
407
this . delete_data . splice ( index , 1 ) ;
420
408
this . deleteInputDOM . value = JSON . stringify ( this . delete_data ) ;
421
409
}
422
410
return ;
423
411
}
424
- if ( operate == this . MODE . delete ) {
412
+ if ( operate === this . MODE . delete ) {
425
413
let index = this . select_data . indexOf ( id ) ;
426
- if ( index != - 1 ) {
414
+ if ( index !== - 1 ) {
427
415
this . select_data . splice ( index , 1 ) ;
428
416
this . selectInputDOM . value = JSON . stringify ( this . select_data ) ;
429
417
}
430
- if ( this . selected_data . indexOf ( id ) != - 1 && this . delete_data . indexOf ( id ) == - 1 ) {
418
+ if ( this . selected_data . indexOf ( id ) !== - 1 && this . delete_data . indexOf ( id ) = == - 1 ) {
431
419
this . delete_data . push ( id ) ;
432
420
this . deleteInputDOM . value = JSON . stringify ( this . delete_data ) ;
433
421
}
434
422
index = this . insert_data . indexOf ( id ) ;
435
- if ( index != - 1 ) {
423
+ if ( index !== - 1 ) {
436
424
this . insert_data . splice ( index , 1 ) ;
437
425
this . insertInputDOM . value = JSON . stringify ( this . insert_data ) ;
438
426
}
0 commit comments