summaryrefslogtreecommitdiff
path: root/src/static/js/html10n.js
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2013-01-23 17:40:10 +0100
committerMarcel Klehr <mklehr@gmx.net>2013-01-23 17:40:10 +0100
commit25e1ed2d0cd6ea60668c853bc3f7e168df280b1c (patch)
tree3e20216e89560e03a81c77f1f5e78ad2d37c7299 /src/static/js/html10n.js
parent557b5c1ad089764d0ff602887f4b653fb3573d70 (diff)
downloadetherpad-lite-25e1ed2d0cd6ea60668c853bc3f7e168df280b1c.zip
Fix Array.prototype.indexOf for IE8! <3
Diffstat (limited to 'src/static/js/html10n.js')
-rw-r--r--src/static/js/html10n.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/static/js/html10n.js b/src/static/js/html10n.js
index b2c4e619..d0d14814 100644
--- a/src/static/js/html10n.js
+++ b/src/static/js/html10n.js
@@ -21,6 +21,8 @@
* IN THE SOFTWARE.
*/
window.html10n = (function(window, document, undefined) {
+
+ // fix console
var console = window.console
function interceptConsole(method){
if (!console) return function() {}
@@ -44,6 +46,39 @@ window.html10n = (function(window, document, undefined) {
, consoleError = interceptConsole('warn')
+ // fix Array.prototype.instanceOf in, guess what, IE! <3
+ if (!Array.prototype.indexOf) {
+ Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
+ "use strict";
+ if (this == null) {
+ throw new TypeError();
+ }
+ var t = Object(this);
+ var len = t.length >>> 0;
+ if (len === 0) {
+ return -1;
+ }
+ var n = 0;
+ if (arguments.length > 1) {
+ n = Number(arguments[1]);
+ if (n != n) { // shortcut for verifying if it's NaN
+ n = 0;
+ } else if (n != 0 && n != Infinity && n != -Infinity) {
+ n = (n > 0 || -1) * Math.floor(Math.abs(n));
+ }
+ }
+ if (n >= len) {
+ return -1;
+ }
+ var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0);
+ for (; k < len; k++) {
+ if (k in t && t[k] === searchElement) {
+ return k;
+ }
+ }
+ return -1;
+ }
+ }
/**
* MicroEvent - to make any js object an event emitter (server or browser)