Edit File by line
/home/barbar84/public_h.../wp-inclu.../js
File: tw-sack.js
/* Simple AJAX Code-Kit (SACK) v1.6.1 */
[0] Fix | Delete
[1] Fix | Delete
/* www.twilightuniverse.com */
[2] Fix | Delete
/* Software licenced under a modified X11 licence,
[3] Fix | Delete
see documentation or authors website for more details */
[4] Fix | Delete
[5] Fix | Delete
function sack(file) {
[6] Fix | Delete
this.xmlhttp = null;
[7] Fix | Delete
[8] Fix | Delete
this.resetData = function() {
[9] Fix | Delete
this.method = "POST";
[10] Fix | Delete
this.queryStringSeparator = "?";
[11] Fix | Delete
this.argumentSeparator = "&";
[12] Fix | Delete
this.URLString = "";
[13] Fix | Delete
this.encodeURIString = true;
[14] Fix | Delete
this.execute = false;
[15] Fix | Delete
this.element = null;
[16] Fix | Delete
this.elementObj = null;
[17] Fix | Delete
this.requestFile = file;
[18] Fix | Delete
this.vars = new Object();
[19] Fix | Delete
this.responseStatus = new Array(2);
[20] Fix | Delete
};
[21] Fix | Delete
[22] Fix | Delete
this.resetFunctions = function() {
[23] Fix | Delete
this.onLoading = function() { };
[24] Fix | Delete
this.onLoaded = function() { };
[25] Fix | Delete
this.onInteractive = function() { };
[26] Fix | Delete
this.onCompletion = function() { };
[27] Fix | Delete
this.onError = function() { };
[28] Fix | Delete
this.onFail = function() { };
[29] Fix | Delete
};
[30] Fix | Delete
[31] Fix | Delete
this.reset = function() {
[32] Fix | Delete
this.resetFunctions();
[33] Fix | Delete
this.resetData();
[34] Fix | Delete
};
[35] Fix | Delete
[36] Fix | Delete
this.createAJAX = function() {
[37] Fix | Delete
try {
[38] Fix | Delete
this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
[39] Fix | Delete
} catch (e1) {
[40] Fix | Delete
try {
[41] Fix | Delete
this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
[42] Fix | Delete
} catch (e2) {
[43] Fix | Delete
this.xmlhttp = null;
[44] Fix | Delete
}
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
if (! this.xmlhttp) {
[48] Fix | Delete
if (typeof XMLHttpRequest != "undefined") {
[49] Fix | Delete
this.xmlhttp = new XMLHttpRequest();
[50] Fix | Delete
} else {
[51] Fix | Delete
this.failed = true;
[52] Fix | Delete
}
[53] Fix | Delete
}
[54] Fix | Delete
};
[55] Fix | Delete
[56] Fix | Delete
this.setVar = function(name, value){
[57] Fix | Delete
this.vars[name] = Array(value, false);
[58] Fix | Delete
};
[59] Fix | Delete
[60] Fix | Delete
this.encVar = function(name, value, returnvars) {
[61] Fix | Delete
if (true == returnvars) {
[62] Fix | Delete
return Array(encodeURIComponent(name), encodeURIComponent(value));
[63] Fix | Delete
} else {
[64] Fix | Delete
this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
[65] Fix | Delete
}
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
this.processURLString = function(string, encode) {
[69] Fix | Delete
encoded = encodeURIComponent(this.argumentSeparator);
[70] Fix | Delete
regexp = new RegExp(this.argumentSeparator + "|" + encoded);
[71] Fix | Delete
varArray = string.split(regexp);
[72] Fix | Delete
for (i = 0; i < varArray.length; i++){
[73] Fix | Delete
urlVars = varArray[i].split("=");
[74] Fix | Delete
if (true == encode){
[75] Fix | Delete
this.encVar(urlVars[0], urlVars[1]);
[76] Fix | Delete
} else {
[77] Fix | Delete
this.setVar(urlVars[0], urlVars[1]);
[78] Fix | Delete
}
[79] Fix | Delete
}
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
this.createURLString = function(urlstring) {
[83] Fix | Delete
if (this.encodeURIString && this.URLString.length) {
[84] Fix | Delete
this.processURLString(this.URLString, true);
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
if (urlstring) {
[88] Fix | Delete
if (this.URLString.length) {
[89] Fix | Delete
this.URLString += this.argumentSeparator + urlstring;
[90] Fix | Delete
} else {
[91] Fix | Delete
this.URLString = urlstring;
[92] Fix | Delete
}
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
// prevents caching of URLString
[96] Fix | Delete
this.setVar("rndval", new Date().getTime());
[97] Fix | Delete
[98] Fix | Delete
urlstringtemp = new Array();
[99] Fix | Delete
for (key in this.vars) {
[100] Fix | Delete
if (false == this.vars[key][1] && true == this.encodeURIString) {
[101] Fix | Delete
encoded = this.encVar(key, this.vars[key][0], true);
[102] Fix | Delete
delete this.vars[key];
[103] Fix | Delete
this.vars[encoded[0]] = Array(encoded[1], true);
[104] Fix | Delete
key = encoded[0];
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
[108] Fix | Delete
}
[109] Fix | Delete
if (urlstring){
[110] Fix | Delete
this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
[111] Fix | Delete
} else {
[112] Fix | Delete
this.URLString += urlstringtemp.join(this.argumentSeparator);
[113] Fix | Delete
}
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
this.runResponse = function() {
[117] Fix | Delete
eval(this.response);
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
this.runAJAX = function(urlstring) {
[121] Fix | Delete
if (this.failed) {
[122] Fix | Delete
this.onFail();
[123] Fix | Delete
} else {
[124] Fix | Delete
this.createURLString(urlstring);
[125] Fix | Delete
if (this.element) {
[126] Fix | Delete
this.elementObj = document.getElementById(this.element);
[127] Fix | Delete
}
[128] Fix | Delete
if (this.xmlhttp) {
[129] Fix | Delete
var self = this;
[130] Fix | Delete
if (this.method == "GET") {
[131] Fix | Delete
totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
[132] Fix | Delete
this.xmlhttp.open(this.method, totalurlstring, true);
[133] Fix | Delete
} else {
[134] Fix | Delete
this.xmlhttp.open(this.method, this.requestFile, true);
[135] Fix | Delete
try {
[136] Fix | Delete
this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
[137] Fix | Delete
} catch (e) { }
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
this.xmlhttp.onreadystatechange = function() {
[141] Fix | Delete
switch (self.xmlhttp.readyState) {
[142] Fix | Delete
case 1:
[143] Fix | Delete
self.onLoading();
[144] Fix | Delete
break;
[145] Fix | Delete
case 2:
[146] Fix | Delete
self.onLoaded();
[147] Fix | Delete
break;
[148] Fix | Delete
case 3:
[149] Fix | Delete
self.onInteractive();
[150] Fix | Delete
break;
[151] Fix | Delete
case 4:
[152] Fix | Delete
self.response = self.xmlhttp.responseText;
[153] Fix | Delete
self.responseXML = self.xmlhttp.responseXML;
[154] Fix | Delete
self.responseStatus[0] = self.xmlhttp.status;
[155] Fix | Delete
self.responseStatus[1] = self.xmlhttp.statusText;
[156] Fix | Delete
[157] Fix | Delete
if (self.execute) {
[158] Fix | Delete
self.runResponse();
[159] Fix | Delete
}
[160] Fix | Delete
[161] Fix | Delete
if (self.elementObj) {
[162] Fix | Delete
elemNodeName = self.elementObj.nodeName;
[163] Fix | Delete
elemNodeName.toLowerCase();
[164] Fix | Delete
if (elemNodeName == "input"
[165] Fix | Delete
|| elemNodeName == "select"
[166] Fix | Delete
|| elemNodeName == "option"
[167] Fix | Delete
|| elemNodeName == "textarea") {
[168] Fix | Delete
self.elementObj.value = self.response;
[169] Fix | Delete
} else {
[170] Fix | Delete
self.elementObj.innerHTML = self.response;
[171] Fix | Delete
}
[172] Fix | Delete
}
[173] Fix | Delete
if (self.responseStatus[0] == "200") {
[174] Fix | Delete
self.onCompletion();
[175] Fix | Delete
} else {
[176] Fix | Delete
self.onError();
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
self.URLString = "";
[180] Fix | Delete
break;
[181] Fix | Delete
}
[182] Fix | Delete
};
[183] Fix | Delete
[184] Fix | Delete
this.xmlhttp.send(this.URLString);
[185] Fix | Delete
}
[186] Fix | Delete
}
[187] Fix | Delete
};
[188] Fix | Delete
[189] Fix | Delete
this.reset();
[190] Fix | Delete
this.createAJAX();
[191] Fix | Delete
}
[192] Fix | Delete
[193] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function