aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Benjamin Jones <bjones@galois.com>2012-10-22 14:29:09 -0700
committerGravatar Benjamin Jones <bjones@galois.com>2012-10-22 14:29:09 -0700
commit806a3481a674ecb96948473578841647e27f3a0b (patch)
tree3dfba998469de462143506f447d2b05019912f6a
parent336788ccac1db986dc1c55eb920dfd942152c1ed (diff)
fixed bug with global for loop index i
-rw-r--r--contexts/data/fiveui/injected/jquery-plugins.js5
-rw-r--r--contexts/data/fiveui/injected/prelude.js15
2 files changed, 13 insertions, 7 deletions
diff --git a/contexts/data/fiveui/injected/jquery-plugins.js b/contexts/data/fiveui/injected/jquery-plugins.js
index 2a9b76f..1fb084c 100644
--- a/contexts/data/fiveui/injected/jquery-plugins.js
+++ b/contexts/data/fiveui/injected/jquery-plugins.js
@@ -80,12 +80,11 @@ fiveui.jqueryPlugins.notColorSet = function (cset) {
fiveui.jqueryPlugins.cssIsNot = function (prop, set, fn) {
var allowable = {};
fn = fn || function (x) { return x; }; // default is Id
-
- if (typeof set == "string") {
+ if (typeof set === "string") {
allowable[fn(set)] = true;
}
else { // assume `set` is an array of strings
- for (i = 0; i < set.length; i += 1) { allowable[fn(set[i])] = true; } // array -> object
+ for (var i = 0; i < set.length; i += 1) { allowable[fn(set[i])] = true; } // array -> object
}
return this.filter(function (index) {
var cssProp = fn($(this).css(prop));
diff --git a/contexts/data/fiveui/injected/prelude.js b/contexts/data/fiveui/injected/prelude.js
index 9a83df6..f799883 100644
--- a/contexts/data/fiveui/injected/prelude.js
+++ b/contexts/data/fiveui/injected/prelude.js
@@ -230,16 +230,23 @@ fiveui.color.colorToHex = function(color) {
var haveDigits = color.substr(1, color.length);
var need = 6 - have;
var reps = Math.ceil(need / have);
+ var i, strColor;
for (i = 0, stdColor = color; i < reps; i += 1) { stdColor += haveDigits; }
return stdColor.substr(0, 7);
}
}
- var digits = /rgb(a)?\((\d+), (\d+), (\d+)/.exec(color);
+ var digits = /rgba?\((\d+), (\d+), (\d+)/.exec(color);
+ if (!digits) {
+ throw {
+ name: 'ParseError',
+ message: 'Could not parse rgb color: ' + color
+ };
+ }
- var red = parseInt(digits[2]);
- var green = parseInt(digits[3]);
- var blue = parseInt(digits[4]);
+ var red = parseInt(digits[1]);
+ var green = parseInt(digits[2]);
+ var blue = parseInt(digits[3]);
var rgb = blue | (green << 8) | (red << 16);
if (rgb === 0) {