diff options
Diffstat (limited to 'js/util.js')
-rw-r--r-- | js/util.js | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/js/util.js b/js/util.js index e0e87259f..cc4a87081 100644 --- a/js/util.js +++ b/js/util.js @@ -143,10 +143,7 @@ function bz_overlayBelow(item, parent) { */ function bz_isValueInArray(aArray, aValue) { - var run = 0; - var len = aArray.length; - - for ( ; run < len; run++) { + for (var run = 0, len = aArray.length ; run < len; run++) { if (aArray[run] == aValue) { return true; } @@ -156,6 +153,26 @@ function bz_isValueInArray(aArray, aValue) } /** + * Checks if a specified value is in the specified array by performing a + * case-insensitive comparison. + * + * @param aArray Array to search for the value. + * @param aValue Value to search from the array. + * @return Boolean; true if value is found in the array and false if not. + */ +function bz_isValueInArrayIgnoreCase(aArray, aValue) +{ + var re = new RegExp(aValue.replace(/([^A-Za-z0-9])/g, "\\$1"), 'i'); + for (var run = 0, len = aArray.length ; run < len; run++) { + if (aArray[run].match(re)) { + return true; + } + } + + return false; +} + +/** * Create wanted options in a select form control. * * @param aSelect Select form control to manipulate. |