PageSourceSearch

https://s61m.com/js/pw_ajax.js

js s61m.com collected 2026-10-06 13:14:15 UTC 12,569 bytes, 446 lines download raw bytes

1
2function AjaxObj() {
3	this.responseText = null;
4	var s = document.createElement('div');
5	s.style.display = 'none';
6	var n = 'iframe' + new Date().getTime();
7	s.innerHTML = '<iframe src="about:blank" id="' + n + '" name="' + n + '"></iframe>';
8	var bd=document.body;
9	bd.insertBefore(s,bd.firstChild);
10	this.iframe = s.firstChild;
11
12	this.post = function(url,data) {
13		if (typeof data == 'string' && data != '') {
14			var f = document.createElement('form');
15			f.name	 = 'ajaxform';
16			f.target = n;
17			f.method = 'post';
18			f.action = url;
19			var ds = data.split("&");
20			for (var i = 0; i < ds.length; i++) {
21				if (ds[i]) {
22					var v	 = ds[i];
23					var el	 = document.createElement('input');
24					el.type  = 'hidden';
25					el.name  = v.substr(0,v.indexOf('='));
26					el.value = v.substr(v.indexOf('=')+1);
27					f.appendChild(el);
28				}
29			}
30			document.body.insertBefore(f,document.body.childNodes[0]);
31			f.submit();
32			document.body.removeChild(f);
33			
34		} else if (typeof data == 'object') {
35			var s = data.getAttribute('action');
36			if (typeof s == 'object') {
37				var p = s.parentNode;
38				p.removeChild(s);
39				data.setAttribute('action', url);
40				p.appendChild(s);
41			} else {
42				data.setAttribute('action', url);
43			}
44			data.target = n;
45			data.submit();
46		} else {
47			self.frames&&self.frames[n].location.replace(url);//ÈÃiframeûÓÐä¯ÀÀÀúÊ·
48			//this.iframe.src=url;
49		}
50	}
51	this.clearhistroy = function() {
52		self.frames&&self.frames[n].location.replace('about:blank');
53	}
54}
55function XMLhttp() {
56	this.request = null;
57	this.recall	 = null;
58	this.time    = null;
59	this.t       = null;
60	this.sArray  = new Array();
61	this.last	 = 0;
62}
63
64XMLhttp.prototype = {
65
66	send : function(url,data,callback) {
67		if (this.request == null) {
68			this.request = new AjaxObj();
69		}
70		this.request.responseText = '';
71
72		var nowtime	= new Date().getTime();
73		if (nowtime - this.last < 1500) {
74			clearTimeout(this.t);
75			this.t = setTimeout(function(){ajax.send(url,data,callback)},1500+this.last-nowtime);
76			return;
77		}
78		this.last = nowtime;
79		url	+= (url.indexOf("?") >= 0) ? "&nowtime=" + nowtime : "?nowtime=" + nowtime;
80		if (typeof verifyhash != 'undefined') {
81			url += '&verify=' + verifyhash;
82		}
83		this.request.post(url,data);
84		this.recall = callback;
85		if (typeof this.recall == "function") {
86			if (this.request.iframe.attachEvent) {
87				this.request.iframe.detachEvent('onload',ajax.load);
88				this.request.iframe.attachEvent('onload',ajax.load);
89			} else {
90				this.request.iframe.addEventListener('load',ajax.load,true);
91			}
92		}
93	},
94
95	load : function() {
96		if(!ajax.request.iframe.contentWindow){
97			return false;
98		}
99		var _innerText=ajax.request.iframe.contentWindow.document.documentElement.innerText;
100		var _textContent=ajax.request.iframe.contentWindow.document.documentElement.textContent;
101		if(_innerText==undefined&&_textContent==undefined){
102			return false;
103		}
104		if(-[1,]){
105				ajax.request.responseText=_textContent;
106		}else{
107				var rules = /<!\[CDATA\[([\s\S]+)\]\]>/.exec(_innerText);
108				if(rules && rules[1]){
109					ajax.request.responseText=rules[1].replace(/^\s+|\s+$/g,'');
110				}else{
111					var xmlDoc=ajax.request.iframe.contentWindow.document.XMLDocument;
112					if(xmlDoc){
113						ajax.request.responseText=xmlDoc.text;
114					}else{
115						ajax.request.responseText=_innerText;
116					}
117				}
118		}
119		
120		if (ajax.request.iframe.detachEvent) {
121			ajax.request.iframe.detachEvent('onload',ajax.load);
122		} else {
123			ajax.request.iframe.removeEventListener('load',ajax.load,true);
124		}
125		//try{if (ajax.request.iframe.location.href == 'about:blank'){return '';}}catch(e){}
126		if (typeof(ajax.recall) == 'function') {
127			ajax.recall();
128			ajax.doscript();
129		}
130		//fixed for tt browser (register page)
131		if (typeof ajaxclearhistory == 'undefined')ajax.request.clearhistroy();
132	},
133
134	XmlDocument : function(obj) {
135		return (!-[1,]) ? ajax.request.iframe.contentWindow.document.XMLDocument : ajax.request.iframe.contentWindow.document;
136	},
137
138	submit : function(obj,recall) {
139		if (typeof recall == 'undefined' || typeof recall != 'function') {
140			recall = ajax.guide;
141		}
142		ajax.send(obj.getAttribute('action'), obj, recall);
143		closep();
144	},
145
146	get : function(newread,border,cb,focus) {
147		var temp = newread ? newread : read;
148		var no_run_script = false;
149		if (ajax.request.responseText.indexOf('NO_RUN_SCRIPT') == 0){
150			ajax.request.responseText = ajax.request.responseText.substring(13);
151			no_run_script = true;
152		}
153		if (ajax.request.responseText != null && ajax.request.responseText.indexOf('<') != -1 && !no_run_script) {
154			temp.setMenu(this.runscript(ajax.request.responseText), '', border);
155			temp.menupz(temp.obj);
156			if(cb){
157				cb();
158			}
159			//¾Û½¹
160			if(focus){
161				try{
162				var inputs=temp.menu.getElementsByTagName("input");
163				for(var i=0,len=inputs.length;i<len;i++){
164					var _input=inputs[i];
165					if(_input.type=="text" && !_input.disabled && _input.style.display != 'none'){
166						setTimeout(function(){
167							_input.focus();
168						},100)
169						return;
170					}
171				}
172				}catch(e){}
173			}
174		} else {
175			closep();
176			ajax.guide();
177		}
178		
179	},
180
181	runscript : function (html) {
182		if (html.indexOf('<script') == -1) return html;
183		var _=this;
184		html = html.replace(/<script(.*?)>([^\x00]*?)<\/script>/ig, function($1, $2, $3) {
185			_.sArray.push({'attribute' : $2, 'code' : $3});
186			return '';
187		});
188		return html;
189	},
190
191	doscript : function() {
192		for (var i = 0; i < this.sArray.length; i++) {
193			var id = path = code = '';
194			if (this.sArray[i]['attribute'].match(/\s*id\="([\w\_]+?)"/i)) {
195				id = RegExp.$1;
196			}
197			if (this.sArray[i]['attribute'].match(/\s*src\="(.+?)"/i)) {
198				path = RegExp.$1;
199			} else {
200				code = this.sArray[i]['code'];
201			}
202			loadjs(path, code, id);
203		}
204		this.sArray = new Array();
205	},
206	
207	showError : function(message,time){
208		var control = document.getElementById('pw_box'),
209			popout = getElementsByClassName('popout',control)[0],
210			msgBoxs = getElementsByClassName('wrongTip',popout),
211			box = msgBoxs.length ? msgBoxs[0] : null;
212			popBottom = getElementsByClassName('popBottom',control);
213			if(!box) {	
214				
215				box = document.createElement('div');
216				box.className = 'wrongTip';
217				box.innerHTML = message;
218				popBottom[0].parentNode.insertBefore(box,popBottom[0]);
219			}
220			box.style.display = '';
221			box.innerHTML = message;
222			if(time == undefined) time = 3;	
223			clearTimeout(this.showTime);
224			this.showTime = setTimeout(function(){box.style.display = 'none';},time * 1000);
225			return false;
226	},
227
228	guide : function(callback) {
229		if (ajax.request.responseText == null) {
230			ajax.request.responseText = 'ÄúÇëÇóµÄÒ³Ãæ³ö´íÀ²!';
231		}
232		var rText = ajax.request.responseText.split('\t');
233
234		/*Ö÷ÌâÓ¡´Á*/
235		if(operateOverPrint(rText)){
236			return false;
237		}
238		if (rText[1] != 'nextto') {
239			showDialog('', rText[0], 2, callback ? callback : null);
240		}
241		if (typeof(rText[1]) != 'undefined' && in_array(rText[1],['jump','nextto','reload'])) {
242			if (rText[1] == 'jump') {
243				setTimeout("window.location.href='"+rText[2]+"';",200);
244			} else if (rText[1] == 'nextto') {
245				sendmsg(rText[2],rText[3],rText[4]);
246			} else if (rText[1] == 'reload') {
247				setTimeout("window.location.reload();",2000);
248			}
249		}
250	},
251
252	clear : function() {
253		if (IsElement('ajax_guide')) document.body.removeChild(getObj('ajax_guide'));
254	},
255
256	convert : function(str) {
257		if (typeof(str)=='string') {
258			return str.replace(/\&/g,'%26');
259		}
260		return str;
261	},
262
263	quickpost : function(event,obj) {
264		if ((event.ctrlKey && event.keyCode == 13) || (event.altKey && event.keyCode == 83)) {
265			try{obj.ajaxsubmit.click();}catch(e){}
266		}
267	}
268}
269
270var ajax = new XMLhttp();
271function sendmsg(url,data,id,callback) {//callback 07-05À©Õ¹,ÓÃÀ´Ö´ÐÐhtmlÉú³ÉÖ®ºóµÄ»Øµ÷,²»Ó°Ïì֮ǰ´úÂë
272	var e=getEvent();
273	if(e.preventDefault){
274		e.preventDefault();
275	}else{
276		e.returnValue=false;
277	}
278	read.obj = (!!id&&typeof id === 'string') ? getObj(id) :(typeof id=="object")?id:null;
279	read.guide();
280	setTimeout(function(){ajax.send(url,data,function(){
281		ajax.get();
282		callback && callback();
283	});},100);
284}
285function objCheck(obj) {
286	if (typeof(obj)=='string') {
287		obj	= getObj(obj);
288	}
289	return obj;
290}
291
292function setCurrent(src,dst,css) {
293	var o = null;
294	if (IsElement(src)) {
295		o = getObj(src);
296	} else if (dst && IsElement(dst)) {
297		o = getObj(dst);
298	}
299	if (o) o.className += ' ' + css;
300}
301
302function strlen(str){
303	var len = 0;
304	var s_len = str.length = (is_ie && str.indexOf('\n')!=-1) ? str.replace(/\r?\n/g, '_').length : str.length;
305	window.charset?0:charset="";
306	var c_len = charset == 'utf-8' ? 3 : 2;
307	for(var i=0;i<s_len;i++){
308		len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? c_len : 1;
309	}
310	return len;
311}
312
313function substr(str, len) {
314	if(!str || !len) {
315		return '';
316	}
317	var a = 0;
318	var i = 0;
319	var temp = '';
320	var c_len = charset == 'utf-8' ? 3 : 2;
321	for (i=0;i<str.length;i++) {
322		if (str.charCodeAt(i)>255) {
323			a+=c_len;
324		} else {
325			a++;
326		}
327		if(a > len) {
328			return temp;
329		}
330		temp += str.charAt(i);
331	}
332	return str;
333}
334
335function initCheckTextNum(textareaid,warnid,num,nodisplay) {
336	var textareaobj = getObj(textareaid);
337	var nodisplay = nodisplay ? false : true;/* if choose true the limit nums will not display else will display*/
338	try{if (document.addEventListener) {
339		textareaobj.addEventListener("input",function(){checkTextNum(textareaobj,warnid,num,nodisplay);},false);
340	} else if (document.attachEvent){
341		textareaobj.attachEvent("onpropertychange",function(){checkTextNum(textareaobj,warnid,num,nodisplay);});
342	}}catch(e){}
343}
344
345function checkTextNum(textareaid,warnid,num,nodisplay) {
346
347	if (typeof(textareaid) == 'string') {
348		var textareaobj = getObj(textareaid);
349	} else {
350		var textareaobj = textareaid;
351	}
352	var str_length = strlen(textareaobj.value);
353	if (!objCheck(getObj(warnid))) {
354		return false;
355	}
356	var warn = getObj(warnid);
357	if (str_length > num) {
358		warn.style.display = '';
359		warn.style.color = '';
360		warn.innerHTML = 'Òѳ¬³ö'+(str_length-num)+'×Ö½Ú';
361	} else {
362		if(nodisplay){
363			warn.style.display = '';
364			warn.innerHTML = 'Ê£Óà'+(num-str_length)+'×Ö½Ú';
365		}else if(warn.style.display == ''){
366			warn.style.display = 'none';
367		}
368	}
369}
370function SetCookie(name,value) {
371	expires = new Date();
372	expires.setTime(expires.getTime()+(86400*365*1000));
373	document.cookie=name+"="+escape(value)+"; expires="+expires.toGMTString()+"; path=/";
374}
375
376function FetchCookie(name) {
377	var start = document.cookie.indexOf(name);
378	var end = document.cookie.indexOf(";",start);
379	return start==-1 ? null : unescape(document.cookie.substring(start+name.length+1,(end>start ? end : document.cookie.length)));
380}
381
382function showOverPrint(obj,isMulti){
383	var url = obj.getAttribute("url");
384	if (!isMulti) {
385		sendmsg(url,'',obj.id);
386		return false;
387	}
388	var overprintTids = getObj('overprinttids').value;
389	sendmsg(url,'tidarray=' + overprintTids,obj.id);
390	return false;
391}
392
393function operateOverPrint(text){
394	/*Ö÷ÌâÓ¡´Á*/
395	if (typeof(text[1]) != 'undefined' && in_array(text[1],['overprint'])) {
396		var overprint = getObj("read_overprint");
397		if(overprint && typeof(text[2]) != 'undefined'){
398			var img = overprint.getElementsByTagName("img")[0];
399			if(!img){
400				img = document.createElement("img");
401				img.src = text[2];
402				overprint.appendChild(img);
403			}else{
404				img.src = text[2];/*ͼ±êÇл»*/
405			}
406			if(text[2] == ""){
407				overprint.removeChild(img);
408			}
409		}
410		/*ÊÇ·ñ´æÔÚºóÐø²Ù×÷*/
411		if(typeof(text[3]) == 'undefined'){
412			showDialog('',text[0],2);
413		}
414		if(typeof(text[3]) != 'undefined' && text[3] == "nextto"){
415			sendmsg(text[4],text[5],text[6]);
416		}
417		return true;;
418	}else{
419		return false;
420	}
421}
422function showViewLog(url,data,id){
423	read.obj = (typeof id == 'undefined' || !id) ? null : getObj(id);
424	read.guide();
425	setTimeout(function(){ajax.send(url,data,function(){
426		ajax.get();
427		document.body.onmousedown = function(event){
428			closep();
429			document.body.onmousedown = function(){};
430		}
431		var box = getObj("pw_box");
432		if(box){
433			box.onmousedown = function(evt){
434				if(evt){
435		    		evt.stopPropagation();
436		    	}else{
437		    		event.cancelBubble = true;
438		    	}
439			}
440		}
441	});},100);
442}
443function uploadFile(ajaxForm,callback)
444{
445	ajax.send(url, ajaxForm.cloneNode(true), callback);
446}

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.