forked from feincms/feincms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathie_compat.js
More file actions
60 lines (53 loc) · 1.46 KB
/
Copy pathie_compat.js
File metadata and controls
60 lines (53 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* Re-implement some methods IE sadly does not */
if(typeof(Array.prototype.indexOf) == 'undefined') {
// indexOf() function prototype for IE6/7/8 compatibility, taken from
// JavaScript Standard Library - http://www.devpro.it/JSL/
Array.prototype.indexOf=function(elm,i){
var j=this.length;
if(!i)i=0;
if(i>=0){while(i<j){if(this[i++]===elm){
i=i-1+j;j=i-j;
}}}
else
j=this.indexOf(elm,j+i);
return j!==this.length?j:-1;
};
}
if (!Array.prototype.filter)
{
Array.prototype.filter = function(fun /*, thisp*/)
{
var len = this.length;
if (typeof fun != "function")
throw new TypeError();
var res = [];
var thisp = arguments[1];
for (var i = 0; i < len; i++)
{
if (i in this)
{
var val = this[i]; // in case fun mutates this
if (fun.call(thisp, val, i, this))
res.push(val);
}
}
return res;
};
}
if (!Array.prototype.map)
{
Array.prototype.map = function(fun /*, thisp*/)
{
var len = this.length;
if (typeof fun != "function")
throw new TypeError();
var res = new Array(len);
var thisp = arguments[1];
for (var i = 0; i < len; i++)
{
if (i in this)
res[i] = fun.call(thisp, this[i], i, this);
}
return res;
};
}