Fixed JavaScript "no-cond-assign" violations.
This commit is contained in:
parent
77a112cb88
commit
71df9b7de4
|
@ -1,4 +1,3 @@
|
||||||
/*eslint no-cond-assign:1*/
|
|
||||||
(function() {
|
(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
var SelectBox = {
|
var SelectBox = {
|
||||||
|
@ -8,16 +7,19 @@
|
||||||
var node;
|
var node;
|
||||||
SelectBox.cache[id] = [];
|
SelectBox.cache[id] = [];
|
||||||
var cache = SelectBox.cache[id];
|
var cache = SelectBox.cache[id];
|
||||||
for (var i = 0; (node = box.options[i]); i++) {
|
for (var i = 0, j = box.options.length; i < j; i++) {
|
||||||
|
node = box.options[i];
|
||||||
cache.push({value: node.value, text: node.text, displayed: 1});
|
cache.push({value: node.value, text: node.text, displayed: 1});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
redisplay: function(id) {
|
redisplay: function(id) {
|
||||||
// Repopulate HTML select box from cache
|
// Repopulate HTML select box from cache
|
||||||
var box = document.getElementById(id);
|
var box = document.getElementById(id);
|
||||||
|
var node;
|
||||||
box.options.length = 0; // clear all options
|
box.options.length = 0; // clear all options
|
||||||
for (var i = 0, j = SelectBox.cache[id].length; i < j; i++) {
|
var cache = SelectBox.cache[id];
|
||||||
var node = SelectBox.cache[id][i];
|
for (var i = 0, j = cache.length; i < j; i++) {
|
||||||
|
node = cache[i];
|
||||||
if (node.displayed) {
|
if (node.displayed) {
|
||||||
var new_option = new Option(node.text, node.value, false, false);
|
var new_option = new Option(node.text, node.value, false, false);
|
||||||
// Shows a tooltip when hovering over the option
|
// Shows a tooltip when hovering over the option
|
||||||
|
@ -31,9 +33,13 @@
|
||||||
// the words in text. (It's an AND search.)
|
// the words in text. (It's an AND search.)
|
||||||
var tokens = text.toLowerCase().split(/\s+/);
|
var tokens = text.toLowerCase().split(/\s+/);
|
||||||
var node, token;
|
var node, token;
|
||||||
for (var i = 0; (node = SelectBox.cache[id][i]); i++) {
|
var cache = SelectBox.cache[id];
|
||||||
|
for (var i = 0, j = cache.length; i < j; i++) {
|
||||||
|
node = cache[i];
|
||||||
node.displayed = 1;
|
node.displayed = 1;
|
||||||
for (var j = 0; (token = tokens[j]); j++) {
|
var numTokens = tokens.length;
|
||||||
|
for (var k = 0; k < numTokens; k++) {
|
||||||
|
token = tokens[k];
|
||||||
if (node.text.toLowerCase().indexOf(token) === -1) {
|
if (node.text.toLowerCase().indexOf(token) === -1) {
|
||||||
node.displayed = 0;
|
node.displayed = 0;
|
||||||
}
|
}
|
||||||
|
@ -43,17 +49,19 @@
|
||||||
},
|
},
|
||||||
delete_from_cache: function(id, value) {
|
delete_from_cache: function(id, value) {
|
||||||
var node, delete_index = null;
|
var node, delete_index = null;
|
||||||
for (var i = 0; (node = SelectBox.cache[id][i]); i++) {
|
var cache = SelectBox.cache[id];
|
||||||
|
for (var i = 0, j = cache.length; i < j; i++) {
|
||||||
|
node = cache[i];
|
||||||
if (node.value === value) {
|
if (node.value === value) {
|
||||||
delete_index = i;
|
delete_index = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var j = SelectBox.cache[id].length - 1;
|
var k = cache.length - 1;
|
||||||
for (i = delete_index; i < j; i++) {
|
for (i = delete_index; i < k; i++) {
|
||||||
SelectBox.cache[id][i] = SelectBox.cache[id][i + 1];
|
cache[i] = cache[i + 1];
|
||||||
}
|
}
|
||||||
SelectBox.cache[id].length--;
|
cache.length--;
|
||||||
},
|
},
|
||||||
add_to_cache: function(id, option) {
|
add_to_cache: function(id, option) {
|
||||||
SelectBox.cache[id].push({value: option.value, text: option.text, displayed: 1});
|
SelectBox.cache[id].push({value: option.value, text: option.text, displayed: 1});
|
||||||
|
@ -61,7 +69,9 @@
|
||||||
cache_contains: function(id, value) {
|
cache_contains: function(id, value) {
|
||||||
// Check if an item is contained in the cache
|
// Check if an item is contained in the cache
|
||||||
var node;
|
var node;
|
||||||
for (var i = 0; (node = SelectBox.cache[id][i]); i++) {
|
var cache = SelectBox.cache[id];
|
||||||
|
for (var i = 0, j = cache.length; i < j; i++) {
|
||||||
|
node = cache[i];
|
||||||
if (node.value === value) {
|
if (node.value === value) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +81,9 @@
|
||||||
move: function(from, to) {
|
move: function(from, to) {
|
||||||
var from_box = document.getElementById(from);
|
var from_box = document.getElementById(from);
|
||||||
var option;
|
var option;
|
||||||
for (var i = 0; (option = from_box.options[i]); i++) {
|
var boxOptions = from_box.options;
|
||||||
|
for (var i = 0, j = boxOptions.length; i < j; i++) {
|
||||||
|
option = boxOptions[i];
|
||||||
if (option.selected && SelectBox.cache_contains(from, option.value)) {
|
if (option.selected && SelectBox.cache_contains(from, option.value)) {
|
||||||
SelectBox.add_to_cache(to, {value: option.value, text: option.text, displayed: 1});
|
SelectBox.add_to_cache(to, {value: option.value, text: option.text, displayed: 1});
|
||||||
SelectBox.delete_from_cache(from, option.value);
|
SelectBox.delete_from_cache(from, option.value);
|
||||||
|
@ -83,7 +95,9 @@
|
||||||
move_all: function(from, to) {
|
move_all: function(from, to) {
|
||||||
var from_box = document.getElementById(from);
|
var from_box = document.getElementById(from);
|
||||||
var option;
|
var option;
|
||||||
for (var i = 0; (option = from_box.options[i]); i++) {
|
var boxOptions = from_box.options;
|
||||||
|
for (var i = 0, j = boxOptions.length; i < j; i++) {
|
||||||
|
option = boxOptions[i];
|
||||||
if (SelectBox.cache_contains(from, option.value)) {
|
if (SelectBox.cache_contains(from, option.value)) {
|
||||||
SelectBox.add_to_cache(to, {value: option.value, text: option.text, displayed: 1});
|
SelectBox.add_to_cache(to, {value: option.value, text: option.text, displayed: 1});
|
||||||
SelectBox.delete_from_cache(from, option.value);
|
SelectBox.delete_from_cache(from, option.value);
|
||||||
|
@ -93,7 +107,7 @@
|
||||||
SelectBox.redisplay(to);
|
SelectBox.redisplay(to);
|
||||||
},
|
},
|
||||||
sort: function(id) {
|
sort: function(id) {
|
||||||
SelectBox.cache[id].sort( function(a, b) {
|
SelectBox.cache[id].sort(function(a, b) {
|
||||||
a = a.text.toLowerCase();
|
a = a.text.toLowerCase();
|
||||||
b = b.text.toLowerCase();
|
b = b.text.toLowerCase();
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue