Wordpress/wp-includes/js/tw-sack.compressed.js

1 line
3.4 KiB
JavaScript

function sack(_1){this.xmlhttp=null;this.resetData=function(){this.method="POST";this.queryStringSeparator="?";this.argumentSeparator="&";this.URLString="";this.encodeURIString=true;this.execute=false;this.element=null;this.elementObj=null;this.requestFile=_1;this.vars=new Object();this.responseStatus=new Array(2);};this.resetFunctions=function(){this.onLoading=function(){};this.onLoaded=function(){};this.onInteractive=function(){};this.onCompletion=function(){};this.onError=function(){};this.onFail=function(){};};this.reset=function(){this.resetFunctions();this.resetData();};this.createAJAX=function(){try{this.xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");}catch(e1){try{this.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}catch(e2){this.xmlhttp=null;}}if(!this.xmlhttp){if(typeof XMLHttpRequest!="undefined"){this.xmlhttp=new XMLHttpRequest();}else{this.failed=true;}}};this.setVar=function(_2,_3){this.vars[_2]=Array(_3,false);};this.encVar=function(_4,_5,_6){if(true==_6){return Array(encodeURIComponent(_4),encodeURIComponent(_5));}else{this.vars[encodeURIComponent(_4)]=Array(encodeURIComponent(_5),true);}};this.processURLString=function(_7,_8){encoded=encodeURIComponent(this.argumentSeparator);regexp=new RegExp(this.argumentSeparator+"|"+encoded);varArray=_7.split(regexp);for(i=0;i<varArray.length;i++){urlVars=varArray[i].split("=");if(true==_8){this.encVar(urlVars[0],urlVars[1]);}else{this.setVar(urlVars[0],urlVars[1]);}}};this.createURLString=function(_9){if(this.encodeURIString&&this.URLString.length){this.processURLString(this.URLString,true);}if(_9){if(this.URLString.length){this.URLString+=this.argumentSeparator+_9;}else{this.URLString=_9;}}this.setVar("rndval",new Date().getTime());urlstringtemp=new Array();for(key in this.vars){if(false==this.vars[key][1]&&true==this.encodeURIString){encoded=this.encVar(key,this.vars[key][0],true);delete this.vars[key];this.vars[encoded[0]]=Array(encoded[1],true);key=encoded[0];}urlstringtemp[urlstringtemp.length]=key+"="+this.vars[key][0];}if(_9){this.URLString+=this.argumentSeparator+urlstringtemp.join(this.argumentSeparator);}else{this.URLString+=urlstringtemp.join(this.argumentSeparator);}};this.runResponse=function(){eval(this.response);};this.runAJAX=function(_a){if(this.failed){this.onFail();}else{this.createURLString(_a);if(this.element){this.elementObj=document.getElementById(this.element);}if(this.xmlhttp){var _b=this;if(this.method=="GET"){totalurlstring=this.requestFile+this.queryStringSeparator+this.URLString;this.xmlhttp.open(this.method,totalurlstring,true);}else{this.xmlhttp.open(this.method,this.requestFile,true);try{this.xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");}catch(e){}}this.xmlhttp.onreadystatechange=function(){switch(_b.xmlhttp.readyState){case 1:_b.onLoading();break;case 2:_b.onLoaded();break;case 3:_b.onInteractive();break;case 4:_b.response=_b.xmlhttp.responseText;_b.responseXML=_b.xmlhttp.responseXML;_b.responseStatus[0]=_b.xmlhttp.status;_b.responseStatus[1]=_b.xmlhttp.statusText;if(_b.execute){_b.runResponse();}if(_b.elementObj){elemNodeName=_b.elementObj.nodeName;elemNodeName.toLowerCase();if(elemNodeName=="input"||elemNodeName=="select"||elemNodeName=="option"||elemNodeName=="textarea"){_b.elementObj.value=_b.response;}else{_b.elementObj.innerHTML=_b.response;}}if(_b.responseStatus[0]=="200"){_b.onCompletion();}else{_b.onError();}_b.URLString="";break;}};this.xmlhttp.send(this.URLString);}}};this.reset();this.createAJAX();}