Skip to content

Commit e7c1997

Browse files
author
hikki
committed
js warning fix
1 parent e277f7f commit e7c1997

File tree

1 file changed

+46
-47
lines changed

1 file changed

+46
-47
lines changed

resources/assets/component.js

Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const _component = {
1111
<path fill-rule="evenodd" d="M1 13.5A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-6a.5.5 0 0 0-1 0v6a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5v-11a.5.5 0 0 1 .5-.5H9a.5.5 0 0 0 0-1H2.5A1.5 1.5 0 0 0 1 2.5v11z"/>
1212
</svg>`,
1313
'close': `<svg style="vertical-align: middle;" width="14" height="14" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill="none" stroke="white" stroke-width="2.5" d="M16,16 L4,4"></path><path fill="none" stroke="white" stroke-width="2.5" d="M16,4 L4,16"></path></svg>`,
14-
'loading': `<svg version="1.1" style="width: 100%;height:100px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
14+
'loading': `<svg style="width: 100%;height:100px" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
1515
width="40px" height="40px" viewBox="0 0 40 40" enable-background="new 0 0 40 40" xml:space="preserve">
1616
<path opacity="0.2" fill="#000" d="M20.201,5.169c-8.254,0-14.946,6.692-14.946,14.946c0,8.255,6.692,14.946,14.946,14.946
1717
s14.946-6.691,14.946-14.946C35.146,11.861,28.455,5.169,20.201,5.169z M20.201,31.749c-6.425,0-11.634-5.208-11.634-11.634
@@ -62,7 +62,7 @@ type="rotate" from="0 20 20" to="360 20 20" dur="0.5s" repeatCount="indefinite"/
6262
let style = "z-index: 1000000; position: fixed;background-color: rgba(0,0,0,.6);color: #fff;" +
6363
"width: 280px;height: 45px;line-height: 40px;border-radius: 3px;text-align: center;" +
6464
"top:" + h + "px;left:" + w + "px;";
65-
div.setAttribute('style',style);
65+
div.setAttribute('style', style);
6666
document.getElementsByTagName("BODY")[0].appendChild(div);
6767
let task = setTimeout(function () {
6868
clearTimeout(task);
@@ -76,7 +76,7 @@ type="rotate" from="0 20 20" to="360 20 20" dur="0.5s" repeatCount="indefinite"/
7676
}, options);
7777
let ul = document.createElement('ul');
7878
ul.className = 'dlp dlp-contextmenu';
79-
list.forEach((v)=>{
79+
list.forEach((v) => {
8080
let li = document.createElement('li');
8181
li.className = 'dlp dlp-text';
8282
li.textContent = v.title;
@@ -145,12 +145,12 @@ class ComponentDot {
145145
let selected_dom = '';
146146
let select_dom = '';
147147
for (let i in select) {
148-
if(!select.hasOwnProperty(i))continue;
148+
if (!select.hasOwnProperty(i)) continue;
149149
if (selected.indexOf(parseInt(i)) !== -1) {
150-
selected_dom += `<div class='dlp dlp-text dlp-label' data-id='${i}' title="${select[i]}">${select[i]}</div>`;
150+
selected_dom += `<div class="dlp dlp-text dlp-label" data-id="${i}" title="${select[i]}">${select[i]}</div>`;
151151
continue;
152152
}
153-
select_dom += `<div class='dlp dlp-text dlp-label' data-id='${i}' title="${select[i]}">${select[i]}</div>`;
153+
select_dom += `<div class="dlp dlp-text dlp-label" data-id="${i}" title="${select[i]}">${select[i]}</div>`;
154154
}
155155

156156
let html = `<div class="dlp-dot" ><div class="dot-top"><input type="text" class="dlp dot-search" placeholder="搜索名称"><div class="dot-selected dlp-scroll">${selected_dom}</div></div><div class="dot-body"><div class="dot-select dlp-scroll">${select_dom}</div></div></div>
@@ -183,8 +183,7 @@ class ComponentDot {
183183
if (index === -1) {
184184
this.select_data.push(id);
185185
this.selectInputDOM.value = JSON.stringify(this.select_data);
186-
}
187-
if (this.selected_data.indexOf(id) === -1 && this.insert_data.indexOf(id) === -1) {
186+
} else if (this.selected_data.indexOf(id) === -1 && this.insert_data.indexOf(id) === -1) {
188187
this.insert_data.push(id);
189188
this.insertInputDOM.value = JSON.stringify(this.insert_data);
190189
}
@@ -193,13 +192,11 @@ class ComponentDot {
193192
this.delete_data.splice(index, 1);
194193
this.deleteInputDOM.value = JSON.stringify(this.delete_data);
195194
}
196-
return;
197-
}else {
195+
} else {
198196
if (index !== -1) {
199197
this.select_data.splice(index, 1);
200198
this.selectInputDOM.value = JSON.stringify(this.select_data);
201-
}
202-
if (this.selected_data.indexOf(id) !== -1 && this.delete_data.indexOf(id) === -1) {
199+
} else if (this.selected_data.indexOf(id) !== -1 && this.delete_data.indexOf(id) === -1) {
203200
this.delete_data.push(id);
204201
this.deleteInputDOM.value = JSON.stringify(this.delete_data);
205202
}
@@ -297,7 +294,7 @@ class ComponentCascadeDot {
297294
this.makeDimensional(select);
298295
let object = this;
299296
for (let stack in this.dimensional_data) {
300-
if(!this.dimensional_data.hasOwnProperty(stack)) continue;
297+
if (!this.dimensional_data.hasOwnProperty(stack)) continue;
301298
stack = parseInt(stack);
302299
let data = this.dimensional_data[stack];
303300
let stackDom = document.createElement('div');
@@ -315,22 +312,26 @@ class ComponentCascadeDot {
315312
div.setAttribute('data-id', v.key);
316313
div.setAttribute('data-k', k);
317314
div.addEventListener('click', this.select.bind(this, div, stack));
318-
if(v.nodes !== null){
315+
if (v.nodes !== null) {
319316
div.addEventListener("contextmenu", (e) => {
320317
e.preventDefault();
321318
let k = parseInt(div.getAttribute('data-k'));
322319
_component.contextmenu(e, [
323-
{title:'全选',func: () => {
324-
object.checkAll(stack + 1,
325-
this.dimensional_data[stack][k].nodes,true);
326-
}},
327-
{title:'取消',func: () => {
328-
object.checkAll(stack + 1,
329-
this.dimensional_data[stack][k].nodes,false);
330-
}}
320+
{
321+
title: '全选', func: () => {
322+
object.checkAll(stack + 1,
323+
this.dimensional_data[stack][k].nodes, true);
324+
}
325+
},
326+
{
327+
title: '取消', func: () => {
328+
object.checkAll(stack + 1,
329+
this.dimensional_data[stack][k].nodes, false);
330+
}
331+
}
331332
]);
332333
});
333-
}else {
334+
} else {
334335
div.addEventListener("contextmenu", (e) => {
335336
e.preventDefault();
336337
});
@@ -361,7 +362,7 @@ class ComponentCascadeDot {
361362
makeDimensional(data, dimension = 0, parentNodes = []) {
362363
if (Array.isArray(data)) {
363364
for (let k in data) {
364-
if(!data.hasOwnProperty(k))continue;
365+
if (!data.hasOwnProperty(k)) continue;
365366
let parents = parentNodes.slice(0);
366367
parents.push(data[k].key);
367368
this.makeDimensional(data[k], dimension, parents);
@@ -574,20 +575,20 @@ class ComponentCascadeDot {
574575
this.CONTENT_DOM.parentNode.append(this.SELECT_COVER_DOM);
575576
}
576577
this.dimensional_data.forEach((data, stack) => {
577-
this.searchPushTag(search,data,stack);
578+
this.searchPushTag(search, data, stack);
578579
});
579580
}
580581

581582
searchCoverClick(stack, data, dom) {
582583
if (data.nodes !== null) {
583584
let nextStack = stack + 1;
584-
this.searchPushTag(this.dimensional_data[nextStack],data,nextStack);
585+
this.searchPushTag(this.dimensional_data[nextStack], data, nextStack);
585586
return;
586587
}
587588
(dom instanceof HTMLElement) && dom.click();
588589
}
589590

590-
searchPushTag(search,data,stack){
591+
searchPushTag(search, data, stack) {
591592
data.forEach((d, k) => {
592593
if (d.val.indexOf(search.value) !== -1 &&
593594
(!Array.isArray(this.COVER_STACK_HASH_DOM[stack]) || this.COVER_STACK_HASH_DOM[stack].indexOf(d.key) === -1)) {
@@ -663,10 +664,10 @@ class ComponentLine {
663664

664665
makeHead() {
665666
let head = '<tr>';
666-
let foot = head;
667+
let foot = '<tr>';
667668
let columns = this.COLUMNS;
668669
for (let column in columns) {
669-
if(!columns.hasOwnProperty(column)) continue;
670+
if (!columns.hasOwnProperty(column)) continue;
670671
let val = columns[column];
671672
if (val.type === 'hidden') {
672673
continue;
@@ -676,7 +677,7 @@ class ComponentLine {
676677
foot += `<th style="${val.style}"><input class="dlp-input" data-column="${column}" placeholder=":${val.name}"/></th>`;
677678
continue;
678679
}
679-
head += '<th>' + val.name + '</th>';
680+
head += `<th>${val.name}</th>`;
680681
foot += `<th><input class="dlp-input" data-column="${column}" placeholder=":${val.name}"/></th>`;
681682
}
682683
head += '<th class="operate-column" style="width: 48px;"></th></tr>';
@@ -698,7 +699,7 @@ class ComponentLine {
698699
tr.setAttribute('sortable-item', 'sortable-item');
699700
let record = {};
700701
for (let column in columns) {
701-
if(!columns.hasOwnProperty(column)) continue;
702+
if (!columns.hasOwnProperty(column)) continue;
702703
if (columns[column].type === 'hidden') {
703704
if (value[column]) {
704705
record[column] = value[column];
@@ -752,19 +753,17 @@ class ComponentLine {
752753
let tr = document.createElement('tr');
753754
tr.setAttribute('sortable-item', 'sortable-item');
754755
tr.setAttribute('data-key', object.DATA.length.toString());
755-
for (let input in inputs) {
756-
if (inputs.hasOwnProperty(input)) {
757-
let td = document.createElement('td');
758-
let column = inputs[input].getAttribute('data-column');
759-
insert[column] = inputs[input].value;
756+
for (let input of inputs) {
757+
let td = document.createElement('td');
758+
let column = input.getAttribute('data-column');
759+
insert[column] = input.value;
760760

761-
object.makeTd(td, object.COLUMNS[column].type, inputs[input].value, column);
762-
if (object.COLUMNS[column].style) {
763-
td.style = object.COLUMNS[column].style;
764-
}
765-
tr.appendChild(td);
766-
inputs[input].value = '';
761+
object.makeTd(td, object.COLUMNS[column].type, input.value, column);
762+
if (object.COLUMNS[column].style) {
763+
td.style = object.COLUMNS[column].style;
767764
}
765+
tr.appendChild(td);
766+
input.value = '';
768767
}
769768
let td = document.createElement('td');
770769
object.operateButton(td);
@@ -789,7 +788,7 @@ class ComponentLine {
789788
input.setAttribute('data-column', column);
790789
input.value = value;
791790
for (let attribute in attributes) {
792-
if(!attributes.hasOwnProperty(attribute)) continue;
791+
if (!attributes.hasOwnProperty(attribute)) continue;
793792
input.setAttribute(attribute, attributes[attribute]);
794793
}
795794
input.addEventListener('input', function () {
@@ -809,7 +808,7 @@ class ComponentLine {
809808
}
810809

811810
operateButton(td) {
812-
var object = this;
811+
let object = this;
813812
if (this.OPTIONS.sortable) {
814813
let M = document.createElement('i');
815814
M.setAttribute('style', 'cursor: pointer;margin-right:5px;');
@@ -831,7 +830,7 @@ class ComponentLine {
831830
tbody.removeChild(tr);
832831
object.DATA_INPUT.value = JSON.stringify(object.DATA);
833832
for (let node in tbody.childNodes) {
834-
if(!tbody.childNodes.hasOwnProperty(node))continue;
833+
if (!tbody.childNodes.hasOwnProperty(node)) continue;
835834
if (tbody.childNodes[node] instanceof HTMLElement) {
836835
tbody.childNodes[node].setAttribute('data-key', node);
837836
}
@@ -1029,7 +1028,7 @@ class ComponentSortable {
10291028
e.preventDefault();
10301029
}
10311030

1032-
dragEnd(e) {
1031+
dragEnd() {
10331032
this.animation = true;
10341033
if (this.items.length < 2) return;
10351034
this.item.style.transition = `all ${this.options.animationSpeed}ms ${this.options.animationEasing}`;
@@ -1063,7 +1062,7 @@ class ComponentSortable {
10631062
}
10641063

10651064
swapElements(array, a, b) {
1066-
const temp = array[a];
1065+
let temp = array[a];
10671066
array[a] = array[b];
10681067
array[b] = temp;
10691068
}

0 commit comments

Comments
 (0)