-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray_prototype.js
More file actions
82 lines (72 loc) · 1.97 KB
/
array_prototype.js
File metadata and controls
82 lines (72 loc) · 1.97 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
* @author Helena
*/
Array.prototype.diff = function(a) {
return this.filter(function(i) {return !(a.indexOf(i) > -1);});
};
if (!Array.prototype.filter)
{
Array.prototype.filter = function(fun /*, thisp */)
{
"use strict";
if (this == null)
throw new TypeError();
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun != "function")
{
}
//throw new TypeError();
var res = [];
var thisp = arguments[1];
for (var i = 0; i < len; i++)
{
if (i in t)
{
var val = t[i]; // in case fun mutates this
if (fun.call(thisp, val, i, t))
res.push(val);
}
}
return res;
};
}
Array.prototype.clean = function(deleteValue) {
for (var i = 0; i < this.length; i++) {
if (this[i] == deleteValue) {
this.splice(i, 1);
i--;
}
}
return this;
};
Array.prototype.getUnique = function(){
var u = {}, a = [];
for(var i = 0, l = this.length; i < l; ++i){
if(u.hasOwnProperty(this[i])) {
continue;
}
a.push(this[i]);
u[this[i]] = 1;
}
return a;
};
var GET = [];
function get() {
var query = unescape(window.location.search.replace("?",""));
if(query){
//Separate the parameters of the query
var query = query.replace(/\n/g, ' ');
var splitQuery = query.split("&");
for (var i=0; i<splitQuery.length; i++) {
if(typeof(splitQuery[i])==='string'){
//var tmp = splitQuery[i].match(/([A-Za-z0-9_]+)=(.*)/);
var tmp = splitQuery[i].match(/([A-Za-z0-9_]+)=/);
if(tmp){
//GET[tmp[1]] = tmp[2];
GET[tmp[1]] = splitQuery[i].replace(tmp[0],'');
}
}
}
}
};