aboutsummaryrefslogtreecommitdiffstats
path: root/js/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/util.js')
-rw-r--r--js/util.js25
1 files changed, 21 insertions, 4 deletions
diff --git a/js/util.js b/js/util.js
index 6d1f88938..d3a34477b 100644
--- a/js/util.js
+++ b/js/util.js
@@ -125,10 +125,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;
}
@@ -138,6 +135,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.