PageSourceSearch

http://beichuan-machine.com/include/dedeajax2.js

js beichuan-machine.com collected 2026-10-06 13:16:30 UTC 6,684 bytes, 278 lines download raw bytes

1<!--
2//xmlhttp和xmldom对象
3var DedeXHTTP = null;
4var DedeXDOM = null;
5var DedeContainer = null;
6var DedeShowError = false;
7var DedeShowWait = false;
8var DedeErrCon = "";
9var DedeErrDisplay = "下载数据失败";
10var DedeWaitDisplay = "正在下载数据...";
11
12//获取指定ID的元素
13
14function $DE(id) {
15	return document.getElementById(id);
16}
17
18//gcontainer 是保存下载完成的内容的容器
19//mShowError 是否提示错误信息
20//DedeShowWait 是否提示等待信息
21//mErrCon 服务器返回什么字符串视为错误
22//mErrDisplay 发生错误时显示的信息
23//mWaitDisplay 等待时提示信息
24//默认调用 DedeAjax('divid',false,false,'','','')
25
26function DedeAjax(gcontainer,mShowError,mShowWait,mErrCon,mErrDisplay,mWaitDisplay)
27{
28
29	DedeContainer = gcontainer;
30	DedeShowError = mShowError;
31	DedeShowWait = mShowWait;
32	if(mErrCon!="") DedeErrCon = mErrCon;
33	if(mErrDisplay!="") DedeErrDisplay = mErrDisplay;
34	if(mErrDisplay=="x") DedeErrDisplay = "";
35	if(mWaitDisplay!="") DedeWaitDisplay = mWaitDisplay;
36
37
38	//post或get发送数据的键值对
39	this.keys = Array();
40	this.values = Array();
41	this.keyCount = -1;
42
43	//http请求头
44	this.rkeys = Array();
45	this.rvalues = Array();
46	this.rkeyCount = -1;
47
48	//请求头类型
49	this.rtype = 'text';
50
51	//初始化xmlhttp
52	//IE6、IE5
53	if(window.ActiveXObject) {
54		try { DedeXHTTP = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) { }
55		if (DedeXHTTP == null) try { DedeXHTTP = new ActiveXObject("Microsoft.XMLHTTP");} catch (e) { }
56	}
57	else {
58		DedeXHTTP = new XMLHttpRequest();
59	}
60
61	//增加一个POST或GET键值对
62	this.AddKey = function(skey,svalue) {
63		this.keyCount++;
64		this.keys[this.keyCount] = skey;
65		svalue = svalue.replace(/\+/g,'$#$');
66		this.values[this.keyCount] = escape(svalue);
67	};
68
69	//增加一个POST或GET键值对
70	this.AddKeyUtf8 = function(skey,svalue) {
71		this.keyCount++;
72		this.keys[this.keyCount] = skey;
73		svalue = svalue.replace(/\+/g,'$#$');
74		this.values[this.keyCount] = encodeURI(svalue);
75	};
76
77	//增加一个Http请求头键值对
78	this.AddHead = function(skey,svalue) {
79		this.rkeyCount++;
80		this.rkeys[this.rkeyCount] = skey;
81		this.rvalues[this.rkeyCount] = svalue;
82	};
83
84	//清除当前对象的哈希表参数
85	this.ClearSet = function() {
86		this.keyCount = -1;
87		this.keys = Array();
88		this.values = Array();
89		this.rkeyCount = -1;
90		this.rkeys = Array();
91		this.rvalues = Array();
92	};
93
94
95	DedeXHTTP.onreadystatechange = function() {
96		//在IE6中不管阻断或异步模式都会执行这个事件的
97		if(DedeXHTTP.readyState == 4){
98			if(DedeXHTTP.status == 200)
99			{
100				if(DedeXHTTP.responseText!=DedeErrCon) {
101					DedeContainer.innerHTML = DedeXHTTP.responseText;
102				}
103				else {
104					if(DedeShowError) DedeContainer.innerHTML = DedeErrDisplay;
105				}
106				DedeXHTTP = null;
107			}
108			else { if(DedeShowError) DedeContainer.innerHTML = DedeErrDisplay; }
109		}
110		else { if(DedeShowWait) DedeContainer.innerHTML = DedeWaitDisplay; }
111	};
112
113	//检测阻断模式的状态
114	this.BarrageStat = function() {
115		if(DedeXHTTP==null) return;
116		if(typeof(DedeXHTTP.status)!=undefined && DedeXHTTP.status == 200)
117		{
118			if(DedeXHTTP.responseText!=DedeErrCon) {
119				DedeContainer.innerHTML = DedeXHTTP.responseText;
120			}
121			else {
122				if(DedeShowError) DedeContainer.innerHTML = DedeErrDisplay;
123			}
124		}
125	};
126
127	//发送http请求头
128	this.SendHead = function()
129	{
130		if(this.rkeyCount!=-1)
131		{ 
132			for(;i<=this.rkeyCount;i++)
133			{
134				DedeXHTTP.setRequestHeader(this.rkeys[i],this.rvalues[i]);
135			}
136		}
137		if(this.rtype=='binary') {
138			DedeXHTTP.setRequestHeader("Content-Type","multipart/form-data");
139		}
140		else {
141			DedeXHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
142		}
143};
144
145//用Post方式发送数据
146this.SendPost = function(purl) {
147	var pdata = "";
148	var i=0;
149	this.state = 0;
150	DedeXHTTP.open("POST", purl, true);
151	this.SendHead();
152	//post数据
153	if(this.keyCount!=-1)
154	{
155		for(;i<=this.keyCount;i++)
156		{
157			if(pdata=="") pdata = this.keys[i]+'='+this.values[i];
158			else pdata += "&"+this.keys[i]+'='+this.values[i];
159		}
160	}
161	DedeXHTTP.send(pdata);
162};
163
164//用GET方式发送数据
165this.SendGet = function(purl) {
166	var gkey = "";
167	var i=0;
168	this.state = 0;
169	//get参数
170	if(this.keyCount!=-1)
171	{ 
172		for(;i<=this.keyCount;i++)
173		{
174			if(gkey=="") gkey = this.keys[i]+'='+this.values[i];
175			else gkey += "&"+this.keys[i]+'='+this.values[i];
176		}
177		if(purl.indexOf('?')==-1) purl = purl + '?' + gkey;
178		else  purl = purl + '&' + gkey;
179	}
180	DedeXHTTP.open("GET", purl, true);
181	this.SendHead();
182	DedeXHTTP.send(null);
183};
184
185//用GET方式发送数据,阻塞模式
186this.SendGet2 = function(purl) {
187	var gkey = "";
188	var i=0;
189	this.state = 0;
190	//get参数
191	if(this.keyCount!=-1)
192	{ 
193		for(;i<=this.keyCount;i++)
194		{
195			if(gkey=="") gkey = this.keys[i]+'='+this.values[i];
196			else gkey += "&"+this.keys[i]+'='+this.values[i];
197		}
198		if(purl.indexOf('?')==-1) purl = purl + '?' + gkey;
199		else  purl = purl + '&' + gkey;
200	}
201	DedeXHTTP.open("GET", purl, false);
202	this.SendHead();
203	DedeXHTTP.send(null);
204	//firefox中直接检测XHTTP状态
205	this.BarrageStat();
206};
207
208//用Post方式发送数据
209this.SendPost2 = function(purl) {
210	var pdata = "";
211	var i=0;
212	this.state = 0;
213	DedeXHTTP.open("POST", purl, false);
214	this.SendHead();
215	//post数据
216	if(this.keyCount!=-1)
217	{
218		for(;i<=this.keyCount;i++)
219		{
220			if(pdata=="") pdata = this.keys[i]+'='+this.values[i];
221			else pdata += "&"+this.keys[i]+'='+this.values[i];
222		}
223	}
224	DedeXHTTP.send(pdata);
225	//firefox中直接检测XHTTP状态
226	this.BarrageStat();
227};
228
229
230} // End Class DedeAjax
231
232//初始化xmldom
233function InitXDom() {
234	if(DedeXDOM!=null) return;
235	var obj = null;
236	// Gecko、Mozilla、Firefox
237	if (typeof(DOMParser) != "undefined") { 
238		var parser = new DOMParser();
239		obj = parser.parseFromString(xmlText, "text/xml");
240	}
241	// IE
242	else { 
243		try { obj = new ActiveXObject("MSXML2.DOMDocument");} catch (e) { }
244		if (obj == null) try { obj = new ActiveXObject("Microsoft.XMLDOM"); } catch (e) { }
245	}
246	DedeXDOM = obj;
247};
248
249
250
251//读写cookie函数
252function GetCookie(c_name)
253{
254	if (document.cookie.length > 0)
255	{
256		c_start = document.cookie.indexOf(c_name + "=")
257		if (c_start != -1)
258		{
259			c_start = c_start + c_name.length + 1;
260			c_end   = document.cookie.indexOf(";",c_start);
261			if (c_end == -1)
262			{
263				c_end = document.cookie.length;
264			}
265			return unescape(document.cookie.substring(c_start,c_end));
266		}
267	}
268	return null
269}
270
271function SetCookie(c_name,value,expiredays)
272{
273	var exdate = new Date();
274	exdate.setDate(exdate.getDate() + expiredays);
275	document.cookie = c_name + "=" +escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString()); //使设置的有效时间正确。增加toGMTString()
276}
277
278-->

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.