PageSourceSearch

https://www.alguer.it/inc/tab_panel/ajax.php

js alguer.it collected 2026-10-02 10:08:07 UTC 3,857 bytes, 134 lines download raw bytes

1
2/* Simple AJAX Code-Kit (SACK) */
3/* ©2005 Gregory Wild-Smith */
4/* www.twilightuniverse.com */
5/* Software licenced under a modified X11 licence, see documentation or authors website for more details */
6
7function sack(file){
8	this.AjaxFailedAlert = "Your browser does not support the enhanced functionality of this website, and therefore you will have an experience that differs from the intended one.\n";
9	this.requestFile = file;
10	this.method = "POST";
11	this.URLString = "";
12	this.encodeURIString = true;
13	this.execute = false;
14
15	this.onLoading = function() { };
16	this.onLoaded = function() { };
17	this.onInteractive = function() { };
18	this.onCompletion = function() { };
19
20	this.createAJAX = function() {
21		try {
22			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
23		} catch (e) {
24			try {
25				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
26			} catch (err) {
27				this.xmlhttp = null;
28			}
29		}
30		if(!this.xmlhttp && typeof XMLHttpRequest != "undefined")
31			this.xmlhttp = new XMLHttpRequest();
32		if (!this.xmlhttp){
33			this.failed = true; 
34		}
35	};
36	
37	this.setVar = function(name, value){
38		if (this.URLString.length < 3){
39			this.URLString = name + "=" + value;
40		} else {
41			this.URLString += "&" + name + "=" + value;
42		}
43	}
44	
45	this.encVar = function(name, value){
46		var varString = encodeURIComponent(name) + "=" + encodeURIComponent(value);
47	return varString;
48	}
49	
50	this.encodeURLString = function(string){
51		varArray = string.split('&');
52		for (i = 0; i < varArray.length; i++){
53			urlVars = varArray[i].split('=');
54			if (urlVars[0].indexOf('amp;') != -1){
55				urlVars[0] = urlVars[0].substring(4);
56			}
57			varArray[i] = this.encVar(urlVars[0],urlVars[1]);
58		}
59	return varArray.join('&');
60	}
61	
62	this.runResponse = function(){
63		eval(this.response);
64	}
65	
66	this.runAJAX = function(urlstring){
67		this.responseStatus = new Array(2);
68		if(this.failed && this.AjaxFailedAlert){ 
69			alert(this.AjaxFailedAlert); 
70		} else {
71			if (urlstring){ 
72				if (this.URLString.length){
73					this.URLString = this.URLString + "&" + urlstring; 
74				} else {
75					this.URLString = urlstring; 
76				}
77			}
78			if (this.encodeURIString){
79				var timeval = new Date().getTime(); 
80				this.URLString = this.encodeURLString(this.URLString);
81				this.setVar("rndval", timeval);
82			}
83			if (this.element) { this.elementObj = document.getElementById(this.element); }
84			if (this.xmlhttp) {
85				var self = this;
86				if (this.method == "GET") {
87					var totalurlstring = this.requestFile + "?" + this.URLString;
88					this.xmlhttp.open(this.method, totalurlstring, true);
89				} else {
90					this.xmlhttp.open(this.method, this.requestFile, true);
91				}
92				if (this.method == "POST"){
93  					try {
94						this.xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded')  
95					} catch (e) {}
96				}
97
98				this.xmlhttp.send(this.URLString);
99				this.xmlhttp.onreadystatechange = function() {
100					switch (self.xmlhttp.readyState){
101						case 1:
102							self.onLoading();
103						break;
104						case 2:
105							self.onLoaded();
106						break;
107						case 3:
108							self.onInteractive();
109						break;
110						case 4:
111							self.response = self.xmlhttp.responseText;
112							self.responseXML = self.xmlhttp.responseXML;
113							self.responseStatus[0] = self.xmlhttp.status;
114							self.responseStatus[1] = self.xmlhttp.statusText;
115							self.onCompletion();
116							if(self.execute){ self.runResponse(); }
117							if (self.elementObj) {
118								var elemNodeName = self.elementObj.nodeName;
119								elemNodeName.toLowerCase();
120								if (elemNodeName == "input" || elemNodeName == "select" || elemNodeName == "option" || elemNodeName == "textarea"){
121									self.elementObj.value = self.response;
122								} else {
123									self.elementObj.innerHTML = self.response;
124								}
125							}
126							self.URLString = "";
127						break;
128					}
129				};
130			}
131		}
132	};
133this.createAJAX();
134}

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.