⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 html_ajax_lite.js

📁 This is the script which used on 10minutemail.com for temporary email.
💻 JS
📖 第 1 页 / 共 5 页
字号:
return;}input = input.split("&");var pos, key, keys, val, _HTML_AJAX = [];if (input.length == 1) {return HTML_AJAX_Util.decodeUrl(input[0].substr(this.base.length + 1));}for (var i in input) {pos = input[i].indexOf("=");if (pos < 1 || input[i].length - pos - 1 < 1) {this.raiseError("input is too short", input[i]);return;}key = HTML_AJAX_Util.decodeUrl(input[i].substr(0, pos));val = HTML_AJAX_Util.decodeUrl(input[i].substr(pos + 1));key = key.replace(/\[((\d*\D+)+)\]/g, '["$1"]');keys = key.split(']');for (j in keys) {if (!keys[j].length || keys[j].length == 0) {continue;}try {if (eval('typeof ' + keys[j] + ']') == 'undefined') {var ev = keys[j] + ']=[];';eval(ev);}} catch (e) {this.raiseError("error evaluating key", ev);return;}}try {eval(key + '="' + val + '";');} catch (e) {this.raiseError("error evaluating value", input);return;}}return _HTML_AJAX;},/***  Gets the last error message**  @return	string   the last error message from unserialize()*/getError: function() {return this.message + "\n" + this.cont;},/***  Raises an eror (called by unserialize().)**  @param	string	message	the error message*  @param	string	cont	   the remaining unserialized content*/raiseError: function(message, cont) {this.error = 1;this.message = message;this.cont = cont;}}// serializer/phpSerializer.js/*** PHP serializer** This class can be used to serialize and unserialize data in a* format compatible with PHP's native serialization functions.** @version	0.0.3* @copyright	2005 Arpad Ray <arpad@php.net>* @license	http://www.opensource.org/licenses/lgpl-license.php  LGPL** See Main.js for Author/license details*/function HTML_AJAX_Serialize_PHP() {}HTML_AJAX_Serialize_PHP.prototype = {error: false,message: "",cont: "",defaultEncoding: 'UTF-8',contentType: 'application/php-serialized; charset: UTF-8',/***  Serializes a variable**  @param	mixed  inp the variable to serialize*  @return	string   a string representation of the input,*					  which can be reconstructed by unserialize()*  @author Arpad Ray <arpad@rajeczy.com>*  @author David Coallier <davidc@php.net>*/serialize: function(inp) {var type = HTML_AJAX_Util.getType(inp);var val;switch (type) {case "undefined":val = "N";break;case "boolean":val = "b:" + (inp ? "1" : "0");break;case "number":val = (Math.round(inp) == inp ? "i" : "d") + ":" + inp;break;case "string":val = "s:" + inp.length + ":\"" + inp + "\"";break;case "array":val = "a";case "object":if (type == "object") {var objname = inp.constructor.toString().match(/(\w+)\(\)/);if (objname == undefined) {return;}objname[1] = this.serialize(objname[1]);val = "O" + objname[1].substring(1, objname[1].length - 1);}var count = 0;var vals = "";var okey;for (key in inp) {okey = (key.match(/^[0-9]+$/) ? parseInt(key) : key);vals += this.serialize(okey) +this.serialize(inp[key]);count++;}val += ":" + count + ":{" + vals + "}";break;}if (type != "object" && type != "array") val += ";";return val;},/***  Reconstructs a serialized variable**  @param	string inp the string to reconstruct*  @return   mixed the variable represented by the input string, or void on failure*/unserialize: function(inp) {this.error = 0;if (inp == "" || inp.length < 2) {this.raiseError("input is too short");return;}var val, kret, vret, cval;var type = inp.charAt(0);var cont = inp.substring(2);var size = 0, divpos = 0, endcont = 0, rest = "", next = "";switch (type) {case "N": // nullif (inp.charAt(1) != ";") {this.raiseError("missing ; for null", cont);}rest = cont;break;case "b": // booleanif (!/[01];/.test(cont.substring(0,2))) {this.raiseError("value not 0 or 1, or missing ; for boolean", cont);}val = (cont.charAt(0) == "1");rest = cont.substring(1);break;case "s": // stringval = "";divpos = cont.indexOf(":");if (divpos == -1) {this.raiseError("missing : for string", cont);break;}size = parseInt(cont.substring(0, divpos));if (size == 0) {if (cont.length - divpos < 4) {this.raiseError("string is too short", cont);break;}rest = cont.substring(divpos + 4);break;}if ((cont.length - divpos - size) < 4) {this.raiseError("string is too short", cont);break;}if (cont.substring(divpos + 2 + size, divpos + 4 + size) != "\";") {this.raiseError("string is too long, or missing \";", cont);}val = cont.substring(divpos + 2, divpos + 2 + size);rest = cont.substring(divpos + 4 + size);break;case "i": // integercase "d": // floatvar dotfound = 0;for (var i = 0; i < cont.length; i++) {cval = cont.charAt(i);if (isNaN(parseInt(cval)) && !(type == "d" && cval == "." && !dotfound++)) {endcont = i;break;}}if (!endcont || cont.charAt(endcont) != ";") {this.raiseError("missing or invalid value, or missing ; for int/float", cont);}val = cont.substring(0, endcont);val = (type == "i" ? parseInt(val) : parseFloat(val));rest = cont.substring(endcont + 1);break;case "a": // arrayif (cont.length < 4) {this.raiseError("array is too short", cont);return;}divpos = cont.indexOf(":", 1);if (divpos == -1) {this.raiseError("missing : for array", cont);return;}size = parseInt(cont.substring(0, divpos));cont = cont.substring(divpos + 2);val = new Array();if (cont.length < 1) {this.raiseError("array is too short", cont);return;}for (var i = 0; i < size; i++) {kret = this.unserialize(cont, 1);if (this.error || kret[0] == undefined || kret[1] == "") {this.raiseError("missing or invalid key, or missing value for array", cont);return;}vret = this.unserialize(kret[1], 1);if (this.error) {this.raiseError("invalid value for array", cont);return;}val[kret[0]] = vret[0];cont = vret[1];}if (cont.charAt(0) != "}") {this.raiseError("missing ending }, or too many values for array", cont);return;}rest = cont.substring(1);break;case "O": // objectdivpos = cont.indexOf(":");if (divpos == -1) {this.raiseError("missing : for object", cont);return;}size = parseInt(cont.substring(0, divpos));var objname = cont.substring(divpos + 2, divpos + 2 + size);if (cont.substring(divpos + 2 + size, divpos + 4 + size) != "\":") {this.raiseError("object name is too long, or missing \":", cont);return;}var objprops = this.unserialize("a:" + cont.substring(divpos + 4 + size), 1);if (this.error) {this.raiseError("invalid object properties", cont);return;}rest = objprops[1];var objout = "function " + objname + "(){";for (key in objprops[0]) {objout += "this." + key + "=objprops[0]['" + key + "'];";}objout += "}val=new " + objname + "();";eval(objout);break;default:this.raiseError("invalid input type", cont);}return (arguments.length == 1 ? val : [val, rest]);},/***  Gets the last error message**  @return	string   the last error message from unserialize()*/getError: function() {return this.message + "\n" + this.cont;},/***  Raises an eror (called by unserialize().)**  @param	string	message	the error message*  @param	string	cont	   the remaining unserialized content*/raiseError: function(message, cont) {this.error = 1;this.message = message;this.cont = cont;}}// Dispatcher.js/*** Class that is used by generated stubs to make actual AJAX calls** @category    HTML* @package 	AJAX* @author	Joshua Eichorn <josh@bluga.net>* @copyright   2005 Joshua Eichorn* @license 	http://www.opensource.org/licenses/lgpl-license.php  LGPL*/function HTML_AJAX_Dispatcher(className,mode,callback,serverUrl,serializerType){this.className = className;this.mode = mode;this.callback = callback;this.serializerType = serializerType;if (serverUrl) {this.serverUrl = serverUrl}else {this.serverUrl = window.location;}}HTML_AJAX_Dispatcher.prototype = {/*** Queue to use when making a request*/queue: 'default',/*** Timeout for async calls*/timeout: 20000,/*** Default request priority*/priority: 0,/*** Request options*/options: {},/*** Make an ajax call** @param   string callName* @param   Array   args	arguments to the report method*/doCall: function(callName,args){var request = new HTML_AJAX_Request();request.requestUrl = this.serverUrl;request.className = this.className;request.methodName = callName;request.timeout = this.timeout;request.contentType = this.contentType;request.serializer = eval('new HTML_AJAX_Serialize_'+this.serializerType);request.queue = this.queue;request.priority = this.priority;for(var i in this.options) {request[i] = this.options[i];}for(var i=0; i < args.length; i++) {request.addArg(i,args[i]);};if ( this.mode == "async" ) {request.isAsync = true;if (this.callback[callName]) {var self = this;request.callback = function(result) { self.callback[callName](result); }}} else {request.isAsync = false;}return HTML_AJAX.makeRequest(request);},Sync: function(){this.mode = 'sync';},Async: function(callback){this.mode = 'async';if (callback) {this.callback = callback;}}};// HttpClient.js/*** XMLHttpRequest Wrapper* @category    HTML* @package 	AJAX* @author      Joshua Eichorn <josh@bluga.net>* @copyright   2005 Joshua Eichorn* @license     http://www.opensource.org/licenses/lgpl-license.php  LGPL*/function HTML_AJAX_HttpClient() { }HTML_AJAX_HttpClient.prototype = {request: null,_timeoutId: null,callbackComplete: true,aborted: false,init:function(){try {this.xmlhttp = new XMLHttpRequest();} catch (e) {var XMLHTTP_IDS = new Array('MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP' );var success = false;for (var i=0;i < XMLHTTP_IDS.length && !success; i++) {try {this.xmlhttp = new ActiveXObject(XMLHTTP_IDS[i]);success = true;} catch (e) {}}if (!success) {try{this.xmlhttp = new HTML_AJAX_IframeXHR();this.request.iframe = true;} catch(e) {throw new Error('Unable to create XMLHttpRequest.');}}}},callInProgress: function(){switch ( this.xmlhttp.readyState ) {case 1:case 2:case 3:return true;break;default:return false;break;}},makeRequest: function(){if (!this.xmlhttp) {this.init();}try {if (this.request.Open) {this.request.Open();}else if (HTML_AJAX.Open) {HTML_AJAX.Open(this.request);}if (this.request.multipart) {if (document.all) {this.iframe = true;} else {this.xmlhttp.multipart = true;}}var self = this;this.xmlhttp.open(this.request.requestType,this.request.completeUrl(),this.request.isAsync);if (this.request.customHeaders) {for (i in this.request.customHeaders) {this.xmlhttp.setRequestHeader(i, this.request.customHeaders[i]);}}if (this.request.customHeaders && !this.request.customHeaders['Content-Type']) {var content = this.request.getContentType();if(window.opera && content != 'application/xml'){this.xmlhttp.setRequestHeader('Content-Type','text/plain; charset=utf-8');this.xmlhttp.setRequestHeader('x-Content-Type', content + '; charset=utf-8');}else{this.xmlhttp.setRequestHeader('Content-Type', content +  '; charset=utf-8');}}if (this.request.isAsync) {if (this.request.callback) {this.callbackComplete = false;}this.xmlhttp.onreadystatechange = function() { self._readyStateChangeCallback(); }} else {this.xmlhttp.onreadystatechange = function() {}}var payload = this.request.getSerializedPayload();if (payload) {this.xmlhttp.setRequestHeader('Content-Length', payload.length);}this.xmlhttp.send(payload);if (!this.request.isAsync) {if ( this.xmlhttp.status == 200 ) {HTML_AJAX.requestComplete(this.request);if (this.request.Load) {this.request.Load();} else if (HTML_AJAX.Load) {HTML_AJAX.Load(this.request);}return this._decodeResponse();} else {var e = new Error('['+this.xmlhttp.status +'] '+this.xmlhttp.statusText);e.headers = this.xmlhttp.getAllResponseHeaders();this._handleError(e);}}else {var self = this;this._timeoutId = window.setTimeout(function() { self.abort(true); },this.request.timeout);}} catch (e) {this._handleError(e);}},abort: function (automatic){if (this.callInProgress()) {this.aborted = true;this.xmlhttp.abort();if (automatic) {HTML_AJAX.requestComplete(this.request);this._handleError(new Error('Request Timed Out: time out was '+this.request.timeout+'ms'));}}},_readyStateChangeCallback:function(){try {switch(this.xmlhttp.readyState) {case 1:break;case 2:if (this.request.Send) {this.request.Send();} else if (HTML_AJAX.Send) {HTML_AJAX.Send(this.request);}break;case 3:if (this.request.Progress) {this.request.Progress();} else if (HTML_AJAX.Progress ) {HTML_AJAX.Progress(this.request);}break;case 4:window.clearTimeout(this._timeoutId);if (this.aborted) {if (this.request.Load) {this.request.Load();} else if (HTML_AJAX.Load) {HTML_AJAX.Load(this.request);}}else if (this.xmlhttp.status == 200) {if (this.request.Load) {this.request.Load();} else if (HTML_AJAX.Load ) {HTML_AJAX.Load(this.request);}var response = this._decodeResponse();if (this.request.callback) {this.request.callback(response);this.callbackComplete = true;}}else {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -