Fail more gracefully on pre-IE9 browsers (still room for improvement though)

This commit is contained in:
Jeff Parsons 2015-04-25 12:54:03 -07:00 committed by jeffpar
commit fcb7c32909
6 changed files with 43 additions and 9 deletions

View file

@ -249,7 +249,7 @@ Component.log = function(s, type)
Component.msStart = usr.getTime();
}
msElapsed = usr.getTime() - Component.msStart;
console.log(msElapsed + "ms: " + sMsg.replace(/\n/g, " "));
if (window && window.console) console.log(msElapsed + "ms: " + sMsg.replace(/\n/g, " "));
}
}
};
@ -658,7 +658,7 @@ Component.prototype = {
}
control.value += s + "\n";
control.scrollTop = control.scrollHeight;
if (DEBUG) console.log(s);
if (DEBUG && window && window.console) console.log(s);
};
}(control));
/**

View file

@ -34,6 +34,28 @@
var usr = {};
/**
* indexOf(a, t, i)
*
* @param {Array} a
* @param {*} t
* @param {number} [i]
* @returns {number}
*/
usr.indexOf = function(a, t, i)
{
if (Array.prototype.indexOf) {
return a.indexOf(t, i);
}
i = i || 0;
if (i < 0) i += a.length;
if (i < 0) i = 0;
for (var n = a.length; i < n; i++) {
if (i in a && a[i] === t) return i;
}
return -1;
};
/**
* binarySearch(a, v, fnCompare)
*