repoindex/web/js/proto.js

44 lines
986 B
JavaScript
Raw Normal View History

2015-08-10 22:46:01 +02:00
(function() {
// let's add some "evil" prototype definitions
if(!String.prototype.contains) {
2016-02-10 21:09:20 +01:00
String.prototype.contains = function(substr) {
return this.indexOf(substr) !== -1;
2015-08-10 22:46:01 +02:00
};
}
if(!Array.prototype.contains) {
2016-02-10 21:09:20 +01:00
Array.prototype.contains = function(element) {
return this.indexOf(element) !== -1;
2015-08-10 22:46:01 +02:00
};
}
if(!Array.prototype.last) {
Array.prototype.last = function() {
return this[this.length - 1];
};
}
if(!Array.prototype.first) {
Array.prototype.first = function() {
return this[0];
};
}
2016-02-10 21:09:20 +01:00
if(!Array.prototype.second) {
Array.prototype.second = function() {
return this[1];
};
}
2015-08-10 22:46:01 +02:00
if(!Node.prototype.wipeChildren) {
Node.prototype.wipeChildren = function() {
while(this.lastChild) {
this.removeChild(this.lastChild);
}
};
}
})();