1Object.extend = function(dest, source, replace) { 2 for(prop in source) { 3 if(replace == false && dest[prop] != null) continue; 4 dest[prop] = source[prop]; 5 } 6 return dest; 7} 8 9Object.extend(Function.prototype, { 10 apply: function(o, a) { 11 var r, x = "__fapply"; 12 if(typeof o != "object") o = {}; 13 o[x] = this; 14 var s = "r = o." + x + "("; 15 for(var i=0; i<a.length; i++) { 16 if(i>0) s += ","; 17 s += "a[" + i + "]"; 18 } 19 s += ");"; 20 eval(s); 21 delete o[x]; 22 return r; 23 }, 24 bind: function(o) { 25 if(!Function.__objs) { 26 Function.__objs = []; 27 Function.__funcs = []; 28 } 29 30 var objId = o.__oid; 31 if(!objId) 32 Function.__objs[objId = o.__oid = Function.__objs.length] = o; 33 34 var me = this; 35 var funcId = me.__fid; 36 if(!funcId) 37 Function.__funcs[funcId = me.__fid = Function.__funcs.length] = me; 38 39 if(!o.__closures) 40 o.__closures = []; 41 42 var closure = o.__closures[funcId]; 43 if(closure) 44 return closure; 45 46 o = null; 47 me = null; 48 49 return Function.__objs[objId].__closures[funcId] = function() { 50 return Function.__funcs[funcId].apply(Function.__objs[objId], arguments); 51 }; 52 } 53}, false); 54 55Object.extend(Array.prototype, { 56 push: function(o) { 57 this[this.length] = o; 58 }, 59 addRange: function(items) { 60 if(items.length > 0) 61 for(var i=0; i<items.length; i++) 62 this.push(items[i]); 63 }, 64 clear: function() { 65 this.length = 0; 66 return this; 67 }, 68 shift: function() { 69 if(this.length == 0) return null; 70 var o = this[0]; 71 for(var i=0; i<this.length-1; i++) 72 this[i] = this[i + 1]; 73 this.length--; 74 return o; 75 } 76}, false); 77 78Object.extend(String.prototype, { 79 trimLeft: function() { 80 return this.replace(/^\s*/,""); 81 }, 82 trimRight: function() { 83 return this.replace(/\s*$/,""); 84 }, 85 trim: function() { 86 return this.trimRight().trimLeft(); 87 }, 88 endsWith: function(s) { 89 if(this.length == 0 || this.length < s.length) return false; 90 return (this.substr(this.length - s.length) == s); 91 }, 92 startsWith: function(s) { 93 if(this.length == 0 || this.length < s.length) return false; 94 return (this.substr(0, s.length) == s); 95 }, 96 split: function(c) { 97 var a = []; 98 if(this.length == 0) return a; 99 var p = 0; 100 for(var i=0; i<this.length; i++) { 101 if(this.charAt(i) == c) { 102 a.push(this.substring(p, i)); 103 p = ++i; 104 } 105 } 106 a.push(s.substr(p)); 107 return a; 108 } 109}, false); 110 111Object.extend(String, { 112 format: function(s) { 113 for(var i=1; i<arguments.length; i++) 114 s = s.replace("{" + (i -1) + "}", arguments[i]); 115 return s; 116 }, 117 isNullOrEmpty: function(s) { 118 if(s == null || s.length == 0) 119 return true; 120 return false; 121 } 122}, false); 123 124if(typeof addEvent == "undefined") 125 addEvent = function(o, evType, f, capture) { 126 if(o == null) return false; 127 if(o.addEventListener) { 128 o.addEventListener(evType, f, capture); 129 return true; 130 } else if (o.attachEvent) { 131 var r = o.attachEvent("on" + evType, f); 132 return r; 133 } else { 134 try{ o["on" + evType] = f; }catch(e){} 135 } 136 }; 137 138if(typeof removeEvent == "undefined") 139 removeEvent = function(o, evType, f, capture) { 140 if(o == null) return false; 141 if(o.removeEventListener) { 142 o.removeEventListener(evType, f, capture); 143 return true; 144 } else if (o.detachEvent) { 145 o.detachEvent("on" + evType, f); 146 } else { 147 try{ o["on" + evType] = function(){}; }catch(e){} 148 } 149 };
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.