-
+ 9117A060918D0C15CCF22EAD20623EB72B734770FF5117591A4842D1714E0FAEEF2A0E1ABBEF66A493A1FE1A6B8322AE1ED06D406002E8D2C62DE6A5FB96FBCE
mp-wp/wp-includes/js/tw-sack.js
(0 . 0)(1 . 192)
132776 /* Simple AJAX Code-Kit (SACK) v1.6.1 */
132777 /* www.twilightuniverse.com */
132778 /* Software licenced under a modified X11 licence,
132779 see documentation or authors website for more details */
132780
132781 function sack(file) {
132782 this.xmlhttp = null;
132783
132784 this.resetData = function() {
132785 this.method = "POST";
132786 this.queryStringSeparator = "?";
132787 this.argumentSeparator = "&";
132788 this.URLString = "";
132789 this.encodeURIString = true;
132790 this.execute = false;
132791 this.element = null;
132792 this.elementObj = null;
132793 this.requestFile = file;
132794 this.vars = new Object();
132795 this.responseStatus = new Array(2);
132796 };
132797
132798 this.resetFunctions = function() {
132799 this.onLoading = function() { };
132800 this.onLoaded = function() { };
132801 this.onInteractive = function() { };
132802 this.onCompletion = function() { };
132803 this.onError = function() { };
132804 this.onFail = function() { };
132805 };
132806
132807 this.reset = function() {
132808 this.resetFunctions();
132809 this.resetData();
132810 };
132811
132812 this.createAJAX = function() {
132813 try {
132814 this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
132815 } catch (e1) {
132816 try {
132817 this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
132818 } catch (e2) {
132819 this.xmlhttp = null;
132820 }
132821 }
132822
132823 if (! this.xmlhttp) {
132824 if (typeof XMLHttpRequest != "undefined") {
132825 this.xmlhttp = new XMLHttpRequest();
132826 } else {
132827 this.failed = true;
132828 }
132829 }
132830 };
132831
132832 this.setVar = function(name, value){
132833 this.vars[name] = Array(value, false);
132834 };
132835
132836 this.encVar = function(name, value, returnvars) {
132837 if (true == returnvars) {
132838 return Array(encodeURIComponent(name), encodeURIComponent(value));
132839 } else {
132840 this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
132841 }
132842 }
132843
132844 this.processURLString = function(string, encode) {
132845 encoded = encodeURIComponent(this.argumentSeparator);
132846 regexp = new RegExp(this.argumentSeparator + "|" + encoded);
132847 varArray = string.split(regexp);
132848 for (i = 0; i < varArray.length; i++){
132849 urlVars = varArray[i].split("=");
132850 if (true == encode){
132851 this.encVar(urlVars[0], urlVars[1]);
132852 } else {
132853 this.setVar(urlVars[0], urlVars[1]);
132854 }
132855 }
132856 }
132857
132858 this.createURLString = function(urlstring) {
132859 if (this.encodeURIString && this.URLString.length) {
132860 this.processURLString(this.URLString, true);
132861 }
132862
132863 if (urlstring) {
132864 if (this.URLString.length) {
132865 this.URLString += this.argumentSeparator + urlstring;
132866 } else {
132867 this.URLString = urlstring;
132868 }
132869 }
132870
132871 // prevents caching of URLString
132872 this.setVar("rndval", new Date().getTime());
132873
132874 urlstringtemp = new Array();
132875 for (key in this.vars) {
132876 if (false == this.vars[key][1] && true == this.encodeURIString) {
132877 encoded = this.encVar(key, this.vars[key][0], true);
132878 delete this.vars[key];
132879 this.vars[encoded[0]] = Array(encoded[1], true);
132880 key = encoded[0];
132881 }
132882
132883 urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
132884 }
132885 if (urlstring){
132886 this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
132887 } else {
132888 this.URLString += urlstringtemp.join(this.argumentSeparator);
132889 }
132890 }
132891
132892 this.runResponse = function() {
132893 eval(this.response);
132894 }
132895
132896 this.runAJAX = function(urlstring) {
132897 if (this.failed) {
132898 this.onFail();
132899 } else {
132900 this.createURLString(urlstring);
132901 if (this.element) {
132902 this.elementObj = document.getElementById(this.element);
132903 }
132904 if (this.xmlhttp) {
132905 var self = this;
132906 if (this.method == "GET") {
132907 totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
132908 this.xmlhttp.open(this.method, totalurlstring, true);
132909 } else {
132910 this.xmlhttp.open(this.method, this.requestFile, true);
132911 try {
132912 this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
132913 } catch (e) { }
132914 }
132915
132916 this.xmlhttp.onreadystatechange = function() {
132917 switch (self.xmlhttp.readyState) {
132918 case 1:
132919 self.onLoading();
132920 break;
132921 case 2:
132922 self.onLoaded();
132923 break;
132924 case 3:
132925 self.onInteractive();
132926 break;
132927 case 4:
132928 self.response = self.xmlhttp.responseText;
132929 self.responseXML = self.xmlhttp.responseXML;
132930 self.responseStatus[0] = self.xmlhttp.status;
132931 self.responseStatus[1] = self.xmlhttp.statusText;
132932
132933 if (self.execute) {
132934 self.runResponse();
132935 }
132936
132937 if (self.elementObj) {
132938 elemNodeName = self.elementObj.nodeName;
132939 elemNodeName.toLowerCase();
132940 if (elemNodeName == "input"
132941 || elemNodeName == "select"
132942 || elemNodeName == "option"
132943 || elemNodeName == "textarea") {
132944 self.elementObj.value = self.response;
132945 } else {
132946 self.elementObj.innerHTML = self.response;
132947 }
132948 }
132949 if (self.responseStatus[0] == "200") {
132950 self.onCompletion();
132951 } else {
132952 self.onError();
132953 }
132954
132955 self.URLString = "";
132956 break;
132957 }
132958 };
132959
132960 this.xmlhttp.send(this.URLString);
132961 }
132962 }
132963 };
132964
132965 this.reset();
132966 this.createAJAX();
132967 }