core_002 -...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Function.prototype.addMethod=function(a,b){if(! this.prototype[a])this.prototype[a]=b;return this};Function.addMethod("as",function(e,f){var b=e?e.split("."): [];if(b.length>0){var a=window;for(var d=0;d<b.length-1;++d){var c=b[d];if(c) {if(!a[c])a[c]={};a=a[c]}}a[b.last()]=f?new this:this}return this});Function.addMethod("ns",function(a) {this.as(a,1)});String.addMethod("trim",function(){return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/,"$1")});String.addMethod("collapse",functi on(){return this.replace(/\s+/g," ").trim()});String.addMethod("wrap",function(a){var b,c={"(":")","{":"}","[":"]","<":">","\u00c2\u00ab":"\u00c2\u00bb","\u00e2\u20ac \u00b9":"\u00e2\u20ac\u00ba","\u00e2\u20ac\u0153":"\u00e2\u20ac\u009d","\u00e2\u 20ac\u02dc":"\u00e2\u20ac\u2122"};if(c[a])b=c[a];else{var d=/^<(\w+) (\s+\w+\s*=\s*"[^"]*")*\s*>$/.exec(a);if(d)b="</"+d[1]+">"}return a+this+(b? b:a)});String.addMethod("format",function(){var b=this;for(var a=0;a<arguments.length;++a)b=b.replace(new RegExp("\\ {"+a+"\\}","g"),arguments[a]);return b});String.addMethod("encodeHtml",function(){var a=this.replace(/\>/g,">").replace(/\</g,"<").replace(/\&/g,"&").replac e(/\'/g,"&#039;").replace(/\"/g,"&quot;");return a});String.addMethod("decodeHtml",function(){var &#039;/g,"'").replace(/&quot;/g,'"');return a});String.addMethod("encodeURIComponent",function(){return typeof encodeURIComponent!="undefined"? encodeURIComponent(this):escape(this)});String.addMethod("decodeURIComponent",fu nction(){return typeof decodeURIComponent!="undefined"? decodeURIComponent(this):unescape(this)});Array.addMethod("last",function() {return this.length>0?this[this.length-1]:void 0});Array.addMethod("remove",function(b){for(var a=this.length-1;a>=0;-- a)if(this[a]===b)this.splice(a,1);return this});Array.addMethod("contains",function(b){for(var a=0;a<this.length;+ +a)if(this[a]===b)return 1;return 0});Array.addMethod("push",function(a) {this[this.length]=a;return this.length});Array.addMethod("shift",function() {return this.splice(0,1)[0]});Array.addMethod("splice",function(c,d){var b,e=arguments.length- 2;if(c>this.length)c=this.length;if(c+d>this.length)d=this.length-c;var f=[];for(var a=0;a<d;++a)f.push(this[c+a]);if(e>d){b=e-d;for(a=this.length+b- 1;a>=c+b;--a)this[a]=this[a-b]}else if(e<d){b=d-e;for(a=c+e;a<this.length-b;+ +a)this[a]=this[a+b];for(;a<this.length-1;++a)delete this[a];this.length- =b}for(a=0;a<e;++a)this[c+a]=arguments[2+a];return f});(function(){var a=this;Function.addMethod("hook",function(d,e){if(d){var f=b();if(! f&d.addEventListener)d.addEventListener(e,this,false);else if(! f&&d.attachEvent)d.attachEvent("on"+e,this);else{var c=d["x"+e];if(c&&c.constructor==Array)if(c.contains(this))c=null;else c.push(this);else c=d["x"+e]=[this];if(c){d["on"+e]=function(d){var f=true;d=a.Event(d);for(var b=0;b<c.length;++b){var e=c[b](d);if(typeof e! ="undefined"&&!e)f=false}return f};d=null}}}return
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 10/29/2011 for the course MNGT 350C at Jackson State.

Page1 / 4

core_002 -...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online