repoindex/web/js/proto.js

44 lines
986 B
JavaScript

(function() {
// let's add some "evil" prototype definitions
if(!String.prototype.contains) {
String.prototype.contains = function(substr) {
return this.indexOf(substr) !== -1;
};
}
if(!Array.prototype.contains) {
Array.prototype.contains = function(element) {
return this.indexOf(element) !== -1;
};
}
if(!Array.prototype.last) {
Array.prototype.last = function() {
return this[this.length - 1];
};
}
if(!Array.prototype.first) {
Array.prototype.first = function() {
return this[0];
};
}
if(!Array.prototype.second) {
Array.prototype.second = function() {
return this[1];
};
}
if(!Node.prototype.wipeChildren) {
Node.prototype.wipeChildren = function() {
while(this.lastChild) {
this.removeChild(this.lastChild);
}
};
}
})();