PageSourceSearch

https://diyweek.net/ajaxpro/prototype.ashx

js diyweek.net collected 2026-09-24 23:01:14 UTC 3,766 bytes, 163 lines download raw bytes

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

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.