cvs: pear /HTML_AJAX/js Dispatcher.js HTML_AJAX.js HTML_AJAX_lite.js HttpClient.js Loading.js Request.js build.php phpSerializer.js util.js
| From: | David Coallier | Date: | Mon, 07 Nov 2005 18:41:40 +0000 |
| Subject: | cvs: pear /HTML_AJAX/js Dispatcher.js HTML_AJAX.js HTML_AJAX_lite.js HttpClient.js Loading.js Request.js build.php phpSerializer.js util.js | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-36133@lists.php.net to get a copy of this message | ||
davidc Mon Nov 7 13:41:40 2005 EDT
Modified files:
/pear/HTML_AJAX/js Dispatcher.js HTML_AJAX.js HTML_AJAX_lite.js
HttpClient.js Loading.js Request.js build.php
phpSerializer.js util.js
Log:
Latest release, updates
view svn.bluga.net for more infos.
http://cvs.php.net/diff.php/pear/HTML_AJAX/js/Dispatcher.js?r1=1.5&r2=1.6&ty=u Index: pear/HTML_AJAX/js/Dispatcher.js diff -u pear/HTML_AJAX/js/Dispatcher.js:1.5 pear/HTML_AJAX/js/Dispatcher.js:1.6 --- pear/HTML_AJAX/js/Dispatcher.js:1.5 Mon Oct 24 23:26:13 2005 +++ pear/HTML_AJAX/js/Dispatcher.js Mon Nov 7 13:41:38 2005 @@ -1,71 +1,85 @@ -/** - * 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, - - /** - * 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; - - 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); - } -}; -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +/** + * 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, + + /** + * 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; + + 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; + } + } + +}; +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ http://cvs.php.net/diff.php/pear/HTML_AJAX/js/HTML_AJAX.js?r1=1.4&r2=1.5&ty=u Index: pear/HTML_AJAX/js/HTML_AJAX.js diff -u pear/HTML_AJAX/js/HTML_AJAX.js:1.4 pear/HTML_AJAX/js/HTML_AJAX.js:1.5 --- pear/HTML_AJAX/js/HTML_AJAX.js:1.4 Mon Oct 24 23:26:13 2005 +++ pear/HTML_AJAX/js/HTML_AJAX.js Mon Nov 7 13:41:39 2005 @@ -272,375 +272,393 @@ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ // 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, - - /** - * 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; - - 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); - } -}; -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +/** + * 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, + + /** + * 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; + + 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; + } + } + +}; +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ // 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 object - request: null, - - // timeout id - _timeoutId: null, - - // method to initialize an xmlhttpclient - init:function() - { - try { - // Mozilla / Safari - this.xmlhttp = new XMLHttpRequest(); - } catch (e) { - // IE - 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) { - throw new Error('Unable to create XMLHttpRequest.'); - } - } - }, - - // check if there is a call in progress - callInProgress: function() - { - switch ( this.xmlhttp.readyState ) { - case 1: - case 2: - case 3: - return true; - break; - default: - return false; - break; - } - }, - - // make the request defined in the request object - makeRequest: function() - { - if (!this.xmlhttp) { - this.init(); - } - - try { - if (this.request.onOpen) { - this.request.onOpen(); - } - else if (HTML_AJAX.onOpen) { - HTML_AJAX.onOpen(this.request); - } - this.xmlhttp.open(this.request.requestType,this.request.completeUrl(),this.request.isAsync); - - // set onreadystatechange here since it will be reset after a completed call in Mozilla - var self = this; - this.xmlhttp.onreadystatechange = function() { self._readyStateChangeCallback(); } - - this.xmlhttp.setRequestHeader('Content-Type',this.request.getContentType()); - var payload = this.request.getSerializedPayload(); - if (payload) { - this.xmlhttp.setRequestHeader('Content-Length', payload.length); - } - this.xmlhttp.send(payload); - } catch (e) { - this._handleError(e); - } - - if (!this.request.isAsync) { - if ( this.xmlhttp.status == 200 ) { - HTML_AJAX.requestComplete(this.request); - if (this.request.onLoad) { - this.request.onLoad(); - } else if (HTML_AJAX.onLoad) { - HTML_AJAX.onLoad(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 { - // setup timeout - var self = this; - this._timeoutId = window.setTimeout(function() { self.abort(true); },this.request.timeout); - } - }, - - // abort an inprogress request - abort: function (automatic) - { - if (this.callInProgress()) { - this.xmlhttp.abort(); - - if (automatic) { - this._handleError(new Error('Request Timed Out')); - } - } - }, - - // internal method used to handle ready state changes - _readyStateChangeCallback:function() - { - try { - switch(this.xmlhttp.readyState) { - // XMLHTTPRequest.open() has just been called - case 1: - break; - // XMLHTTPRequest.send() has just been called - case 2: - if (this.request.onSend) { - this.request.onSend(); - } else if (HTML_AJAX.onSend) { - HTML_AJAX.onSend(this.request); - } - break; - // Fetching response from server in progress - case 3: - if (this.request.onProgress) { - this.request.onProgress(); - } else if (HTML_AJAX.onProgress ) { - HTML_AJAX.onProgress(this.request); - } - break; - // Download complete - case 4: - window.clearTimeout(this._timeout_id); - - if (this.xmlhttp.status == 200) { - HTML_AJAX.requestComplete(this.request); - if (this.request.onLoad) { - this.request.onLoad(); - } else if (HTML_AJAX.onLoad ) { - HTML_AJAX.onLoad(this.request); - } - - if (this.request.callback) { - this.request.callback(this._decodeResponse()); - } - } - - else { - var e = new Error('HTTP Error Making Request: ['+this.xmlhttp.status+'] '+this.xmlhttp.statusText); - this._handleError(e); - } - break; - } - } catch (e) { - this._handleError(e); - } - }, - - // decode response as needed - _decodeResponse: function() { - var unserializer = HTML_AJAX.serializerForEncoding(this.xmlhttp.getResponseHeader('Content-Type')); - //alert(this.xmlhttp.responseText); // some sort of debug hook is needed here - - // some sort of sane way for a serializer to ask for XML needs to be added - return unserializer.unserialize(this.xmlhttp.responseText); - }, - - // handle sending an error where it needs to go - _handleError: function(e) - { - HTML_AJAX.requestComplete(this.request,e); - if (this.request.onError) { - this.request.onError(e); - } else if (HTML_AJAX.onError) { - HTML_AJAX.onError(e,this.request); - } - else { - throw e; - } - } -} -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +/** + * 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 object + request: null, + + // timeout id + _timeoutId: null, + + // method to initialize an xmlhttpclient + init:function() + { + try { + // Mozilla / Safari + this.xmlhttp = new XMLHttpRequest(); + } catch (e) { + // IE + 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) { + throw new Error('Unable to create XMLHttpRequest.'); + } + } + }, + + // check if there is a call in progress + callInProgress: function() + { + switch ( this.xmlhttp.readyState ) { + case 1: + case 2: + case 3: + return true; + break; + default: + return false; + break; + } + }, + + // make the request defined in the request object + makeRequest: function() + { + if (!this.xmlhttp) { + this.init(); + } + + try { + if (this.request.onOpen) { + this.request.onOpen(); + } + else if (HTML_AJAX.onOpen) { + HTML_AJAX.onOpen(this.request); + } + this.xmlhttp.open(this.request.requestType,this.request.completeUrl(),this.request.isAsync); + + // set onreadystatechange here since it will be reset after a completed call in Mozilla + var self = this; + this.xmlhttp.onreadystatechange = function() { self._readyStateChangeCallback(); } + + this.xmlhttp.setRequestHeader('Content-Type',this.request.getContentType()); + var payload = this.request.getSerializedPayload(); + if (payload) { + this.xmlhttp.setRequestHeader('Content-Length', payload.length); + } + this.xmlhttp.send(payload); + } catch (e) { + this._handleError(e); + } + + if (!this.request.isAsync) { + if ( this.xmlhttp.status == 200 ) { + HTML_AJAX.requestComplete(this.request); + if (this.request.onLoad) { + this.request.onLoad(); + } else if (HTML_AJAX.onLoad) { + HTML_AJAX.onLoad(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 { + // setup timeout + var self = this; + this._timeoutId = window.setTimeout(function() { self.abort(true); },this.request.timeout); + } + }, + + // abort an inprogress request + abort: function (automatic) + { + if (this.callInProgress()) { + this.xmlhttp.abort(); + + if (automatic) { + this._handleError(new Error('Request Timed Out')); + } + } + }, + + // internal method used to handle ready state changes + _readyStateChangeCallback:function() + { + try { + switch(this.xmlhttp.readyState) { + // XMLHTTPRequest.open() has just been called + case 1: + break; + // XMLHTTPRequest.send() has just been called + case 2: + if (this.request.onSend) { + this.request.onSend(); + } else if (HTML_AJAX.onSend) { + HTML_AJAX.onSend(this.request); + } + break; + // Fetching response from server in progress + case 3: + if (this.request.onProgress) { + this.request.onProgress(); + } else if (HTML_AJAX.onProgress ) { + HTML_AJAX.onProgress(this.request); + } + break; + // Download complete + case 4: + window.clearTimeout(this._timeout_id); + + if (this.xmlhttp.status == 200) { + HTML_AJAX.requestComplete(this.request); + if (this.request.onLoad) { + this.request.onLoad(); + } else if (HTML_AJAX.onLoad ) { + HTML_AJAX.onLoad(this.request); + } + + if (this.request.callback) { + this.request.callback(this._decodeResponse()); + } + } + + else { + var e = new Error('HTTP Error Making Request: ['+this.xmlhttp.status+'] '+this.xmlhttp.statusText); + this._handleError(e); + } + break; + } + } catch (e) { + this._handleError(e); + } + }, + + // decode response as needed + _decodeResponse: function() { + var unserializer = HTML_AJAX.serializerForEncoding(this.xmlhttp.getResponseHeader('Content-Type')); + //alert(this.xmlhttp.responseText); // some sort of debug hook is needed here + + // some sort of sane way for a serializer to ask for XML needs to be added + return unserializer.unserialize(this.xmlhttp.responseText); + }, + + // handle sending an error where it needs to go + _handleError: function(e) + { + HTML_AJAX.requestComplete(this.request,e); + if (this.request.onError) { + this.request.onError(e); + } else if (HTML_AJAX.onError) { + HTML_AJAX.onError(e,this.request); + } + else { + throw e; + } + } +} +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ // Request.js -/** - * Class that contains everything needed to make a request - * This includes: - * The url were calling - * If were calling a remote method, the class and method name - * The payload, unserialized - * The timeout for async calls - * The callback method - * Optional event handlers: onError, onLoad, onSend - * A serializer instance - * - * @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_Request(serializer) { - this.serializer = serializer; -} -HTML_AJAX_Request.prototype = { - - // Instance of a serializer - serializer: null, - - // Is this an async request - isAsync: false, - - // HTTP verb - requestType: 'POST', - - // The actual URL the request is sent to - requestUrl: '', - - // Remote Class - className: null, - - // Remote Method - methodName: null, - - // Timeout in milliseconds for requests - timeout: 20000, - - // unserialized data, for rpc calls use add args, to send raw data just set this directly - args: null, - - // async callback method - callback: null, - - // Queue to push this request too - queue: 'default', - - /** - * Add an argument for the remote method - * @param string argument name - * @param mixed value - * @return void - * @throws Error code 1004 - */ - addArg: function(name, value) - { - if ( !this.args ) { - this.args = []; - } - if (!/[^a-zA-Z_0-9]/.test(name) ) { - this.args[name] = value; - } else { - throw new Error('Invalid parameter name ('+name+')'); - } - }, - - /** - * Get the payload in a serialized manner - */ - getSerializedPayload: function() { - return this.serializer.serialize(this.args); - }, - - /** - * Get the content type - */ - getContentType: function() { - return this.serializer.contentType; - }, - - /** - * Get the complete url, adding in any needed get params for rpc - */ - completeUrl: function() { - var url = this.requestUrl; - if (this.className || this.methodName) { - url += '?c='+escape(this.className)+'&m='+escape(this.methodName); - } - return url; - } -} -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +/** + * Class that contains everything needed to make a request + * This includes: + * The url were calling + * If were calling a remote method, the class and method name + * The payload, unserialized + * The timeout for async calls + * The callback method + * Optional event handlers: onError, onLoad, onSend + * A serializer instance + * + * @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_Request(serializer) { + this.serializer = serializer; +} +HTML_AJAX_Request.prototype = { + + // Instance of a serializer + serializer: null, + + // Is this an async request + isAsync: false, + + // HTTP verb + requestType: 'POST', + + // The actual URL the request is sent to + requestUrl: '', + + // Remote Class + className: null, + + // Remote Method + methodName: null, + + // Timeout in milliseconds for requests + timeout: 20000, + + // unserialized data, for rpc calls use add args, to send raw data just set this directly + args: null, + + // async callback method + callback: null, + + // Queue to push this request too + queue: 'default', + + /** + * Add an argument for the remote method + * @param string argument name + * @param mixed value + * @return void + * @throws Error code 1004 + */ + addArg: function(name, value) + { + if ( !this.args ) { + this.args = []; + } + if (!/[^a-zA-Z_0-9]/.test(name) ) { + this.args[name] = value; + } else { + throw new Error('Invalid parameter name ('+name+')'); + } + }, + + /** + * Get the payload in a serialized manner + */ + getSerializedPayload: function() { + return this.serializer.serialize(this.args); + }, + + /** + * Get the content type + */ + getContentType: function() { + return this.serializer.contentType; + }, + + /** + * Get the complete url, adding in any needed get params for rpc + */ + completeUrl: function() { + var url = new String(this.requestUrl); + var delimiter = '?'; + if (url.indexOf('?') >= 0) { + delimiter = '&'; + } + if (this.className || this.methodName) { + url += delimiter+'c='+escape(this.className)+'&m='+escape(this.methodName); + } + return url; + } +} +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ // JSON.js /* Copyright (c) 2005 JSON.org @@ -984,90 +1002,90 @@ }; /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ // Loading.js -/** - * Default loading implementation - * - * @category HTML - * @package Ajax - * @author Joshua Eichorn <josh@bluga.net> - * @copyright 2005 Joshua Eichorn - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - */ - -HTML_AJAX.onOpen = function(request) { - var loading = document.getElementById('HTML_AJAX_LOADING'); - if (!loading) { - loading = document.createElement('div'); - loading.id = 'HTML_AJAX_LOADING'; - loading.innerHTML = 'Loading...'; - loading.style.position = 'absolute'; - loading.style.top = 0; - loading.style.right = 0; - loading.style.backgroundColor = 'red'; - loading.style.width = '80px'; - loading.style.padding = '4px'; - - document.body.insertBefore(loading,document.body.firstChild); - } - HTML_AJAX.onOpen_Timeout = window.setTimeout(function() { loading.style.display = 'block'; },500); -} -HTML_AJAX.onLoad = function(request) { - if (HTML_AJAX.onOpen_Timeout) { - window.clearTimeout(HTML_AJAX.onOpen_Timeout); - HTML_AJAX.onOpen_Timeout = false; - } - var loading = document.getElementById('HTML_AJAX_LOADING'); - if (loading) { - loading.style.display = 'none'; - } -} -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +/** + * Default loading implementation + * + * @category HTML + * @package Ajax + * @author Joshua Eichorn <josh@bluga.net> + * @copyright 2005 Joshua Eichorn + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + */ + +HTML_AJAX.onOpen = function(request) { + var loading = document.getElementById('HTML_AJAX_LOADING'); + if (!loading) { + loading = document.createElement('div'); + loading.id = 'HTML_AJAX_LOADING'; + loading.innerHTML = 'Loading...'; + loading.style.position = 'absolute'; + loading.style.top = 0; + loading.style.right = 0; + loading.style.backgroundColor = 'red'; + loading.style.width = '80px'; + loading.style.padding = '4px'; + + document.body.insertBefore(loading,document.body.firstChild); + } + HTML_AJAX.onOpen_Timeout = window.setTimeout(function() { loading.style.display = 'block'; },500); +} +HTML_AJAX.onLoad = function(request) { + if (HTML_AJAX.onOpen_Timeout) { + window.clearTimeout(HTML_AJAX.onOpen_Timeout); + HTML_AJAX.onOpen_Timeout = false; + } + var loading = document.getElementById('HTML_AJAX_LOADING'); + if (loading) { + loading.style.display = 'none'; + } +} +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ // util.js -/** - * Utility methods - * - * @category HTML - * @package Ajax - * @author David Coallier <davidc@php.net> - * @copyright 2005 David Coallier - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - */ -// {{{ HTML_AJAX_Util -/** - * All the utilities we will be using thorough the classes - */ -var HTML_AJAX_Util = { - // Set the element event - setElementEvent: function(id, event, handler) { - var element = document.getElementById(id); - if (typeof element.addEventListener != "undefined") { //Dom2 - element.addEventListener(event, handler, false); - } else if (typeof element.attachEvent != "undefined") { //IE 5+ - element.attachEvent("on" + event, handler); - } else { - if (element["on" + event] != null) { - var oldHandler = element["on" + event]; - element["on" + event] = function(e) { - oldHander(e); - handler(e); - }; - } else { - element["on" + event] = handler; - } - } - }, - // simple non recursive variable dumper, don't rely on its output staying the same, its just for debugging and will get smarter at some point - varDump: function(input) { - var r = ""; - for(var i in input) { - r += i+':'+input[i]+"\n"; - } - return r; - } - -} -// }}} -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +/** + * Utility methods + * + * @category HTML + * @package Ajax + * @author David Coallier <davidc@php.net> + * @copyright 2005 David Coallier + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + */ +// {{{ HTML_AJAX_Util +/** + * All the utilities we will be using thorough the classes + */ +var HTML_AJAX_Util = { + // Set the element event + setElementEvent: function(id, event, handler) { + var element = document.getElementById(id); + if (typeof element.addEventListener != "undefined") { //Dom2 + element.addEventListener(event, handler, false); + } else if (typeof element.attachEvent != "undefined") { //IE 5+ + element.attachEvent("on" + event, handler); + } else { + if (element["on" + event] != null) { + var oldHandler = element["on" + event]; + element["on" + event] = function(e) { + oldHander(e); + handler(e); + }; + } else { + element["on" + event] = handler; + } + } + }, + // simple non recursive variable dumper, don't rely on its output staying the same, its just for debugging and will get smarter at some point + varDump: function(input) { + var r = ""; + for(var i in input) { + r += i+':'+input[i]+"\n"; + } + return r; + } + +} +// }}} +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ // behavior.js /** @@ -1170,9 +1188,9 @@ } Behavior.start();// cssQuery-p.js -/* - cssQuery, version 2.0.2 (2005-08-19) - Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) - License: http://creativecommons.org/licenses/LGPL/2.1/ -*/ -eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('7 x=6(){7 1D="2.0.2";7 C=/\\s*,\\s*/;7 x=6(s,A){33{7 m=[];7 u=1z.32.2c&&!A;7 b=(A)?(A.31==22)?A:[A]:[1g];7 1E=18(s).1l(C),i;9(i=0;i<1E.y;i++){s=1y(1E[i]);8(U&&s.Z(0,3).2b("")==" *#"){s=s.Z(2);A=24([],b,s[1])}1A A=b;7 j=0,t,f,a,c="";H(j<s.y){t=s[j++];f=s[j++];c+=t+f;a="";8(s[j]=="("){H(s[j++]!=")")a+=s[j];a=a.Z(0,-1);c+="("+a+")"}A=(u&&V[c])?V[c]:21(A,t,f,a);8(u)V[c]=A}m=m.30(A)}2a x.2d;5 m}2Z(e){x.2d=e;5[]}};x.1Z=6(){5"6 x() {\\n [1D "+1D+"]\\n}"};7 V={};x.2c=L;x.2Y=6(s){8(s){s=1y(s).2b("");2a V[s]}1A V={}};7 29={};7 19=L;x.15=6(n,s){8(19)1i("s="+1U(s));29[n]=12 s()};x.2X=6(c){5 c?1i(c):o};7 D={};7 h={};7 q={P:/\\[([\\w-]+(\\|[\\w-]+)?)\\s*(\\W?=)?\\s*([^\\]]*)\\]/};7 T=[];D[" "]=6(r,f,t,n){7 e,i,j;9(i=0;i<f.y;i++){7 s=X(f[i],t,n);9(j=0;(e=s[j]);j++){8(M(e)&&14(e,n))r.z(e)}}};D["#"]=6(r,f,i){7 e,j;9(j=0;(e=f[j]);j++)8(e.B==i)r.z(e)};D["."]=6(r,f,c){c=12 1t("(^|\\\\s)"+c+"(\\\\s|$)");7 e,i;9(i=0;(e=f[i]);i++)8(c.l(e.1V))r.z(e)};D[":"]=6(r,f,p,a){7 t=h[p],e,i;8(t)9(i=0;(e=f[i]);i++)8(t(e,a))r.z(e)};h["2W"]=6(e){7 d=Q(e);8(d.1C)9(7 i=0;i<d.1C.y;i++){8(d.1C[i]==e)5 K}};h["2V"]=6(e){};7 M=6(e){5(e&&e.1c==1&&e.1f!="!")?e:23};7 16=6(e){H(e&&(e=e.2U)&&!M(e))28;5 e};7 G=6(e){H(e&&(e=e.2T)&&!M(e))28;5 e};7 1r=6(e){5 M(e.27)||G(e.27)};7 1P=6(e){5 M(e.26)||16(e.26)};7 1o=6(e){7 c=[];e=1r(e);H(e){c.z(e);e=G(e)}5 c};7 U=K;7 1h=6(e){7 d=Q(e);5(2S d.25=="2R")?/\\.1J$/i.l(d.2Q):2P(d.25=="2O 2N")};7 Q=6(e){5 e.2M||e.1g};7 X=6(e,t){5(t=="*"&&e.1B)?e.1B:e.X(t)};7 17=6(e,t,n){8(t=="*")5 M(e);8(!14(e,n))5 L;8(!1h(e))t=t.2L();5 e.1f==t};7 14=6(e,n){5!n||(n=="*")||(e.2K==n)};7 1e=6(e){5 e.1G};6 24(r,f,B){7 m,i,j;9(i=0;i<f.y;i++){8(m=f[i].1B.2J(B)){8(m.B==B)r.z(m);1A 8(m.y!=23){9(j=0;j<m.y;j++){8(m[j].B==B)r.z(m[j])}}}}5 r};8(![].z)22.2I.z=6(){9(7 i=0;i<1z.y;i++){o[o.y]=1z[i]}5 o.y};7 N=/\\|/;6 21(A,t,f,a){8(N.l(f)){f=f.1l(N);a=f[0];f=f[1]}7 r=[];8(D[t]){D[t](r,A,f,a)}5 r};7 S=/^[^\\s>+~]/;7 20=/[\\s#.:>+~()@]|[^\\s#.:>+~()@]+/g;6 1y(s){8(S.l(s))s=" "+s;5 s.P(20)||[]};7 W=/\\s*([\\s>+~(),]|^|$)\\s*/g;7 I=/([\\s>+~,]|[^(]\\+|^)([#.:@])/g;7 18=6(s){5 s.O(W,"$1").O(I,"$1*$2")};7 1u={1Z:6(){5"\'"},P:/^(\'[^\']*\')|("[^"]*")$/,l:6(s){5 o.P.l(s)},1S:6(s){5 o.l(s)?s:o+s+o},1Y:6(s){5 o.l(s)?s.Z(1,-1):s}};7 1s=6(t){5 1u.1Y(t)};7 E=/([\\/()[\\]?{}|*+-])/g;6 R(s){5 s.O(E,"\\\\$1")};x.15("1j-2H",6(){D[">"]=6(r,f,t,n){7 e,i,j;9(i=0;i<f.y;i++){7 s=1o(f[i]);9(j=0;(e=s[j]);j++)8(17(e,t,n))r.z(e)}};D["+"]=6(r,f,t,n){9(7 i=0;i<f.y;i++){7 e=G(f[i]);8(e&&17(e,t,n))r.z(e)}};D["@"]=6(r,f,a){7 t=T[a].l;7 e,i;9(i=0;(e=f[i]);i++)8(t(e))r.z(e)};h["2G-10"]=6(e){5!16(e)};h["1x"]=6(e,c){c=12 1t("^"+c,"i");H(e&&!e.13("1x"))e=e.1n;5 e&&c.l(e.13("1x"))};q.1X=/\\\\:/g;q.1w="@";q.J={};q.O=6(m,a,n,c,v){7 k=o.1w+m;8(!T[k]){a=o.1W(a,c||"",v||"");T[k]=a;T.z(a)}5 T[k].B};q.1Q=6(s){s=s.O(o.1X,"|");7 m;H(m=s.P(o.P)){7 r=o.O(m[0],m[1],m[2],m[3],m[4]);s=s.O(o.P,r)}5 s};q.1W=6(p,t,v){7 a={};a.B=o.1w+T.y;a.2F=p;t=o.J[t];t=t?t(o.13(p),1s(v)):L;a.l=12 2E("e","5 "+t);5 a};q.13=6(n){1d(n.2D()){F"B":5"e.B";F"2C":5"e.1V";F"9":5"e.2B";F"1T":8(U){5"1U((e.2A.P(/1T=\\\\1v?([^\\\\s\\\\1v]*)\\\\1v?/)||[])[1]||\'\')"}}5"e.13(\'"+n.O(N,":")+"\')"};q.J[""]=6(a){5 a};q.J["="]=6(a,v){5 a+"=="+1u.1S(v)};q.J["~="]=6(a,v){5"/(^| )"+R(v)+"( |$)/.l("+a+")"};q.J["|="]=6(a,v){5"/^"+R(v)+"(-|$)/.l("+a+")"};7 1R=18;18=6(s){5 1R(q.1Q(s))}});x.15("1j-2z",6(){D["~"]=6(r,f,t,n){7 e,i;9(i=0;(e=f[i]);i++){H(e=G(e)){8(17(e,t,n))r.z(e)}}};h["2y"]=6(e,t){t=12 1t(R(1s(t)));5 t.l(1e(e))};h["2x"]=6(e){5 e==Q(e).1H};h["2w"]=6(e){7 n,i;9(i=0;(n=e.1F[i]);i++){8(M(n)||n.1c==3)5 L}5 K};h["1N-10"]=6(e){5!G(e)};h["2v-10"]=6(e){e=e.1n;5 1r(e)==1P(e)};h["2u"]=6(e,s){7 n=x(s,Q(e));9(7 i=0;i<n.y;i++){8(n[i]==e)5 L}5 K};h["1O-10"]=6(e,a){5 1p(e,a,16)};h["1O-1N-10"]=6(e,a){5 1p(e,a,G)};h["2t"]=6(e){5 e.B==2s.2r.Z(1)};h["1M"]=6(e){5 e.1M};h["2q"]=6(e){5 e.1q===L};h["1q"]=6(e){5 e.1q};h["1L"]=6(e){5 e.1L};q.J["^="]=6(a,v){5"/^"+R(v)+"/.l("+a+")"};q.J["$="]=6(a,v){5"/"+R(v)+"$/.l("+a+")"};q.J["*="]=6(a,v){5"/"+R(v)+"/.l("+a+")"};6 1p(e,a,t){1d(a){F"n":5 K;F"2p":a="2n";1a;F"2o":a="2n+1"}7 1m=1o(e.1n);6 1k(i){7 i=(t==G)?1m.y-i:i-1;5 1m[i]==e};8(!Y(a))5 1k(a);a=a.1l("n");7 m=1K(a[0]);7 s=1K(a[1]);8((Y(m)||m==1)&&s==0)5 K;8(m==0&&!Y(s))5 1k(s);8(Y(s))s=0;7 c=1;H(e=t(e))c++;8(Y(m)||m==1)5(t==G)?(c<=s):(s>=c);5(c%m)==s}});x.15("1j-2m",6(){U=1i("L;/*@2l@8(@\\2k)U=K@2j@*/");8(!U){X=6(e,t,n){5 n?e.2i("*",t):e.X(t)};14=6(e,n){5!n||(n=="*")||(e.2h==n)};1h=1g.1I?6(e){5/1J/i.l(Q(e).1I)}:6(e){5 Q(e).1H.1f!="2g"};1e=6(e){5 e.2f||e.1G||1b(e)};6 1b(e){7 t="",n,i;9(i=0;(n=e.1F[i]);i++){1d(n.1c){F 11:F 1:t+=1b(n);1a;F 3:t+=n.2e;1a}}5 t}}});19=K;5 x}();',62,190,'|||||return|function|var|if|for||||||||pseudoClasses||||test|||this||AttributeSelector|||||||cssQuery|length|push|fr|id||selectors||case|nextElementSibling|while||tests|true|false|thisElement||replace|match|getDocument|regEscape||attributeSelectors|isMSIE|cache||getElementsByTagName|isNaN|slice|child||new|getAttribute|compareNamespace|addModule|previousElementSibling|compareTagName|parseSelector|loaded|break|_0|nodeType|switch|getTextContent|tagName|document|isXML|eval|css|_1|split|ch|parentNode|childElements|nthChild|disabled|firstElementChild|getText|RegExp|Quote|x22|PREFIX|lang|_2|arguments|else|all|links|version|se|childNodes|innerText|documentElement|contentType|xml|parseInt|indeterminate|checked|last|nth|lastElementChild|parse|_3|add|href|String|className|create|NS_IE|remove|toString|ST|select|Array|null|_4|mimeType|lastChild|firstChild|continue|modules|delete|join|caching|error|nodeValue|textContent|HTML|prefix|getElementsByTagNameNS|end|x5fwin32|cc_on|standard||odd|even|enabled|hash|location|target|not|only|empty|root|contains|level3|outerHTML|htmlFor|class|toLowerCase|Function|name|first|level2|prototype|item|scopeName|toUpperCase|ownerDocument|Document|XML|Boolean|URL|unknown|typeof|nextSibling|previousSibling|visited|link|valueOf|clearCache|catch|concat|constructor|callee|try'.split('|'),0,{})) +/* + cssQuery, version 2.0.2 (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ +eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('7 x=6(){7 1D="2.0.2";7 C=/\\s*,\\s*/;7 x=6(s,A){33{7 m=[];7 u=1z.32.2c&&!A;7 b=(A)?(A.31==22)?A:[A]:[1g];7 1E=18(s).1l(C),i;9(i=0;i<1E.y;i++){s=1y(1E[i]);8(U&&s.Z(0,3).2b("")==" *#"){s=s.Z(2);A=24([],b,s[1])}1A A=b;7 j=0,t,f,a,c="";H(j<s.y){t=s[j++];f=s[j++];c+=t+f;a="";8(s[j]=="("){H(s[j++]!=")")a+=s[j];a=a.Z(0,-1);c+="("+a+")"}A=(u&&V[c])?V[c]:21(A,t,f,a);8(u)V[c]=A}m=m.30(A)}2a x.2d;5 m}2Z(e){x.2d=e;5[]}};x.1Z=6(){5"6 x() {\\n [1D "+1D+"]\\n}"};7 V={};x.2c=L;x.2Y=6(s){8(s){s=1y(s).2b("");2a V[s]}1A V={}};7 29={};7 19=L;x.15=6(n,s){8(19)1i("s="+1U(s));29[n]=12 s()};x.2X=6(c){5 c?1i(c):o};7 D={};7 h={};7 q={P:/\\[([\\w-]+(\\|[\\w-]+)?)\\s*(\\W?=)?\\s*([^\\]]*)\\]/};7 T=[];D[" "]=6(r,f,t,n){7 e,i,j;9(i=0;i<f.y;i++){7 s=X(f[i],t,n);9(j=0;(e=s[j]);j++){8(M(e)&&14(e,n))r.z(e)}}};D["#"]=6(r,f,i){7 e,j;9(j=0;(e=f[j]);j++)8(e.B==i)r.z(e)};D["."]=6(r,f,c){c=12 1t("(^|\\\\s)"+c+"(\\\\s|$)");7 e,i;9(i=0;(e=f[i]);i++)8(c.l(e.1V))r.z(e)};D[":"]=6(r,f,p,a){7 t=h[p],e,i;8(t)9(i=0;(e=f[i]);i++)8(t(e,a))r.z(e)};h["2W"]=6(e){7 d=Q(e);8(d.1C)9(7 i=0;i<d.1C.y;i++){8(d.1C[i]==e)5 K}};h["2V"]=6(e){};7 M=6(e){5(e&&e.1c==1&&e.1f!="!")?e:23};7 16=6(e){H(e&&(e=e.2U)&&!M(e))28;5 e};7 G=6(e){H(e&&(e=e.2T)&&!M(e))28;5 e};7 1r=6(e){5 M(e.27)||G(e.27)};7 1P=6(e){5 M(e.26)||16(e.26)};7 1o=6(e){7 c=[];e=1r(e);H(e){c.z(e);e=G(e)}5 c};7 U=K;7 1h=6(e){7 d=Q(e);5(2S d.25=="2R")?/\\.1J$/i.l(d.2Q):2P(d.25=="2O 2N")};7 Q=6(e){5 e.2M||e.1g};7 X=6(e,t){5(t=="*"&&e.1B)?e.1B:e.X(t)};7 17=6(e,t,n){8(t=="*")5 M(e);8(!14(e,n))5 L;8(!1h(e))t=t.2L();5 e.1f==t};7 14=6(e,n){5!n||(n=="*")||(e.2K==n)};7 1e=6(e){5 e.1G};6 24(r,f,B){7 m,i,j;9(i=0;i<f.y;i++){8(m=f[i].1B.2J(B)){8(m.B==B)r.z(m);1A 8(m.y!=23){9(j=0;j<m.y;j++){8(m[j].B==B)r.z(m[j])}}}}5 r};8(![].z)22.2I.z=6(){9(7 i=0;i<1z.y;i++){o[o.y]=1z[i]}5 o.y};7 N=/\\|/;6 21(A,t,f,a){8(N.l(f)){f=f.1l(N);a=f[0];f=f[1]}7 r=[];8(D[t]){D[t](r,A,f,a)}5 r};7 S=/^[^\\s>+~]/;7 20=/[\\s#.:>+~()@]|[^\\s#.:>+~()@]+/g;6 1y(s){8(S.l(s))s=" "+s;5 s.P(20)||[]};7 W=/\\s*([\\s>+~(),]|^|$)\\s*/g;7 I=/([\\s>+~,]|[^(]\\+|^)([#.:@])/g;7 18=6(s){5 s.O(W,"$1").O(I,"$1*$2")};7 1u={1Z:6(){5"\'"},P:/^(\'[^\']*\')|("[^"]*")$/,l:6(s){5 o.P.l(s)},1S:6(s){5 o.l(s)?s:o+s+o},1Y:6(s){5 o.l(s)?s.Z(1,-1):s}};7 1s=6(t){5 1u.1Y(t)};7 E=/([\\/()[\\]?{}|*+-])/g;6 R(s){5 s.O(E,"\\\\$1")};x.15("1j-2H",6(){D[">"]=6(r,f,t,n){7 e,i,j;9(i=0;i<f.y;i++){7 s=1o(f[i]);9(j=0;(e=s[j]);j++)8(17(e,t,n))r.z(e)}};D["+"]=6(r,f,t,n){9(7 i=0;i<f.y;i++){7 e=G(f[i]);8(e&&17(e,t,n))r.z(e)}};D["@"]=6(r,f,a){7 t=T[a].l;7 e,i;9(i=0;(e=f[i]);i++)8(t(e))r.z(e)};h["2G-10"]=6(e){5!16(e)};h["1x"]=6(e,c){c=12 1t("^"+c,"i");H(e&&!e.13("1x"))e=e.1n;5 e&&c.l(e.13("1x"))};q.1X=/\\\\:/g;q.1w="@";q.J={};q.O=6(m,a,n,c,v){7 k=o.1w+m;8(!T[k]){a=o.1W(a,c||"",v||"");T[k]=a;T.z(a)}5 T[k].B};q.1Q=6(s){s=s.O(o.1X,"|");7 m;H(m=s.P(o.P)){7 r=o.O(m[0],m[1],m[2],m[3],m[4]);s=s.O(o.P,r)}5 s};q.1W=6(p,t,v){7 a={};a.B=o.1w+T.y;a.2F=p;t=o.J[t];t=t?t(o.13(p),1s(v)):L;a.l=12 2E("e","5 "+t);5 a};q.13=6(n){1d(n.2D()){F"B":5"e.B";F"2C":5"e.1V";F"9":5"e.2B";F"1T":8(U){5"1U((e.2A.P(/1T=\\\\1v?([^\\\\s\\\\1v]*)\\\\1v?/)||[])[1]||\'\')"}}5"e.13(\'"+n.O(N,":")+"\')"};q.J[""]=6(a){5 a};q.J["="]=6(a,v){5 a+"=="+1u.1S(v)};q.J["~="]=6(a,v){5"/(^| )"+R(v)+"( |$)/.l("+a+")"};q.J["|="]=6(a,v){5"/^"+R(v)+"(-|$)/.l("+a+")"};7 1R=18;18=6(s){5 1R(q.1Q(s))}});x.15("1j-2z",6(){D["~"]=6(r,f,t,n){7 e,i;9(i=0;(e=f[i]);i++){H(e=G(e)){8(17(e,t,n))r.z(e)}}};h["2y"]=6(e,t){t=12 1t(R(1s(t)));5 t.l(1e(e))};h["2x"]=6(e){5 e==Q(e).1H};h["2w"]=6(e){7 n,i;9(i=0;(n=e.1F[i]);i++){8(M(n)||n.1c==3)5 L}5 K};h["1N-10"]=6(e){5!G(e)};h["2v-10"]=6(e){e=e.1n;5 1r(e)==1P(e)};h["2u"]=6(e,s){7 n=x(s,Q(e));9(7 i=0;i<n.y;i++){8(n[i]==e)5 L}5 K};h["1O-10"]=6(e,a){5 1p(e,a,16)};h["1O-1N-10"]=6(e,a){5 1p(e,a,G)};h["2t"]=6(e){5 e.B==2s.2r.Z(1)};h["1M"]=6(e){5 e.1M};h["2q"]=6(e){5 e.1q===L};h["1q"]=6(e){5 e.1q};h["1L"]=6(e){5 e.1L};q.J["^="]=6(a,v){5"/^"+R(v)+"/.l("+a+")"};q.J["$="]=6(a,v){5"/"+R(v)+"$/.l("+a+")"};q.J["*="]=6(a,v){5"/"+R(v)+"/.l("+a+")"};6 1p(e,a,t){1d(a){F"n":5 K;F"2p":a="2n";1a;F"2o":a="2n+1"}7 1m=1o(e.1n);6 1k(i){7 i=(t==G)?1m.y-i:i-1;5 1m[i]==e};8(!Y(a))5 1k(a);a=a.1l("n");7 m=1K(a[0]);7 s=1K(a[1]);8((Y(m)||m==1)&&s==0)5 K;8(m==0&&!Y(s))5 1k(s);8(Y(s))s=0;7 c=1;H(e=t(e))c++;8(Y(m)||m==1)5(t==G)?(c<=s):(s>=c);5(c%m)==s}});x.15("1j-2m",6(){U=1i("L;/*@2l@8(@\\2k)U=K@2j@*/");8(!U){X=6(e,t,n){5 n?e.2i("*",t):e.X(t)};14=6(e,n){5!n||(n=="*")||(e.2h==n)};1h=1g.1I?6(e){5/1J/i.l(Q(e).1I)}:6(e){5 Q(e).1H.1f!="2g"};1e=6(e){5 e.2f||e.1G||1b(e)};6 1b(e){7 t="",n,i;9(i=0;(n=e.1F[i]);i++){1d(n.1c){F 11:F 1:t+=1b(n);1a;F 3:t+=n.2e;1a}}5 t}}});19=K;5 x}();',62,190,'|||||return|function|var|if|for||||||||pseudoClasses||||test|||this||AttributeSelector|||||||cssQuery|length|push|fr|id||selectors||case|nextElementSibling|while||tests|true|false|thisElement||replace|match|getDocument|regEscape||attributeSelectors|isMSIE|cache||getElementsByTagName|isNaN|slice|child||new|getAttribute|compareNamespace|addModule|previousElementSibling|compareTagName|parseSelector|loaded|break|_0|nodeType|switch|getTextContent|tagName|document|isXML|eval|css|_1|split|ch|parentNode|childElements|nthChild|disabled|firstElementChild|getText|RegExp|Quote|x22|PREFIX|lang|_2|arguments|else|all|links|version|se|childNodes|innerText|documentElement|contentType|xml|parseInt|indeterminate|checked|last|nth|lastElementChild|parse|_3|add|href|String|className|create|NS_IE|remove|toString|ST|select|Array|null|_4|mimeType|lastChild|firstChild|continue|modules|delete|join|caching|error|nodeValue|textContent|HTML|prefix|getElementsByTagNameNS|end|x5fwin32|cc_on|standard||odd|even|enabled|hash|location|target|not|only|empty|root|contains|level3|outerHTML|htmlFor|class|toLowerCase|Function|name|first|level2|prototype|item|scopeName|toUpperCase|ownerDocument|Document|XML|Boolean|URL|unknown|typeof|nextSibling|previousSibling|visited|link|valueOf|clearCache|catch|concat|constructor|callee|try'.split('|'),0,{})) http://cvs.php.net/diff.php/pear/HTML_AJAX/js/HTML_AJAX_lite.js?r1=1.4&r2=1.5&ty=u Index: pear/HTML_AJAX/js/HTML_AJAX_lite.js diff -u pear/HTML_AJAX/js/HTML_AJAX_lite.js:1.4 pear/HTML_AJAX/js/HTML_AJAX_lite.js:1.5 --- pear/HTML_AJAX/js/HTML_AJAX_lite.js:1.4 Mon Oct 24 23:26:13 2005 +++ pear/HTML_AJAX/js/HTML_AJAX_lite.js Mon Nov 7 13:41:39 2005 @@ -242,6 +242,17 @@ 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 @@ -431,9 +442,13 @@ return this.serializer.contentType; }, completeUrl: function() { -var url = this.requestUrl; +var url = new String(this.requestUrl); +var delimiter = '?'; +if (url.indexOf('?') >= 0) { +delimiter = '&'; +} if (this.className || this.methodName) { -url += '?c='+escape(this.className)+'&m='+escape(this.methodName); +url += delimiter+'c='+escape(this.className)+'&m='+escape(this.methodName); } return url; } http://cvs.php.net/diff.php/pear/HTML_AJAX/js/HttpClient.js?r1=1.4&r2=1.5&ty=u Index: pear/HTML_AJAX/js/HttpClient.js diff -u pear/HTML_AJAX/js/HttpClient.js:1.4 pear/HTML_AJAX/js/HttpClient.js:1.5 --- pear/HTML_AJAX/js/HttpClient.js:1.4 Mon Oct 24 23:26:14 2005 +++ pear/HTML_AJAX/js/HttpClient.js Mon Nov 7 13:41:39 2005 @@ -1,199 +1,199 @@ -/** - * 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 object - request: null, - - // timeout id - _timeoutId: null, - - // method to initialize an xmlhttpclient - init:function() - { - try { - // Mozilla / Safari - this.xmlhttp = new XMLHttpRequest(); - } catch (e) { - // IE - 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) { - throw new Error('Unable to create XMLHttpRequest.'); - } - } - }, - - // check if there is a call in progress - callInProgress: function() - { - switch ( this.xmlhttp.readyState ) { - case 1: - case 2: - case 3: - return true; - break; - default: - return false; - break; - } - }, - - // make the request defined in the request object - makeRequest: function() - { - if (!this.xmlhttp) { - this.init(); - } - - try { - if (this.request.onOpen) { - this.request.onOpen(); - } - else if (HTML_AJAX.onOpen) { - HTML_AJAX.onOpen(this.request); - } - this.xmlhttp.open(this.request.requestType,this.request.completeUrl(),this.request.isAsync); - - // set onreadystatechange here since it will be reset after a completed call in Mozilla - var self = this; - this.xmlhttp.onreadystatechange = function() { self._readyStateChangeCallback(); } - - this.xmlhttp.setRequestHeader('Content-Type',this.request.getContentType()); - var payload = this.request.getSerializedPayload(); - if (payload) { - this.xmlhttp.setRequestHeader('Content-Length', payload.length); - } - this.xmlhttp.send(payload); - } catch (e) { - this._handleError(e); - } - - if (!this.request.isAsync) { - if ( this.xmlhttp.status == 200 ) { - HTML_AJAX.requestComplete(this.request); - if (this.request.onLoad) { - this.request.onLoad(); - } else if (HTML_AJAX.onLoad) { - HTML_AJAX.onLoad(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 { - // setup timeout - var self = this; - this._timeoutId = window.setTimeout(function() { self.abort(true); },this.request.timeout); - } - }, - - // abort an inprogress request - abort: function (automatic) - { - if (this.callInProgress()) { - this.xmlhttp.abort(); - - if (automatic) { - this._handleError(new Error('Request Timed Out')); - } - } - }, - - // internal method used to handle ready state changes - _readyStateChangeCallback:function() - { - try { - switch(this.xmlhttp.readyState) { - // XMLHTTPRequest.open() has just been called - case 1: - break; - // XMLHTTPRequest.send() has just been called - case 2: - if (this.request.onSend) { - this.request.onSend(); - } else if (HTML_AJAX.onSend) { - HTML_AJAX.onSend(this.request); - } - break; - // Fetching response from server in progress - case 3: - if (this.request.onProgress) { - this.request.onProgress(); - } else if (HTML_AJAX.onProgress ) { - HTML_AJAX.onProgress(this.request); - } - break; - // Download complete - case 4: - window.clearTimeout(this._timeout_id); - - if (this.xmlhttp.status == 200) { - HTML_AJAX.requestComplete(this.request); - if (this.request.onLoad) { - this.request.onLoad(); - } else if (HTML_AJAX.onLoad ) { - HTML_AJAX.onLoad(this.request); - } - - if (this.request.callback) { - this.request.callback(this._decodeResponse()); - } - } - - else { - var e = new Error('HTTP Error Making Request: ['+this.xmlhttp.status+'] '+this.xmlhttp.statusText); - this._handleError(e); - } - break; - } - } catch (e) { - this._handleError(e); - } - }, - - // decode response as needed - _decodeResponse: function() { - var unserializer = HTML_AJAX.serializerForEncoding(this.xmlhttp.getResponseHeader('Content-Type')); - //alert(this.xmlhttp.responseText); // some sort of debug hook is needed here - - // some sort of sane way for a serializer to ask for XML needs to be added - return unserializer.unserialize(this.xmlhttp.responseText); - }, - - // handle sending an error where it needs to go - _handleError: function(e) - { - HTML_AJAX.requestComplete(this.request,e); - if (this.request.onError) { - this.request.onError(e); - } else if (HTML_AJAX.onError) { - HTML_AJAX.onError(e,this.request); - } - else { - throw e; - } - } -} -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +/** + * 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 object + request: null, + + // timeout id + _timeoutId: null, + + // method to initialize an xmlhttpclient + init:function() + { + try { + // Mozilla / Safari + this.xmlhttp = new XMLHttpRequest(); + } catch (e) { + // IE + 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) { + throw new Error('Unable to create XMLHttpRequest.'); + } + } + }, + + // check if there is a call in progress + callInProgress: function() + { + switch ( this.xmlhttp.readyState ) { + case 1: + case 2: + case 3: + return true; + break; + default: + return false; + break; + } + }, + + // make the request defined in the request object + makeRequest: function() + { + if (!this.xmlhttp) { + this.init(); + } + + try { + if (this.request.onOpen) { + this.request.onOpen(); + } + else if (HTML_AJAX.onOpen) { + HTML_AJAX.onOpen(this.request); + } + this.xmlhttp.open(this.request.requestType,this.request.completeUrl(),this.request.isAsync); + + // set onreadystatechange here since it will be reset after a completed call in Mozilla + var self = this; + this.xmlhttp.onreadystatechange = function() { self._readyStateChangeCallback(); } + + this.xmlhttp.setRequestHeader('Content-Type',this.request.getContentType()); + var payload = this.request.getSerializedPayload(); + if (payload) { + this.xmlhttp.setRequestHeader('Content-Length', payload.length); + } + this.xmlhttp.send(payload); + } catch (e) { + this._handleError(e); + } + + if (!this.request.isAsync) { + if ( this.xmlhttp.status == 200 ) { + HTML_AJAX.requestComplete(this.request); + if (this.request.onLoad) { + this.request.onLoad(); + } else if (HTML_AJAX.onLoad) { + HTML_AJAX.onLoad(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 { + // setup timeout + var self = this; + this._timeoutId = window.setTimeout(function() { self.abort(true); },this.request.timeout); + } + }, + + // abort an inprogress request + abort: function (automatic) + { + if (this.callInProgress()) { + this.xmlhttp.abort(); + + if (automatic) { + this._handleError(new Error('Request Timed Out')); + } + } + }, + + // internal method used to handle ready state changes + _readyStateChangeCallback:function() + { + try { + switch(this.xmlhttp.readyState) { + // XMLHTTPRequest.open() has just been called + case 1: + break; + // XMLHTTPRequest.send() has just been called + case 2: + if (this.request.onSend) { + this.request.onSend(); + } else if (HTML_AJAX.onSend) { + HTML_AJAX.onSend(this.request); + } + break; + // Fetching response from server in progress + case 3: + if (this.request.onProgress) { + this.request.onProgress(); + } else if (HTML_AJAX.onProgress ) { + HTML_AJAX.onProgress(this.request); + } + break; + // Download complete + case 4: + window.clearTimeout(this._timeout_id); + + if (this.xmlhttp.status == 200) { + HTML_AJAX.requestComplete(this.request); + if (this.request.onLoad) { + this.request.onLoad(); + } else if (HTML_AJAX.onLoad ) { + HTML_AJAX.onLoad(this.request); + } + + if (this.request.callback) { + this.request.callback(this._decodeResponse()); + } + } + + else { + var e = new Error('HTTP Error Making Request: ['+this.xmlhttp.status+'] '+this.xmlhttp.statusText); + this._handleError(e); + } + break; + } + } catch (e) { + this._handleError(e); + } + }, + + // decode response as needed + _decodeResponse: function() { + var unserializer = HTML_AJAX.serializerForEncoding(this.xmlhttp.getResponseHeader('Content-Type')); + //alert(this.xmlhttp.responseText); // some sort of debug hook is needed here + + // some sort of sane way for a serializer to ask for XML needs to be added + return unserializer.unserialize(this.xmlhttp.responseText); + }, + + // handle sending an error where it needs to go + _handleError: function(e) + { + HTML_AJAX.requestComplete(this.request,e); + if (this.request.onError) { + this.request.onError(e); + } else if (HTML_AJAX.onError) { + HTML_AJAX.onError(e,this.request); + } + else { + throw e; + } + } +} +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ http://cvs.php.net/diff.php/pear/HTML_AJAX/js/Loading.js?r1=1.1&r2=1.2&ty=u Index: pear/HTML_AJAX/js/Loading.js diff -u pear/HTML_AJAX/js/Loading.js:1.1 pear/HTML_AJAX/js/Loading.js:1.2 --- pear/HTML_AJAX/js/Loading.js:1.1 Mon Oct 24 23:28:30 2005 +++ pear/HTML_AJAX/js/Loading.js Mon Nov 7 13:41:39 2005 @@ -1,38 +1,38 @@ -/** - * Default loading implementation - * - * @category HTML - * @package Ajax - * @author Joshua Eichorn <josh@bluga.net> - * @copyright 2005 Joshua Eichorn - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - */ - -HTML_AJAX.onOpen = function(request) { - var loading = document.getElementById('HTML_AJAX_LOADING'); - if (!loading) { - loading = document.createElement('div'); - loading.id = 'HTML_AJAX_LOADING'; - loading.innerHTML = 'Loading...'; - loading.style.position = 'absolute'; - loading.style.top = 0; - loading.style.right = 0; - loading.style.backgroundColor = 'red'; - loading.style.width = '80px'; - loading.style.padding = '4px'; - - document.body.insertBefore(loading,document.body.firstChild); - } - HTML_AJAX.onOpen_Timeout = window.setTimeout(function() { loading.style.display = 'block'; },500); -} -HTML_AJAX.onLoad = function(request) { - if (HTML_AJAX.onOpen_Timeout) { - window.clearTimeout(HTML_AJAX.onOpen_Timeout); - HTML_AJAX.onOpen_Timeout = false; - } - var loading = document.getElementById('HTML_AJAX_LOADING'); - if (loading) { - loading.style.display = 'none'; - } -} -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +/** + * Default loading implementation + * + * @category HTML + * @package Ajax + * @author Joshua Eichorn <josh@bluga.net> + * @copyright 2005 Joshua Eichorn + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + */ + +HTML_AJAX.onOpen = function(request) { + var loading = document.getElementById('HTML_AJAX_LOADING'); + if (!loading) { + loading = document.createElement('div'); + loading.id = 'HTML_AJAX_LOADING'; + loading.innerHTML = 'Loading...'; + loading.style.position = 'absolute'; + loading.style.top = 0; + loading.style.right = 0; + loading.style.backgroundColor = 'red'; + loading.style.width = '80px'; + loading.style.padding = '4px'; + + document.body.insertBefore(loading,document.body.firstChild); + } + HTML_AJAX.onOpen_Timeout = window.setTimeout(function() { loading.style.display = 'block'; },500); +} +HTML_AJAX.onLoad = function(request) { + if (HTML_AJAX.onOpen_Timeout) { + window.clearTimeout(HTML_AJAX.onOpen_Timeout); + HTML_AJAX.onOpen_Timeout = false; + } + var loading = document.getElementById('HTML_AJAX_LOADING'); + if (loading) { + loading.style.display = 'none'; + } +} +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ http://cvs.php.net/diff.php/pear/HTML_AJAX/js/Request.js?r1=1.4&r2=1.5&ty=u Index: pear/HTML_AJAX/js/Request.js diff -u pear/HTML_AJAX/js/Request.js:1.4 pear/HTML_AJAX/js/Request.js:1.5 --- pear/HTML_AJAX/js/Request.js:1.4 Mon Oct 24 23:26:14 2005 +++ pear/HTML_AJAX/js/Request.js Mon Nov 7 13:41:39 2005 @@ -1,97 +1,101 @@ -/** - * Class that contains everything needed to make a request - * This includes: - * The url were calling - * If were calling a remote method, the class and method name - * The payload, unserialized - * The timeout for async calls - * The callback method - * Optional event handlers: onError, onLoad, onSend - * A serializer instance - * - * @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_Request(serializer) { - this.serializer = serializer; -} -HTML_AJAX_Request.prototype = { - - // Instance of a serializer - serializer: null, - - // Is this an async request - isAsync: false, - - // HTTP verb - requestType: 'POST', - - // The actual URL the request is sent to - requestUrl: '', - - // Remote Class - className: null, - - // Remote Method - methodName: null, - - // Timeout in milliseconds for requests - timeout: 20000, - - // unserialized data, for rpc calls use add args, to send raw data just set this directly - args: null, - - // async callback method - callback: null, - - // Queue to push this request too - queue: 'default', - - /** - * Add an argument for the remote method - * @param string argument name - * @param mixed value - * @return void - * @throws Error code 1004 - */ - addArg: function(name, value) - { - if ( !this.args ) { - this.args = []; - } - if (!/[^a-zA-Z_0-9]/.test(name) ) { - this.args[name] = value; - } else { - throw new Error('Invalid parameter name ('+name+')'); - } - }, - - /** - * Get the payload in a serialized manner - */ - getSerializedPayload: function() { - return this.serializer.serialize(this.args); - }, - - /** - * Get the content type - */ - getContentType: function() { - return this.serializer.contentType; - }, - - /** - * Get the complete url, adding in any needed get params for rpc - */ - completeUrl: function() { - var url = this.requestUrl; - if (this.className || this.methodName) { - url += '?c='+escape(this.className)+'&m='+escape(this.methodName); - } - return url; - } -} -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +/** + * Class that contains everything needed to make a request + * This includes: + * The url were calling + * If were calling a remote method, the class and method name + * The payload, unserialized + * The timeout for async calls + * The callback method + * Optional event handlers: onError, onLoad, onSend + * A serializer instance + * + * @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_Request(serializer) { + this.serializer = serializer; +} +HTML_AJAX_Request.prototype = { + + // Instance of a serializer + serializer: null, + + // Is this an async request + isAsync: false, + + // HTTP verb + requestType: 'POST', + + // The actual URL the request is sent to + requestUrl: '', + + // Remote Class + className: null, + + // Remote Method + methodName: null, + + // Timeout in milliseconds for requests + timeout: 20000, + + // unserialized data, for rpc calls use add args, to send raw data just set this directly + args: null, + + // async callback method + callback: null, + + // Queue to push this request too + queue: 'default', + + /** + * Add an argument for the remote method + * @param string argument name + * @param mixed value + * @return void + * @throws Error code 1004 + */ + addArg: function(name, value) + { + if ( !this.args ) { + this.args = []; + } + if (!/[^a-zA-Z_0-9]/.test(name) ) { + this.args[name] = value; + } else { + throw new Error('Invalid parameter name ('+name+')'); + } + }, + + /** + * Get the payload in a serialized manner + */ + getSerializedPayload: function() { + return this.serializer.serialize(this.args); + }, + + /** + * Get the content type + */ + getContentType: function() { + return this.serializer.contentType; + }, + + /** + * Get the complete url, adding in any needed get params for rpc + */ + completeUrl: function() { + var url = new String(this.requestUrl); + var delimiter = '?'; + if (url.indexOf('?') >= 0) { + delimiter = '&'; + } + if (this.className || this.methodName) { + url += delimiter+'c='+escape(this.className)+'&m='+escape(this.methodName); + } + return url; + } +} +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ http://cvs.php.net/diff.php/pear/HTML_AJAX/js/build.php?r1=1.3&r2=1.4&ty=u Index: pear/HTML_AJAX/js/build.php diff -u pear/HTML_AJAX/js/build.php:1.3 pear/HTML_AJAX/js/build.php:1.4 --- pear/HTML_AJAX/js/build.php:1.3 Mon Oct 24 23:26:14 2005 +++ pear/HTML_AJAX/js/build.php Mon Nov 7 13:41:39 2005 @@ -1,74 +1,74 @@ -<?php -/** - * A simple script to build a single js file from the multiple sources - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - */ -// simple script contains a merged js file from multiple source files -// can optionaly strip whitespace - -$dest = "HTML_AJAX.js"; -if (isset($argv[1])) { - $dest = $argv[1]; -} -$strip = false; -if (isset($argv[2]) && $argv[2] == 'strip') { - $strip = true; -} - -$source = array('Main.js','Dispatcher.js','HttpClient.js','Request.js','JSON.js','Loading.js','util.js','behavior.js','cssQuery-p.js'); - -$stripPregs = array( - '/^\s+$/', - '/^\s*\/\/.*$/' - ); -$blockStart = '/^\s*\/\*.*$/'; -$blockEnd = '/^\s*\*\/\s*$/'; - -$out = ''; -foreach($source as $file) { - $s = ""; - if ($strip) { - $lines = file($file); - $inblock = false; - foreach($lines as $line) { - $keep = true; - if ($inblock) { - if (preg_match($blockEnd,$line)) { - $inblock = false; - $keep = false; - } - } - else if (preg_match($blockStart,$line)) { - $inblock = true; - } - - if (!$inblock) { - foreach($stripPregs as $preg) { - if (preg_match($preg,$line)) { - $keep = false; - break; - } - } - } - - if ($keep && !$inblock) { - $s .= trim($line)."\n"; - } - /* Enable to see what your striping out - else { - echo $line."<br>"; - }*/ - } - } - else { - $s = file_get_contents($file); - } - - $out .= "// $file\n"; - $out .= $s; -} - -$fp = fopen($dest,'w'); -fwrite($fp,$out); -fclose($fp); -?> +<?php +/** + * A simple script to build a single js file from the multiple sources + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + */ +// simple script contains a merged js file from multiple source files +// can optionaly strip whitespace + +$dest = "HTML_AJAX.js"; +if (isset($argv[1])) { + $dest = $argv[1]; +} +$strip = false; +if (isset($argv[2]) && $argv[2] == 'strip') { + $strip = true; +} + +$source = array('Main.js','Dispatcher.js','HttpClient.js','Request.js','JSON.js','Loading.js','util.js','behavior.js','cssQuery-p.js'); + +$stripPregs = array( + '/^\s+$/', + '/^\s*\/\/.*$/' + ); +$blockStart = '/^\s*\/\*.*$/'; +$blockEnd = '/^\s*\*\/\s*$/'; + +$out = ''; +foreach($source as $file) { + $s = ""; + if ($strip) { + $lines = file($file); + $inblock = false; + foreach($lines as $line) { + $keep = true; + if ($inblock) { + if (preg_match($blockEnd,$line)) { + $inblock = false; + $keep = false; + } + } + else if (preg_match($blockStart,$line)) { + $inblock = true; + } + + if (!$inblock) { + foreach($stripPregs as $preg) { + if (preg_match($preg,$line)) { + $keep = false; + break; + } + } + } + + if ($keep && !$inblock) { + $s .= trim($line)."\n"; + } + /* Enable to see what your striping out + else { + echo $line."<br>"; + }*/ + } + } + else { + $s = file_get_contents($file); + } + + $out .= "// $file\n"; + $out .= $s; +} + +$fp = fopen($dest,'w'); +fwrite($fp,$out); +fclose($fp); +?> http://cvs.php.net/diff.php/pear/HTML_AJAX/js/phpSerializer.js?r1=1.1&r2=1.2&ty=u Index: pear/HTML_AJAX/js/phpSerializer.js diff -u pear/HTML_AJAX/js/phpSerializer.js:1.1 pear/HTML_AJAX/js/phpSerializer.js:1.2 --- pear/HTML_AJAX/js/phpSerializer.js:1.1 Mon Oct 24 23:28:30 2005 +++ pear/HTML_AJAX/js/phpSerializer.js Mon Nov 7 13:41:39 2005 @@ -1,290 +1,290 @@ -/*************************************************************************** - - These functions can be used to serialize and unserialize data in a - format compatible with PHP's native serialization functions. - - Copyright (C) 2005 Arpad Ray <arpad@rajeczy.com> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to: - Free Software Foundation, Inc., - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -***************************************************************************/ - -// {{{ var HTML_AJAX_Serialize_PHP -var HTML_AJAX_Serializer_PHP = { - - var defaultEncoding = 'UTF-8'; - // {{{ serialize - /** - * 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> - * @version 0.0.2 - */ - serialize: function(inp) { - var type = HTML_AJAX_Serializer_PHP.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] = HTML_AJAX_Serializer_PHP.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 += HTML_AJAX_Serializer_PHP.serialize(okey) + - HTML_AJAX_Serializer_PHP.serialize(inp[key]); - count++; - } - val += ":" + count + ":{" + vals + "}"; - break; - } - if (type != "object" && type != "array") val += ";"; - return val; - } - // }}} - // {{{ unserialize - /** - * Reconstructs a serialized variable - * - * @param mixed inp the string to reconstruct - * @return mixed the variable represented by the input string - * @author Arpad Ray <arpad@rajeczy.com> - * @version 0.0.2 - */ - unserialize: function(inp) { - - if (inp == "" || inp.length < 2) { - unserializer.raiseError("input is too short"); - return; - } - var val, kret, vret, cval; - var type = inp.charAt(0); - var cont = inp.substring(2); - var size = 0; - var divpos = 0; - var endcont = 0; - var rest = ""; - var next = ""; - - switch (type) { - case "N": // null - if (inp.charAt(1) != ";") { - unserializer.raiseError("missing ; for null", cont); - } - // leave val undefined - rest = cont; - break; - case "b": // boolean - if (!/[01];/.test(cont.substring(0,2))) { - unserializer.raiseError("value not 0 or 1, or missing ; for boolean", cont); - } - val = (cont.charAt(0) == "1"); - rest = cont.substring(1); - break; - case "s": // string - val = ""; - divpos = cont.indexOf(":"); - if (divpos == -1) { - unserializer.raiseError("missing : for string", cont); - break; - } - size = parseInt(cont.substring(0, divpos)); - if (size == 0) { - if (cont.length - divpos < 4) { - unserializer.raiseError("string is too short", cont); - break; - } - rest = cont.substring(divpos + 4); - break; - } - if ((cont.length - divpos - size) < 4) { - unserializer.raiseError("string is too short", cont); - break; - } - if (cont.substring(divpos + 2 + size, divpos + 4 + size) != "\";") { - unserializer.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": // integer - case "d": // float - var 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) != ";") { - unserializer.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": // array - if (cont.length < 4) { - unserializer.raiseError("array is too short", cont); - return; - } - divpos = cont.indexOf(":", 1); - if (divpos == -1) { - unserializer.raiseError("missing : for array", cont); - return; - } - size = parseInt(cont.substring(1, divpos - 1)); - cont = cont.substring(divpos + 2); - val = new Array(); - if (cont.length < 1) { - unserializer.raiseError("array is too short", cont); - return; - } - for (var i = 0; i + 1 < size * 2 && !unserializer.error; i += 2) { - kret = unserialize(cont, 1); - if (unserializer.error || kret[0] == undefined || kret[1] == "") { - unserializer.raiseError("missing or invalid key, or missing value for array", cont); - break; - } - vret = unserialize(kret[1], 1); - if (unserializer.error) { - unserializer.raiseError("invalid value for array", cont); - break; - } - val[kret[0]] = vret[0]; - cont = vret[1]; - } - if (unserializer.error) { - return; - } - if (cont.charAt(0) != "}") { - unserializer.raiseError("missing ending }, or too many values for array", cont); - return; - } - rest = cont.substring(1); - break; - case "O": // object - divpos = cont.indexOf(":"); - if (divpos == -1) { - unserializer.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) != "\":") { - unserializer.raiseError("object name is too long, or missing \":", cont); - return; - } - var objprops = unserialize("a:" + cont.substring(divpos + 4 + size), 1); - if (unserializer.error) { - unserializer.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: - unserializer.raiseError("invalid input type", cont); - } - return (arguments.length == 1 ? val : [val, rest]); - } - // }}} - // {{{ gettype - /** - * Returns the type of a variable or its primitive equivalent - * - * @param inp - * the input variable - * @return mixed - * a string as returned by typeof - * @author - * Arpad Ray <arpad@rajeczy.com> - * @version - * 2005/9/29 - */ - gettype: function(inp) { - var type = typeof inp; - if (type == "object") { - var cons = inp.constructor.toString().toLowerCase(); - var types = ["boolean", "number", "string", "array"]; - for (key in types) { - if (cons.indexOf(types[key]) != -1) { - type = types[key]; - break; - } - } - } - return type; - } - // }}} -} -// }}} -function Unserializer() -{ - this.error = 0; - this.message = ""; - this.cont = ""; -} - -Unserializer.prototype.unserialize = function(inp) -{ - this.error = 0; - return unserialize(inp); -} - -Unserializer.prototype.getError = function() -{ - return this.message + "\n" + this.cont; -} - -Unserializer.prototype.raiseError = function(message, cont) -{ - this.error = 1; - this.message = message; - this.cont = cont; -} - +/*************************************************************************** + + These functions can be used to serialize and unserialize data in a + format compatible with PHP's native serialization functions. + + Copyright (C) 2005 Arpad Ray <arpad@rajeczy.com> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to: + Free Software Foundation, Inc., + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +***************************************************************************/ + +// {{{ var HTML_AJAX_Serialize_PHP +var HTML_AJAX_Serializer_PHP = { + + var defaultEncoding = 'UTF-8'; + // {{{ serialize + /** + * 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> + * @version 0.0.2 + */ + serialize: function(inp) { + var type = HTML_AJAX_Serializer_PHP.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] = HTML_AJAX_Serializer_PHP.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 += HTML_AJAX_Serializer_PHP.serialize(okey) + + HTML_AJAX_Serializer_PHP.serialize(inp[key]); + count++; + } + val += ":" + count + ":{" + vals + "}"; + break; + } + if (type != "object" && type != "array") val += ";"; + return val; + } + // }}} + // {{{ unserialize + /** + * Reconstructs a serialized variable + * + * @param mixed inp the string to reconstruct + * @return mixed the variable represented by the input string + * @author Arpad Ray <arpad@rajeczy.com> + * @version 0.0.2 + */ + unserialize: function(inp) { + + if (inp == "" || inp.length < 2) { + unserializer.raiseError("input is too short"); + return; + } + var val, kret, vret, cval; + var type = inp.charAt(0); + var cont = inp.substring(2); + var size = 0; + var divpos = 0; + var endcont = 0; + var rest = ""; + var next = ""; + + switch (type) { + case "N": // null + if (inp.charAt(1) != ";") { + unserializer.raiseError("missing ; for null", cont); + } + // leave val undefined + rest = cont; + break; + case "b": // boolean + if (!/[01];/.test(cont.substring(0,2))) { + unserializer.raiseError("value not 0 or 1, or missing ; for boolean", cont); + } + val = (cont.charAt(0) == "1"); + rest = cont.substring(1); + break; + case "s": // string + val = ""; + divpos = cont.indexOf(":"); + if (divpos == -1) { + unserializer.raiseError("missing : for string", cont); + break; + } + size = parseInt(cont.substring(0, divpos)); + if (size == 0) { + if (cont.length - divpos < 4) { + unserializer.raiseError("string is too short", cont); + break; + } + rest = cont.substring(divpos + 4); + break; + } + if ((cont.length - divpos - size) < 4) { + unserializer.raiseError("string is too short", cont); + break; + } + if (cont.substring(divpos + 2 + size, divpos + 4 + size) != "\";") { + unserializer.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": // integer + case "d": // float + var 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) != ";") { + unserializer.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": // array + if (cont.length < 4) { + unserializer.raiseError("array is too short", cont); + return; + } + divpos = cont.indexOf(":", 1); + if (divpos == -1) { + unserializer.raiseError("missing : for array", cont); + return; + } + size = parseInt(cont.substring(1, divpos - 1)); + cont = cont.substring(divpos + 2); + val = new Array(); + if (cont.length < 1) { + unserializer.raiseError("array is too short", cont); + return; + } + for (var i = 0; i + 1 < size * 2 && !unserializer.error; i += 2) { + kret = unserialize(cont, 1); + if (unserializer.error || kret[0] == undefined || kret[1] == "") { + unserializer.raiseError("missing or invalid key, or missing value for array", cont); + break; + } + vret = unserialize(kret[1], 1); + if (unserializer.error) { + unserializer.raiseError("invalid value for array", cont); + break; + } + val[kret[0]] = vret[0]; + cont = vret[1]; + } + if (unserializer.error) { + return; + } + if (cont.charAt(0) != "}") { + unserializer.raiseError("missing ending }, or too many values for array", cont); + return; + } + rest = cont.substring(1); + break; + case "O": // object + divpos = cont.indexOf(":"); + if (divpos == -1) { + unserializer.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) != "\":") { + unserializer.raiseError("object name is too long, or missing \":", cont); + return; + } + var objprops = unserialize("a:" + cont.substring(divpos + 4 + size), 1); + if (unserializer.error) { + unserializer.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: + unserializer.raiseError("invalid input type", cont); + } + return (arguments.length == 1 ? val : [val, rest]); + } + // }}} + // {{{ gettype + /** + * Returns the type of a variable or its primitive equivalent + * + * @param inp + * the input variable + * @return mixed + * a string as returned by typeof + * @author + * Arpad Ray <arpad@rajeczy.com> + * @version + * 2005/9/29 + */ + gettype: function(inp) { + var type = typeof inp; + if (type == "object") { + var cons = inp.constructor.toString().toLowerCase(); + var types = ["boolean", "number", "string", "array"]; + for (key in types) { + if (cons.indexOf(types[key]) != -1) { + type = types[key]; + break; + } + } + } + return type; + } + // }}} +} +// }}} +function Unserializer() +{ + this.error = 0; + this.message = ""; + this.cont = ""; +} + +Unserializer.prototype.unserialize = function(inp) +{ + this.error = 0; + return unserialize(inp); +} + +Unserializer.prototype.getError = function() +{ + return this.message + "\n" + this.cont; +} + +Unserializer.prototype.raiseError = function(message, cont) +{ + this.error = 1; + this.message = message; + this.cont = cont; +} + http://cvs.php.net/diff.php/pear/HTML_AJAX/js/util.js?r1=1.2&r2=1.3&ty=u Index: pear/HTML_AJAX/js/util.js diff -u pear/HTML_AJAX/js/util.js:1.2 pear/HTML_AJAX/js/util.js:1.3 --- pear/HTML_AJAX/js/util.js:1.2 Mon Oct 24 23:26:14 2005 +++ pear/HTML_AJAX/js/util.js Mon Nov 7 13:41:39 2005 @@ -1,45 +1,49 @@ -/** - * Utility methods - * - * @category HTML - * @package Ajax - * @author David Coallier <davidc@php.net> - * @copyright 2005 David Coallier - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - */ -// {{{ HTML_AJAX_Util -/** - * All the utilities we will be using thorough the classes - */ -var HTML_AJAX_Util = { - // Set the element event - setElementEvent: function(id, event, handler) { - var element = document.getElementById(id); - if (typeof element.addEventListener != "undefined") { //Dom2 - element.addEventListener(event, handler, false); - } else if (typeof element.attachEvent != "undefined") { //IE 5+ - element.attachEvent("on" + event, handler); - } else { - if (element["on" + event] != null) { - var oldHandler = element["on" + event]; - element["on" + event] = function(e) { - oldHander(e); - handler(e); - }; - } else { - element["on" + event] = handler; - } - } - }, - // simple non recursive variable dumper, don't rely on its output staying the same, its just for debugging and will get smarter at some point - varDump: function(input) { - var r = ""; - for(var i in input) { - r += i+':'+input[i]+"\n"; - } - return r; - } - -} -// }}} -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +/** + * Utility methods + * + * @category HTML + * @package Ajax + * @author David Coallier <davidc@php.net> + * @copyright 2005 David Coallier + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + */ +// {{{ HTML_AJAX_Util +/** + * All the utilities we will be using thorough the classes + */ +var HTML_AJAX_Util = { + // Set the element event + registerEvent: function(element, event, handler) { + //var element = document.getElementById(id); + if (typeof element.addEventListener != "undefined") { //Dom2 + element.addEventListener(event, handler, false); + } else if (typeof element.attachEvent != "undefined") { //IE 5+ + element.attachEvent("on" + event, handler); + } else { + if (element["on" + event] != null) { + var oldHandler = element["on" + event]; + element["on" + event] = function(e) { + oldHander(e); + handler(e); + }; + } else { + element["on" + event] = handler; + } + } + }, + // simple non recursive variable dumper, don't rely on its output staying the same, its just for debugging and will get smarter at some point + varDump: function(input) { + var r = ""; + for(var i in input) { + r += i+':'+input[i]+"\n"; + } + return r; + }, + getElementsByClassName: function(className, parentElement) { + var children = ($(parentElement) || document.body).getElementsByTagName('*'); + for(var i =0; i < children.length; i++) { + } + } +} +// }}} +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
http://cvs.php.net/diff.php/pear/HTML_AJAX/js/Dispatcher.js?r1=1.5&r2=1.6&ty=u Index: pear/HTML_AJAX/js/Dispatcher.js diff -u pear/HTML_AJAX/js/Dispatcher.js:1.5 pear/HTML_AJAX/js/Dispatcher.js:1.6 --- pear/HTML_AJAX/js/Dispatcher.js:1.5 Mon Oct 24 23:26:13 2005 +++ pear/HTML_AJAX/js/Dispatcher.js Mon Nov 7 13:41:38 2005 @@ -1,71 +1,85 @@ -/** - * 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, - - /** - * 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; - - 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); - } -}; -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +/** + * 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, + + /** + * 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; + + 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; + } + } + +}; +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ http://cvs.php.net/diff.php/pear/HTML_AJAX/js/HTML_AJAX.js?r1=1.4&r2=1.5&ty=u Index: pear/HTML_AJAX/js/HTML_AJAX.js diff -u pear/HTML_AJAX/js/HTML_AJAX.js:1.4 pear/HTML_AJAX/js/HTML_AJAX.js:1.5 --- pear/HTML_AJAX/js/HTML_AJAX.js:1.4 Mon Oct 24 23:26:13 2005 +++ pear/HTML_AJAX/js/HTML_AJAX.js Mon Nov 7 13:41:39 2005 @@ -272,375 +272,393 @@ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ // 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, - - /** - * 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; - - 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); - } -}; -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +/** + * 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, + + /** + * 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; + + 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; + } + } + +}; +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ // 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 object - request: null, - - // timeout id - _timeoutId: null, - - // method to initialize an xmlhttpclient - init:function() - { - try { - // Mozilla / Safari - this.xmlhttp = new XMLHttpRequest(); - } catch (e) { - // IE - 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) { - throw new Error('Unable to create XMLHttpRequest.'); - } - } - }, - - // check if there is a call in progress - callInProgress: function() - { - switch ( this.xmlhttp.readyState ) { - case 1: - case 2: - case 3: - return true; - break; - default: - return false; - break; - } - }, - - // make the request defined in the request object - makeRequest: function() - { - if (!this.xmlhttp) { - this.init(); - } - - try { - if (this.request.onOpen) { - this.request.onOpen(); - } - else if (HTML_AJAX.onOpen) { - HTML_AJAX.onOpen(this.request); - } - this.xmlhttp.open(this.request.requestType,this.request.completeUrl(),this.request.isAsync); - - // set onreadystatechange here since it will be reset after a completed call in Mozilla - var self = this; - this.xmlhttp.onreadystatechange = function() { self._readyStateChangeCallback(); } - - this.xmlhttp.setRequestHeader('Content-Type',this.request.getContentType()); - var payload = this.request.getSerializedPayload(); - if (payload) { - this.xmlhttp.setRequestHeader('Content-Length', payload.length); - } - this.xmlhttp.send(payload); - } catch (e) { - this._handleError(e); - } - - if (!this.request.isAsync) { - if ( this.xmlhttp.status == 200 ) { - HTML_AJAX.requestComplete(this.request); - if (this.request.onLoad) { - this.request.onLoad(); - } else if (HTML_AJAX.onLoad) { - HTML_AJAX.onLoad(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 { - // setup timeout - var self = this; - this._timeoutId = window.setTimeout(function() { self.abort(true); },this.request.timeout); - } - }, - - // abort an inprogress request - abort: function (automatic) - { - if (this.callInProgress()) { - this.xmlhttp.abort(); - - if (automatic) { - this._handleError(new Error('Request Timed Out')); - } - } - }, - - // internal method used to handle ready state changes - _readyStateChangeCallback:function() - { - try { - switch(this.xmlhttp.readyState) { - // XMLHTTPRequest.open() has just been called - case 1: - break; - // XMLHTTPRequest.send() has just been called - case 2: - if (this.request.onSend) { - this.request.onSend(); - } else if (HTML_AJAX.onSend) { - HTML_AJAX.onSend(this.request); - } - break; - // Fetching response from server in progress - case 3: - if (this.request.onProgress) { - this.request.onProgress(); - } else if (HTML_AJAX.onProgress ) { - HTML_AJAX.onProgress(this.request); - } - break; - // Download complete - case 4: - window.clearTimeout(this._timeout_id); - - if (this.xmlhttp.status == 200) { - HTML_AJAX.requestComplete(this.request); - if (this.request.onLoad) { - this.request.onLoad(); - } else if (HTML_AJAX.onLoad ) { - HTML_AJAX.onLoad(this.request); - } - - if (this.request.callback) { - this.request.callback(this._decodeResponse()); - } - } - - else { - var e = new Error('HTTP Error Making Request: ['+this.xmlhttp.status+'] '+this.xmlhttp.statusText); - this._handleError(e); - } - break; - } - } catch (e) { - this._handleError(e); - } - }, - - // decode response as needed - _decodeResponse: function() { - var unserializer = HTML_AJAX.serializerForEncoding(this.xmlhttp.getResponseHeader('Content-Type')); - //alert(this.xmlhttp.responseText); // some sort of debug hook is needed here - - // some sort of sane way for a serializer to ask for XML needs to be added - return unserializer.unserialize(this.xmlhttp.responseText); - }, - - // handle sending an error where it needs to go - _handleError: function(e) - { - HTML_AJAX.requestComplete(this.request,e); - if (this.request.onError) { - this.request.onError(e); - } else if (HTML_AJAX.onError) { - HTML_AJAX.onError(e,this.request); - } - else { - throw e; - } - } -} -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +/** + * 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 object + request: null, + + // timeout id + _timeoutId: null, + + // method to initialize an xmlhttpclient + init:function() + { + try { + // Mozilla / Safari + this.xmlhttp = new XMLHttpRequest(); + } catch (e) { + // IE + 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) { + throw new Error('Unable to create XMLHttpRequest.'); + } + } + }, + + // check if there is a call in progress + callInProgress: function() + { + switch ( this.xmlhttp.readyState ) { + case 1: + case 2: + case 3: + return true; + break; + default: + return false; + break; + } + }, + + // make the request defined in the request object + makeRequest: function() + { + if (!this.xmlhttp) { + this.init(); + } + + try { + if (this.request.onOpen) { + this.request.onOpen(); + } + else if (HTML_AJAX.onOpen) { + HTML_AJAX.onOpen(this.request); + } + this.xmlhttp.open(this.request.requestType,this.request.completeUrl(),this.request.isAsync); + + // set onreadystatechange here since it will be reset after a completed call in Mozilla + var self = this; + this.xmlhttp.onreadystatechange = function() { self._readyStateChangeCallback(); } + + this.xmlhttp.setRequestHeader('Content-Type',this.request.getContentType()); + var payload = this.request.getSerializedPayload(); + if (payload) { + this.xmlhttp.setRequestHeader('Content-Length', payload.length); + } + this.xmlhttp.send(payload); + } catch (e) { + this._handleError(e); + } + + if (!this.request.isAsync) { + if ( this.xmlhttp.status == 200 ) { + HTML_AJAX.requestComplete(this.request); + if (this.request.onLoad) { + this.request.onLoad(); + } else if (HTML_AJAX.onLoad) { + HTML_AJAX.onLoad(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 { + // setup timeout + var self = this; + this._timeoutId = window.setTimeout(function() { self.abort(true); },this.request.timeout); + } + }, + + // abort an inprogress request + abort: function (automatic) + { + if (this.callInProgress()) { + this.xmlhttp.abort(); + + if (automatic) { + this._handleError(new Error('Request Timed Out')); + } + } + }, + + // internal method used to handle ready state changes + _readyStateChangeCallback:function() + { + try { + switch(this.xmlhttp.readyState) { + // XMLHTTPRequest.open() has just been called + case 1: + break; + // XMLHTTPRequest.send() has just been called + case 2: + if (this.request.onSend) { + this.request.onSend(); + } else if (HTML_AJAX.onSend) { + HTML_AJAX.onSend(this.request); + } + break; + // Fetching response from server in progress + case 3: + if (this.request.onProgress) { + this.request.onProgress(); + } else if (HTML_AJAX.onProgress ) { + HTML_AJAX.onProgress(this.request); + } + break; + // Download complete + case 4: + window.clearTimeout(this._timeout_id); + + if (this.xmlhttp.status == 200) { + HTML_AJAX.requestComplete(this.request); + if (this.request.onLoad) { + this.request.onLoad(); + } else if (HTML_AJAX.onLoad ) { + HTML_AJAX.onLoad(this.request); + } + + if (this.request.callback) { + this.request.callback(this._decodeResponse()); + } + } + + else { + var e = new Error('HTTP Error Making Request: ['+this.xmlhttp.status+'] '+this.xmlhttp.statusText); + this._handleError(e); + } + break; + } + } catch (e) { + this._handleError(e); + } + }, + + // decode response as needed + _decodeResponse: function() { + var unserializer = HTML_AJAX.serializerForEncoding(this.xmlhttp.getResponseHeader('Content-Type')); + //alert(this.xmlhttp.responseText); // some sort of debug hook is needed here + + // some sort of sane way for a serializer to ask for XML needs to be added + return unserializer.unserialize(this.xmlhttp.responseText); + }, + + // handle sending an error where it needs to go + _handleError: function(e) + { + HTML_AJAX.requestComplete(this.request,e); + if (this.request.onError) { + this.request.onError(e); + } else if (HTML_AJAX.onError) { + HTML_AJAX.onError(e,this.request); + } + else { + throw e; + } + } +} +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ // Request.js -/** - * Class that contains everything needed to make a request - * This includes: - * The url were calling - * If were calling a remote method, the class and method name - * The payload, unserialized - * The timeout for async calls - * The callback method - * Optional event handlers: onError, onLoad, onSend - * A serializer instance - * - * @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_Request(serializer) { - this.serializer = serializer; -} -HTML_AJAX_Request.prototype = { - - // Instance of a serializer - serializer: null, - - // Is this an async request - isAsync: false, - - // HTTP verb - requestType: 'POST', - - // The actual URL the request is sent to - requestUrl: '', - - // Remote Class - className: null, - - // Remote Method - methodName: null, - - // Timeout in milliseconds for requests - timeout: 20000, - - // unserialized data, for rpc calls use add args, to send raw data just set this directly - args: null, - - // async callback method - callback: null, - - // Queue to push this request too - queue: 'default', - - /** - * Add an argument for the remote method - * @param string argument name - * @param mixed value - * @return void - * @throws Error code 1004 - */ - addArg: function(name, value) - { - if ( !this.args ) { - this.args = []; - } - if (!/[^a-zA-Z_0-9]/.test(name) ) { - this.args[name] = value; - } else { - throw new Error('Invalid parameter name ('+name+')'); - } - }, - - /** - * Get the payload in a serialized manner - */ - getSerializedPayload: function() { - return this.serializer.serialize(this.args); - }, - - /** - * Get the content type - */ - getContentType: function() { - return this.serializer.contentType; - }, - - /** - * Get the complete url, adding in any needed get params for rpc - */ - completeUrl: function() { - var url = this.requestUrl; - if (this.className || this.methodName) { - url += '?c='+escape(this.className)+'&m='+escape(this.methodName); - } - return url; - } -} -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +/** + * Class that contains everything needed to make a request + * This includes: + * The url were calling + * If were calling a remote method, the class and method name + * The payload, unserialized + * The timeout for async calls + * The callback method + * Optional event handlers: onError, onLoad, onSend + * A serializer instance + * + * @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_Request(serializer) { + this.serializer = serializer; +} +HTML_AJAX_Request.prototype = { + + // Instance of a serializer + serializer: null, + + // Is this an async request + isAsync: false, + + // HTTP verb + requestType: 'POST', + + // The actual URL the request is sent to + requestUrl: '', + + // Remote Class + className: null, + + // Remote Method + methodName: null, + + // Timeout in milliseconds for requests + timeout: 20000, + + // unserialized data, for rpc calls use add args, to send raw data just set this directly + args: null, + + // async callback method + callback: null, + + // Queue to push this request too + queue: 'default', + + /** + * Add an argument for the remote method + * @param string argument name + * @param mixed value + * @return void + * @throws Error code 1004 + */ + addArg: function(name, value) + { + if ( !this.args ) { + this.args = []; + } + if (!/[^a-zA-Z_0-9]/.test(name) ) { + this.args[name] = value; + } else { + throw new Error('Invalid parameter name ('+name+')'); + } + }, + + /** + * Get the payload in a serialized manner + */ + getSerializedPayload: function() { + return this.serializer.serialize(this.args); + }, + + /** + * Get the content type + */ + getContentType: function() { + return this.serializer.contentType; + }, + + /** + * Get the complete url, adding in any needed get params for rpc + */ + completeUrl: function() { + var url = new String(this.requestUrl); + var delimiter = '?'; + if (url.indexOf('?') >= 0) { + delimiter = '&'; + } + if (this.className || this.methodName) { + url += delimiter+'c='+escape(this.className)+'&m='+escape(this.methodName); + } + return url; + } +} +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ // JSON.js /* Copyright (c) 2005 JSON.org @@ -984,90 +1002,90 @@ }; /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ // Loading.js -/** - * Default loading implementation - * - * @category HTML - * @package Ajax - * @author Joshua Eichorn <josh@bluga.net> - * @copyright 2005 Joshua Eichorn - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - */ - -HTML_AJAX.onOpen = function(request) { - var loading = document.getElementById('HTML_AJAX_LOADING'); - if (!loading) { - loading = document.createElement('div'); - loading.id = 'HTML_AJAX_LOADING'; - loading.innerHTML = 'Loading...'; - loading.style.position = 'absolute'; - loading.style.top = 0; - loading.style.right = 0; - loading.style.backgroundColor = 'red'; - loading.style.width = '80px'; - loading.style.padding = '4px'; - - document.body.insertBefore(loading,document.body.firstChild); - } - HTML_AJAX.onOpen_Timeout = window.setTimeout(function() { loading.style.display = 'block'; },500); -} -HTML_AJAX.onLoad = function(request) { - if (HTML_AJAX.onOpen_Timeout) { - window.clearTimeout(HTML_AJAX.onOpen_Timeout); - HTML_AJAX.onOpen_Timeout = false; - } - var loading = document.getElementById('HTML_AJAX_LOADING'); - if (loading) { - loading.style.display = 'none'; - } -} -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +/** + * Default loading implementation + * + * @category HTML + * @package Ajax + * @author Joshua Eichorn <josh@bluga.net> + * @copyright 2005 Joshua Eichorn + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + */ + +HTML_AJAX.onOpen = function(request) { + var loading = document.getElementById('HTML_AJAX_LOADING'); + if (!loading) { + loading = document.createElement('div'); + loading.id = 'HTML_AJAX_LOADING'; + loading.innerHTML = 'Loading...'; + loading.style.position = 'absolute'; + loading.style.top = 0; + loading.style.right = 0; + loading.style.backgroundColor = 'red'; + loading.style.width = '80px'; + loading.style.padding = '4px'; + + document.body.insertBefore(loading,document.body.firstChild); + } + HTML_AJAX.onOpen_Timeout = window.setTimeout(function() { loading.style.display = 'block'; },500); +} +HTML_AJAX.onLoad = function(request) { + if (HTML_AJAX.onOpen_Timeout) { + window.clearTimeout(HTML_AJAX.onOpen_Timeout); + HTML_AJAX.onOpen_Timeout = false; + } + var loading = document.getElementById('HTML_AJAX_LOADING'); + if (loading) { + loading.style.display = 'none'; + } +} +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ // util.js -/** - * Utility methods - * - * @category HTML - * @package Ajax - * @author David Coallier <davidc@php.net> - * @copyright 2005 David Coallier - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - */ -// {{{ HTML_AJAX_Util -/** - * All the utilities we will be using thorough the classes - */ -var HTML_AJAX_Util = { - // Set the element event - setElementEvent: function(id, event, handler) { - var element = document.getElementById(id); - if (typeof element.addEventListener != "undefined") { //Dom2 - element.addEventListener(event, handler, false); - } else if (typeof element.attachEvent != "undefined") { //IE 5+ - element.attachEvent("on" + event, handler); - } else { - if (element["on" + event] != null) { - var oldHandler = element["on" + event]; - element["on" + event] = function(e) { - oldHander(e); - handler(e); - }; - } else { - element["on" + event] = handler; - } - } - }, - // simple non recursive variable dumper, don't rely on its output staying the same, its just for debugging and will get smarter at some point - varDump: function(input) { - var r = ""; - for(var i in input) { - r += i+':'+input[i]+"\n"; - } - return r; - } - -} -// }}} -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +/** + * Utility methods + * + * @category HTML + * @package Ajax + * @author David Coallier <davidc@php.net> + * @copyright 2005 David Coallier + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + */ +// {{{ HTML_AJAX_Util +/** + * All the utilities we will be using thorough the classes + */ +var HTML_AJAX_Util = { + // Set the element event + setElementEvent: function(id, event, handler) { + var element = document.getElementById(id); + if (typeof element.addEventListener != "undefined") { //Dom2 + element.addEventListener(event, handler, false); + } else if (typeof element.attachEvent != "undefined") { //IE 5+ + element.attachEvent("on" + event, handler); + } else { + if (element["on" + event] != null) { + var oldHandler = element["on" + event]; + element["on" + event] = function(e) { + oldHander(e); + handler(e); + }; + } else { + element["on" + event] = handler; + } + } + }, + // simple non recursive variable dumper, don't rely on its output staying the same, its just for debugging and will get smarter at some point + varDump: function(input) { + var r = ""; + for(var i in input) { + r += i+':'+input[i]+"\n"; + } + return r; + } + +} +// }}} +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ // behavior.js /** @@ -1170,9 +1188,9 @@ } Behavior.start();// cssQuery-p.js -/* - cssQuery, version 2.0.2 (2005-08-19) - Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) - License: http://creativecommons.org/licenses/LGPL/2.1/ -*/ -eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('7 x=6(){7 1D="2.0.2";7 C=/\\s*,\\s*/;7 x=6(s,A){33{7 m=[];7 u=1z.32.2c&&!A;7 b=(A)?(A.31==22)?A:[A]:[1g];7 1E=18(s).1l(C),i;9(i=0;i<1E.y;i++){s=1y(1E[i]);8(U&&s.Z(0,3).2b("")==" *#"){s=s.Z(2);A=24([],b,s[1])}1A A=b;7 j=0,t,f,a,c="";H(j<s.y){t=s[j++];f=s[j++];c+=t+f;a="";8(s[j]=="("){H(s[j++]!=")")a+=s[j];a=a.Z(0,-1);c+="("+a+")"}A=(u&&V[c])?V[c]:21(A,t,f,a);8(u)V[c]=A}m=m.30(A)}2a x.2d;5 m}2Z(e){x.2d=e;5[]}};x.1Z=6(){5"6 x() {\\n [1D "+1D+"]\\n}"};7 V={};x.2c=L;x.2Y=6(s){8(s){s=1y(s).2b("");2a V[s]}1A V={}};7 29={};7 19=L;x.15=6(n,s){8(19)1i("s="+1U(s));29[n]=12 s()};x.2X=6(c){5 c?1i(c):o};7 D={};7 h={};7 q={P:/\\[([\\w-]+(\\|[\\w-]+)?)\\s*(\\W?=)?\\s*([^\\]]*)\\]/};7 T=[];D[" "]=6(r,f,t,n){7 e,i,j;9(i=0;i<f.y;i++){7 s=X(f[i],t,n);9(j=0;(e=s[j]);j++){8(M(e)&&14(e,n))r.z(e)}}};D["#"]=6(r,f,i){7 e,j;9(j=0;(e=f[j]);j++)8(e.B==i)r.z(e)};D["."]=6(r,f,c){c=12 1t("(^|\\\\s)"+c+"(\\\\s|$)");7 e,i;9(i=0;(e=f[i]);i++)8(c.l(e.1V))r.z(e)};D[":"]=6(r,f,p,a){7 t=h[p],e,i;8(t)9(i=0;(e=f[i]);i++)8(t(e,a))r.z(e)};h["2W"]=6(e){7 d=Q(e);8(d.1C)9(7 i=0;i<d.1C.y;i++){8(d.1C[i]==e)5 K}};h["2V"]=6(e){};7 M=6(e){5(e&&e.1c==1&&e.1f!="!")?e:23};7 16=6(e){H(e&&(e=e.2U)&&!M(e))28;5 e};7 G=6(e){H(e&&(e=e.2T)&&!M(e))28;5 e};7 1r=6(e){5 M(e.27)||G(e.27)};7 1P=6(e){5 M(e.26)||16(e.26)};7 1o=6(e){7 c=[];e=1r(e);H(e){c.z(e);e=G(e)}5 c};7 U=K;7 1h=6(e){7 d=Q(e);5(2S d.25=="2R")?/\\.1J$/i.l(d.2Q):2P(d.25=="2O 2N")};7 Q=6(e){5 e.2M||e.1g};7 X=6(e,t){5(t=="*"&&e.1B)?e.1B:e.X(t)};7 17=6(e,t,n){8(t=="*")5 M(e);8(!14(e,n))5 L;8(!1h(e))t=t.2L();5 e.1f==t};7 14=6(e,n){5!n||(n=="*")||(e.2K==n)};7 1e=6(e){5 e.1G};6 24(r,f,B){7 m,i,j;9(i=0;i<f.y;i++){8(m=f[i].1B.2J(B)){8(m.B==B)r.z(m);1A 8(m.y!=23){9(j=0;j<m.y;j++){8(m[j].B==B)r.z(m[j])}}}}5 r};8(![].z)22.2I.z=6(){9(7 i=0;i<1z.y;i++){o[o.y]=1z[i]}5 o.y};7 N=/\\|/;6 21(A,t,f,a){8(N.l(f)){f=f.1l(N);a=f[0];f=f[1]}7 r=[];8(D[t]){D[t](r,A,f,a)}5 r};7 S=/^[^\\s>+~]/;7 20=/[\\s#.:>+~()@]|[^\\s#.:>+~()@]+/g;6 1y(s){8(S.l(s))s=" "+s;5 s.P(20)||[]};7 W=/\\s*([\\s>+~(),]|^|$)\\s*/g;7 I=/([\\s>+~,]|[^(]\\+|^)([#.:@])/g;7 18=6(s){5 s.O(W,"$1").O(I,"$1*$2")};7 1u={1Z:6(){5"\'"},P:/^(\'[^\']*\')|("[^"]*")$/,l:6(s){5 o.P.l(s)},1S:6(s){5 o.l(s)?s:o+s+o},1Y:6(s){5 o.l(s)?s.Z(1,-1):s}};7 1s=6(t){5 1u.1Y(t)};7 E=/([\\/()[\\]?{}|*+-])/g;6 R(s){5 s.O(E,"\\\\$1")};x.15("1j-2H",6(){D[">"]=6(r,f,t,n){7 e,i,j;9(i=0;i<f.y;i++){7 s=1o(f[i]);9(j=0;(e=s[j]);j++)8(17(e,t,n))r.z(e)}};D["+"]=6(r,f,t,n){9(7 i=0;i<f.y;i++){7 e=G(f[i]);8(e&&17(e,t,n))r.z(e)}};D["@"]=6(r,f,a){7 t=T[a].l;7 e,i;9(i=0;(e=f[i]);i++)8(t(e))r.z(e)};h["2G-10"]=6(e){5!16(e)};h["1x"]=6(e,c){c=12 1t("^"+c,"i");H(e&&!e.13("1x"))e=e.1n;5 e&&c.l(e.13("1x"))};q.1X=/\\\\:/g;q.1w="@";q.J={};q.O=6(m,a,n,c,v){7 k=o.1w+m;8(!T[k]){a=o.1W(a,c||"",v||"");T[k]=a;T.z(a)}5 T[k].B};q.1Q=6(s){s=s.O(o.1X,"|");7 m;H(m=s.P(o.P)){7 r=o.O(m[0],m[1],m[2],m[3],m[4]);s=s.O(o.P,r)}5 s};q.1W=6(p,t,v){7 a={};a.B=o.1w+T.y;a.2F=p;t=o.J[t];t=t?t(o.13(p),1s(v)):L;a.l=12 2E("e","5 "+t);5 a};q.13=6(n){1d(n.2D()){F"B":5"e.B";F"2C":5"e.1V";F"9":5"e.2B";F"1T":8(U){5"1U((e.2A.P(/1T=\\\\1v?([^\\\\s\\\\1v]*)\\\\1v?/)||[])[1]||\'\')"}}5"e.13(\'"+n.O(N,":")+"\')"};q.J[""]=6(a){5 a};q.J["="]=6(a,v){5 a+"=="+1u.1S(v)};q.J["~="]=6(a,v){5"/(^| )"+R(v)+"( |$)/.l("+a+")"};q.J["|="]=6(a,v){5"/^"+R(v)+"(-|$)/.l("+a+")"};7 1R=18;18=6(s){5 1R(q.1Q(s))}});x.15("1j-2z",6(){D["~"]=6(r,f,t,n){7 e,i;9(i=0;(e=f[i]);i++){H(e=G(e)){8(17(e,t,n))r.z(e)}}};h["2y"]=6(e,t){t=12 1t(R(1s(t)));5 t.l(1e(e))};h["2x"]=6(e){5 e==Q(e).1H};h["2w"]=6(e){7 n,i;9(i=0;(n=e.1F[i]);i++){8(M(n)||n.1c==3)5 L}5 K};h["1N-10"]=6(e){5!G(e)};h["2v-10"]=6(e){e=e.1n;5 1r(e)==1P(e)};h["2u"]=6(e,s){7 n=x(s,Q(e));9(7 i=0;i<n.y;i++){8(n[i]==e)5 L}5 K};h["1O-10"]=6(e,a){5 1p(e,a,16)};h["1O-1N-10"]=6(e,a){5 1p(e,a,G)};h["2t"]=6(e){5 e.B==2s.2r.Z(1)};h["1M"]=6(e){5 e.1M};h["2q"]=6(e){5 e.1q===L};h["1q"]=6(e){5 e.1q};h["1L"]=6(e){5 e.1L};q.J["^="]=6(a,v){5"/^"+R(v)+"/.l("+a+")"};q.J["$="]=6(a,v){5"/"+R(v)+"$/.l("+a+")"};q.J["*="]=6(a,v){5"/"+R(v)+"/.l("+a+")"};6 1p(e,a,t){1d(a){F"n":5 K;F"2p":a="2n";1a;F"2o":a="2n+1"}7 1m=1o(e.1n);6 1k(i){7 i=(t==G)?1m.y-i:i-1;5 1m[i]==e};8(!Y(a))5 1k(a);a=a.1l("n");7 m=1K(a[0]);7 s=1K(a[1]);8((Y(m)||m==1)&&s==0)5 K;8(m==0&&!Y(s))5 1k(s);8(Y(s))s=0;7 c=1;H(e=t(e))c++;8(Y(m)||m==1)5(t==G)?(c<=s):(s>=c);5(c%m)==s}});x.15("1j-2m",6(){U=1i("L;/*@2l@8(@\\2k)U=K@2j@*/");8(!U){X=6(e,t,n){5 n?e.2i("*",t):e.X(t)};14=6(e,n){5!n||(n=="*")||(e.2h==n)};1h=1g.1I?6(e){5/1J/i.l(Q(e).1I)}:6(e){5 Q(e).1H.1f!="2g"};1e=6(e){5 e.2f||e.1G||1b(e)};6 1b(e){7 t="",n,i;9(i=0;(n=e.1F[i]);i++){1d(n.1c){F 11:F 1:t+=1b(n);1a;F 3:t+=n.2e;1a}}5 t}}});19=K;5 x}();',62,190,'|||||return|function|var|if|for||||||||pseudoClasses||||test|||this||AttributeSelector|||||||cssQuery|length|push|fr|id||selectors||case|nextElementSibling|while||tests|true|false|thisElement||replace|match|getDocument|regEscape||attributeSelectors|isMSIE|cache||getElementsByTagName|isNaN|slice|child||new|getAttribute|compareNamespace|addModule|previousElementSibling|compareTagName|parseSelector|loaded|break|_0|nodeType|switch|getTextContent|tagName|document|isXML|eval|css|_1|split|ch|parentNode|childElements|nthChild|disabled|firstElementChild|getText|RegExp|Quote|x22|PREFIX|lang|_2|arguments|else|all|links|version|se|childNodes|innerText|documentElement|contentType|xml|parseInt|indeterminate|checked|last|nth|lastElementChild|parse|_3|add|href|String|className|create|NS_IE|remove|toString|ST|select|Array|null|_4|mimeType|lastChild|firstChild|continue|modules|delete|join|caching|error|nodeValue|textContent|HTML|prefix|getElementsByTagNameNS|end|x5fwin32|cc_on|standard||odd|even|enabled|hash|location|target|not|only|empty|root|contains|level3|outerHTML|htmlFor|class|toLowerCase|Function|name|first|level2|prototype|item|scopeName|toUpperCase|ownerDocument|Document|XML|Boolean|URL|unknown|typeof|nextSibling|previousSibling|visited|link|valueOf|clearCache|catch|concat|constructor|callee|try'.split('|'),0,{})) +/* + cssQuery, version 2.0.2 (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ +eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('7 x=6(){7 1D="2.0.2";7 C=/\\s*,\\s*/;7 x=6(s,A){33{7 m=[];7 u=1z.32.2c&&!A;7 b=(A)?(A.31==22)?A:[A]:[1g];7 1E=18(s).1l(C),i;9(i=0;i<1E.y;i++){s=1y(1E[i]);8(U&&s.Z(0,3).2b("")==" *#"){s=s.Z(2);A=24([],b,s[1])}1A A=b;7 j=0,t,f,a,c="";H(j<s.y){t=s[j++];f=s[j++];c+=t+f;a="";8(s[j]=="("){H(s[j++]!=")")a+=s[j];a=a.Z(0,-1);c+="("+a+")"}A=(u&&V[c])?V[c]:21(A,t,f,a);8(u)V[c]=A}m=m.30(A)}2a x.2d;5 m}2Z(e){x.2d=e;5[]}};x.1Z=6(){5"6 x() {\\n [1D "+1D+"]\\n}"};7 V={};x.2c=L;x.2Y=6(s){8(s){s=1y(s).2b("");2a V[s]}1A V={}};7 29={};7 19=L;x.15=6(n,s){8(19)1i("s="+1U(s));29[n]=12 s()};x.2X=6(c){5 c?1i(c):o};7 D={};7 h={};7 q={P:/\\[([\\w-]+(\\|[\\w-]+)?)\\s*(\\W?=)?\\s*([^\\]]*)\\]/};7 T=[];D[" "]=6(r,f,t,n){7 e,i,j;9(i=0;i<f.y;i++){7 s=X(f[i],t,n);9(j=0;(e=s[j]);j++){8(M(e)&&14(e,n))r.z(e)}}};D["#"]=6(r,f,i){7 e,j;9(j=0;(e=f[j]);j++)8(e.B==i)r.z(e)};D["."]=6(r,f,c){c=12 1t("(^|\\\\s)"+c+"(\\\\s|$)");7 e,i;9(i=0;(e=f[i]);i++)8(c.l(e.1V))r.z(e)};D[":"]=6(r,f,p,a){7 t=h[p],e,i;8(t)9(i=0;(e=f[i]);i++)8(t(e,a))r.z(e)};h["2W"]=6(e){7 d=Q(e);8(d.1C)9(7 i=0;i<d.1C.y;i++){8(d.1C[i]==e)5 K}};h["2V"]=6(e){};7 M=6(e){5(e&&e.1c==1&&e.1f!="!")?e:23};7 16=6(e){H(e&&(e=e.2U)&&!M(e))28;5 e};7 G=6(e){H(e&&(e=e.2T)&&!M(e))28;5 e};7 1r=6(e){5 M(e.27)||G(e.27)};7 1P=6(e){5 M(e.26)||16(e.26)};7 1o=6(e){7 c=[];e=1r(e);H(e){c.z(e);e=G(e)}5 c};7 U=K;7 1h=6(e){7 d=Q(e);5(2S d.25=="2R")?/\\.1J$/i.l(d.2Q):2P(d.25=="2O 2N")};7 Q=6(e){5 e.2M||e.1g};7 X=6(e,t){5(t=="*"&&e.1B)?e.1B:e.X(t)};7 17=6(e,t,n){8(t=="*")5 M(e);8(!14(e,n))5 L;8(!1h(e))t=t.2L();5 e.1f==t};7 14=6(e,n){5!n||(n=="*")||(e.2K==n)};7 1e=6(e){5 e.1G};6 24(r,f,B){7 m,i,j;9(i=0;i<f.y;i++){8(m=f[i].1B.2J(B)){8(m.B==B)r.z(m);1A 8(m.y!=23){9(j=0;j<m.y;j++){8(m[j].B==B)r.z(m[j])}}}}5 r};8(![].z)22.2I.z=6(){9(7 i=0;i<1z.y;i++){o[o.y]=1z[i]}5 o.y};7 N=/\\|/;6 21(A,t,f,a){8(N.l(f)){f=f.1l(N);a=f[0];f=f[1]}7 r=[];8(D[t]){D[t](r,A,f,a)}5 r};7 S=/^[^\\s>+~]/;7 20=/[\\s#.:>+~()@]|[^\\s#.:>+~()@]+/g;6 1y(s){8(S.l(s))s=" "+s;5 s.P(20)||[]};7 W=/\\s*([\\s>+~(),]|^|$)\\s*/g;7 I=/([\\s>+~,]|[^(]\\+|^)([#.:@])/g;7 18=6(s){5 s.O(W,"$1").O(I,"$1*$2")};7 1u={1Z:6(){5"\'"},P:/^(\'[^\']*\')|("[^"]*")$/,l:6(s){5 o.P.l(s)},1S:6(s){5 o.l(s)?s:o+s+o},1Y:6(s){5 o.l(s)?s.Z(1,-1):s}};7 1s=6(t){5 1u.1Y(t)};7 E=/([\\/()[\\]?{}|*+-])/g;6 R(s){5 s.O(E,"\\\\$1")};x.15("1j-2H",6(){D[">"]=6(r,f,t,n){7 e,i,j;9(i=0;i<f.y;i++){7 s=1o(f[i]);9(j=0;(e=s[j]);j++)8(17(e,t,n))r.z(e)}};D["+"]=6(r,f,t,n){9(7 i=0;i<f.y;i++){7 e=G(f[i]);8(e&&17(e,t,n))r.z(e)}};D["@"]=6(r,f,a){7 t=T[a].l;7 e,i;9(i=0;(e=f[i]);i++)8(t(e))r.z(e)};h["2G-10"]=6(e){5!16(e)};h["1x"]=6(e,c){c=12 1t("^"+c,"i");H(e&&!e.13("1x"))e=e.1n;5 e&&c.l(e.13("1x"))};q.1X=/\\\\:/g;q.1w="@";q.J={};q.O=6(m,a,n,c,v){7 k=o.1w+m;8(!T[k]){a=o.1W(a,c||"",v||"");T[k]=a;T.z(a)}5 T[k].B};q.1Q=6(s){s=s.O(o.1X,"|");7 m;H(m=s.P(o.P)){7 r=o.O(m[0],m[1],m[2],m[3],m[4]);s=s.O(o.P,r)}5 s};q.1W=6(p,t,v){7 a={};a.B=o.1w+T.y;a.2F=p;t=o.J[t];t=t?t(o.13(p),1s(v)):L;a.l=12 2E("e","5 "+t);5 a};q.13=6(n){1d(n.2D()){F"B":5"e.B";F"2C":5"e.1V";F"9":5"e.2B";F"1T":8(U){5"1U((e.2A.P(/1T=\\\\1v?([^\\\\s\\\\1v]*)\\\\1v?/)||[])[1]||\'\')"}}5"e.13(\'"+n.O(N,":")+"\')"};q.J[""]=6(a){5 a};q.J["="]=6(a,v){5 a+"=="+1u.1S(v)};q.J["~="]=6(a,v){5"/(^| )"+R(v)+"( |$)/.l("+a+")"};q.J["|="]=6(a,v){5"/^"+R(v)+"(-|$)/.l("+a+")"};7 1R=18;18=6(s){5 1R(q.1Q(s))}});x.15("1j-2z",6(){D["~"]=6(r,f,t,n){7 e,i;9(i=0;(e=f[i]);i++){H(e=G(e)){8(17(e,t,n))r.z(e)}}};h["2y"]=6(e,t){t=12 1t(R(1s(t)));5 t.l(1e(e))};h["2x"]=6(e){5 e==Q(e).1H};h["2w"]=6(e){7 n,i;9(i=0;(n=e.1F[i]);i++){8(M(n)||n.1c==3)5 L}5 K};h["1N-10"]=6(e){5!G(e)};h["2v-10"]=6(e){e=e.1n;5 1r(e)==1P(e)};h["2u"]=6(e,s){7 n=x(s,Q(e));9(7 i=0;i<n.y;i++){8(n[i]==e)5 L}5 K};h["1O-10"]=6(e,a){5 1p(e,a,16)};h["1O-1N-10"]=6(e,a){5 1p(e,a,G)};h["2t"]=6(e){5 e.B==2s.2r.Z(1)};h["1M"]=6(e){5 e.1M};h["2q"]=6(e){5 e.1q===L};h["1q"]=6(e){5 e.1q};h["1L"]=6(e){5 e.1L};q.J["^="]=6(a,v){5"/^"+R(v)+"/.l("+a+")"};q.J["$="]=6(a,v){5"/"+R(v)+"$/.l("+a+")"};q.J["*="]=6(a,v){5"/"+R(v)+"/.l("+a+")"};6 1p(e,a,t){1d(a){F"n":5 K;F"2p":a="2n";1a;F"2o":a="2n+1"}7 1m=1o(e.1n);6 1k(i){7 i=(t==G)?1m.y-i:i-1;5 1m[i]==e};8(!Y(a))5 1k(a);a=a.1l("n");7 m=1K(a[0]);7 s=1K(a[1]);8((Y(m)||m==1)&&s==0)5 K;8(m==0&&!Y(s))5 1k(s);8(Y(s))s=0;7 c=1;H(e=t(e))c++;8(Y(m)||m==1)5(t==G)?(c<=s):(s>=c);5(c%m)==s}});x.15("1j-2m",6(){U=1i("L;/*@2l@8(@\\2k)U=K@2j@*/");8(!U){X=6(e,t,n){5 n?e.2i("*",t):e.X(t)};14=6(e,n){5!n||(n=="*")||(e.2h==n)};1h=1g.1I?6(e){5/1J/i.l(Q(e).1I)}:6(e){5 Q(e).1H.1f!="2g"};1e=6(e){5 e.2f||e.1G||1b(e)};6 1b(e){7 t="",n,i;9(i=0;(n=e.1F[i]);i++){1d(n.1c){F 11:F 1:t+=1b(n);1a;F 3:t+=n.2e;1a}}5 t}}});19=K;5 x}();',62,190,'|||||return|function|var|if|for||||||||pseudoClasses||||test|||this||AttributeSelector|||||||cssQuery|length|push|fr|id||selectors||case|nextElementSibling|while||tests|true|false|thisElement||replace|match|getDocument|regEscape||attributeSelectors|isMSIE|cache||getElementsByTagName|isNaN|slice|child||new|getAttribute|compareNamespace|addModule|previousElementSibling|compareTagName|parseSelector|loaded|break|_0|nodeType|switch|getTextContent|tagName|document|isXML|eval|css|_1|split|ch|parentNode|childElements|nthChild|disabled|firstElementChild|getText|RegExp|Quote|x22|PREFIX|lang|_2|arguments|else|all|links|version|se|childNodes|innerText|documentElement|contentType|xml|parseInt|indeterminate|checked|last|nth|lastElementChild|parse|_3|add|href|String|className|create|NS_IE|remove|toString|ST|select|Array|null|_4|mimeType|lastChild|firstChild|continue|modules|delete|join|caching|error|nodeValue|textContent|HTML|prefix|getElementsByTagNameNS|end|x5fwin32|cc_on|standard||odd|even|enabled|hash|location|target|not|only|empty|root|contains|level3|outerHTML|htmlFor|class|toLowerCase|Function|name|first|level2|prototype|item|scopeName|toUpperCase|ownerDocument|Document|XML|Boolean|URL|unknown|typeof|nextSibling|previousSibling|visited|link|valueOf|clearCache|catch|concat|constructor|callee|try'.split('|'),0,{})) http://cvs.php.net/diff.php/pear/HTML_AJAX/js/HTML_AJAX_lite.js?r1=1.4&r2=1.5&ty=u Index: pear/HTML_AJAX/js/HTML_AJAX_lite.js diff -u pear/HTML_AJAX/js/HTML_AJAX_lite.js:1.4 pear/HTML_AJAX/js/HTML_AJAX_lite.js:1.5 --- pear/HTML_AJAX/js/HTML_AJAX_lite.js:1.4 Mon Oct 24 23:26:13 2005 +++ pear/HTML_AJAX/js/HTML_AJAX_lite.js Mon Nov 7 13:41:39 2005 @@ -242,6 +242,17 @@ 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 @@ -431,9 +442,13 @@ return this.serializer.contentType; }, completeUrl: function() { -var url = this.requestUrl; +var url = new String(this.requestUrl); +var delimiter = '?'; +if (url.indexOf('?') >= 0) { +delimiter = '&'; +} if (this.className || this.methodName) { -url += '?c='+escape(this.className)+'&m='+escape(this.methodName); +url += delimiter+'c='+escape(this.className)+'&m='+escape(this.methodName); } return url; } http://cvs.php.net/diff.php/pear/HTML_AJAX/js/HttpClient.js?r1=1.4&r2=1.5&ty=u Index: pear/HTML_AJAX/js/HttpClient.js diff -u pear/HTML_AJAX/js/HttpClient.js:1.4 pear/HTML_AJAX/js/HttpClient.js:1.5 --- pear/HTML_AJAX/js/HttpClient.js:1.4 Mon Oct 24 23:26:14 2005 +++ pear/HTML_AJAX/js/HttpClient.js Mon Nov 7 13:41:39 2005 @@ -1,199 +1,199 @@ -/** - * 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 object - request: null, - - // timeout id - _timeoutId: null, - - // method to initialize an xmlhttpclient - init:function() - { - try { - // Mozilla / Safari - this.xmlhttp = new XMLHttpRequest(); - } catch (e) { - // IE - 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) { - throw new Error('Unable to create XMLHttpRequest.'); - } - } - }, - - // check if there is a call in progress - callInProgress: function() - { - switch ( this.xmlhttp.readyState ) { - case 1: - case 2: - case 3: - return true; - break; - default: - return false; - break; - } - }, - - // make the request defined in the request object - makeRequest: function() - { - if (!this.xmlhttp) { - this.init(); - } - - try { - if (this.request.onOpen) { - this.request.onOpen(); - } - else if (HTML_AJAX.onOpen) { - HTML_AJAX.onOpen(this.request); - } - this.xmlhttp.open(this.request.requestType,this.request.completeUrl(),this.request.isAsync); - - // set onreadystatechange here since it will be reset after a completed call in Mozilla - var self = this; - this.xmlhttp.onreadystatechange = function() { self._readyStateChangeCallback(); } - - this.xmlhttp.setRequestHeader('Content-Type',this.request.getContentType()); - var payload = this.request.getSerializedPayload(); - if (payload) { - this.xmlhttp.setRequestHeader('Content-Length', payload.length); - } - this.xmlhttp.send(payload); - } catch (e) { - this._handleError(e); - } - - if (!this.request.isAsync) { - if ( this.xmlhttp.status == 200 ) { - HTML_AJAX.requestComplete(this.request); - if (this.request.onLoad) { - this.request.onLoad(); - } else if (HTML_AJAX.onLoad) { - HTML_AJAX.onLoad(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 { - // setup timeout - var self = this; - this._timeoutId = window.setTimeout(function() { self.abort(true); },this.request.timeout); - } - }, - - // abort an inprogress request - abort: function (automatic) - { - if (this.callInProgress()) { - this.xmlhttp.abort(); - - if (automatic) { - this._handleError(new Error('Request Timed Out')); - } - } - }, - - // internal method used to handle ready state changes - _readyStateChangeCallback:function() - { - try { - switch(this.xmlhttp.readyState) { - // XMLHTTPRequest.open() has just been called - case 1: - break; - // XMLHTTPRequest.send() has just been called - case 2: - if (this.request.onSend) { - this.request.onSend(); - } else if (HTML_AJAX.onSend) { - HTML_AJAX.onSend(this.request); - } - break; - // Fetching response from server in progress - case 3: - if (this.request.onProgress) { - this.request.onProgress(); - } else if (HTML_AJAX.onProgress ) { - HTML_AJAX.onProgress(this.request); - } - break; - // Download complete - case 4: - window.clearTimeout(this._timeout_id); - - if (this.xmlhttp.status == 200) { - HTML_AJAX.requestComplete(this.request); - if (this.request.onLoad) { - this.request.onLoad(); - } else if (HTML_AJAX.onLoad ) { - HTML_AJAX.onLoad(this.request); - } - - if (this.request.callback) { - this.request.callback(this._decodeResponse()); - } - } - - else { - var e = new Error('HTTP Error Making Request: ['+this.xmlhttp.status+'] '+this.xmlhttp.statusText); - this._handleError(e); - } - break; - } - } catch (e) { - this._handleError(e); - } - }, - - // decode response as needed - _decodeResponse: function() { - var unserializer = HTML_AJAX.serializerForEncoding(this.xmlhttp.getResponseHeader('Content-Type')); - //alert(this.xmlhttp.responseText); // some sort of debug hook is needed here - - // some sort of sane way for a serializer to ask for XML needs to be added - return unserializer.unserialize(this.xmlhttp.responseText); - }, - - // handle sending an error where it needs to go - _handleError: function(e) - { - HTML_AJAX.requestComplete(this.request,e); - if (this.request.onError) { - this.request.onError(e); - } else if (HTML_AJAX.onError) { - HTML_AJAX.onError(e,this.request); - } - else { - throw e; - } - } -} -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +/** + * 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 object + request: null, + + // timeout id + _timeoutId: null, + + // method to initialize an xmlhttpclient + init:function() + { + try { + // Mozilla / Safari + this.xmlhttp = new XMLHttpRequest(); + } catch (e) { + // IE + 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) { + throw new Error('Unable to create XMLHttpRequest.'); + } + } + }, + + // check if there is a call in progress + callInProgress: function() + { + switch ( this.xmlhttp.readyState ) { + case 1: + case 2: + case 3: + return true; + break; + default: + return false; + break; + } + }, + + // make the request defined in the request object + makeRequest: function() + { + if (!this.xmlhttp) { + this.init(); + } + + try { + if (this.request.onOpen) { + this.request.onOpen(); + } + else if (HTML_AJAX.onOpen) { + HTML_AJAX.onOpen(this.request); + } + this.xmlhttp.open(this.request.requestType,this.request.completeUrl(),this.request.isAsync); + + // set onreadystatechange here since it will be reset after a completed call in Mozilla + var self = this; + this.xmlhttp.onreadystatechange = function() { self._readyStateChangeCallback(); } + + this.xmlhttp.setRequestHeader('Content-Type',this.request.getContentType()); + var payload = this.request.getSerializedPayload(); + if (payload) { + this.xmlhttp.setRequestHeader('Content-Length', payload.length); + } + this.xmlhttp.send(payload); + } catch (e) { + this._handleError(e); + } + + if (!this.request.isAsync) { + if ( this.xmlhttp.status == 200 ) { + HTML_AJAX.requestComplete(this.request); + if (this.request.onLoad) { + this.request.onLoad(); + } else if (HTML_AJAX.onLoad) { + HTML_AJAX.onLoad(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 { + // setup timeout + var self = this; + this._timeoutId = window.setTimeout(function() { self.abort(true); },this.request.timeout); + } + }, + + // abort an inprogress request + abort: function (automatic) + { + if (this.callInProgress()) { + this.xmlhttp.abort(); + + if (automatic) { + this._handleError(new Error('Request Timed Out')); + } + } + }, + + // internal method used to handle ready state changes + _readyStateChangeCallback:function() + { + try { + switch(this.xmlhttp.readyState) { + // XMLHTTPRequest.open() has just been called + case 1: + break; + // XMLHTTPRequest.send() has just been called + case 2: + if (this.request.onSend) { + this.request.onSend(); + } else if (HTML_AJAX.onSend) { + HTML_AJAX.onSend(this.request); + } + break; + // Fetching response from server in progress + case 3: + if (this.request.onProgress) { + this.request.onProgress(); + } else if (HTML_AJAX.onProgress ) { + HTML_AJAX.onProgress(this.request); + } + break; + // Download complete + case 4: + window.clearTimeout(this._timeout_id); + + if (this.xmlhttp.status == 200) { + HTML_AJAX.requestComplete(this.request); + if (this.request.onLoad) { + this.request.onLoad(); + } else if (HTML_AJAX.onLoad ) { + HTML_AJAX.onLoad(this.request); + } + + if (this.request.callback) { + this.request.callback(this._decodeResponse()); + } + } + + else { + var e = new Error('HTTP Error Making Request: ['+this.xmlhttp.status+'] '+this.xmlhttp.statusText); + this._handleError(e); + } + break; + } + } catch (e) { + this._handleError(e); + } + }, + + // decode response as needed + _decodeResponse: function() { + var unserializer = HTML_AJAX.serializerForEncoding(this.xmlhttp.getResponseHeader('Content-Type')); + //alert(this.xmlhttp.responseText); // some sort of debug hook is needed here + + // some sort of sane way for a serializer to ask for XML needs to be added + return unserializer.unserialize(this.xmlhttp.responseText); + }, + + // handle sending an error where it needs to go + _handleError: function(e) + { + HTML_AJAX.requestComplete(this.request,e); + if (this.request.onError) { + this.request.onError(e); + } else if (HTML_AJAX.onError) { + HTML_AJAX.onError(e,this.request); + } + else { + throw e; + } + } +} +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ http://cvs.php.net/diff.php/pear/HTML_AJAX/js/Loading.js?r1=1.1&r2=1.2&ty=u Index: pear/HTML_AJAX/js/Loading.js diff -u pear/HTML_AJAX/js/Loading.js:1.1 pear/HTML_AJAX/js/Loading.js:1.2 --- pear/HTML_AJAX/js/Loading.js:1.1 Mon Oct 24 23:28:30 2005 +++ pear/HTML_AJAX/js/Loading.js Mon Nov 7 13:41:39 2005 @@ -1,38 +1,38 @@ -/** - * Default loading implementation - * - * @category HTML - * @package Ajax - * @author Joshua Eichorn <josh@bluga.net> - * @copyright 2005 Joshua Eichorn - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - */ - -HTML_AJAX.onOpen = function(request) { - var loading = document.getElementById('HTML_AJAX_LOADING'); - if (!loading) { - loading = document.createElement('div'); - loading.id = 'HTML_AJAX_LOADING'; - loading.innerHTML = 'Loading...'; - loading.style.position = 'absolute'; - loading.style.top = 0; - loading.style.right = 0; - loading.style.backgroundColor = 'red'; - loading.style.width = '80px'; - loading.style.padding = '4px'; - - document.body.insertBefore(loading,document.body.firstChild); - } - HTML_AJAX.onOpen_Timeout = window.setTimeout(function() { loading.style.display = 'block'; },500); -} -HTML_AJAX.onLoad = function(request) { - if (HTML_AJAX.onOpen_Timeout) { - window.clearTimeout(HTML_AJAX.onOpen_Timeout); - HTML_AJAX.onOpen_Timeout = false; - } - var loading = document.getElementById('HTML_AJAX_LOADING'); - if (loading) { - loading.style.display = 'none'; - } -} -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +/** + * Default loading implementation + * + * @category HTML + * @package Ajax + * @author Joshua Eichorn <josh@bluga.net> + * @copyright 2005 Joshua Eichorn + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + */ + +HTML_AJAX.onOpen = function(request) { + var loading = document.getElementById('HTML_AJAX_LOADING'); + if (!loading) { + loading = document.createElement('div'); + loading.id = 'HTML_AJAX_LOADING'; + loading.innerHTML = 'Loading...'; + loading.style.position = 'absolute'; + loading.style.top = 0; + loading.style.right = 0; + loading.style.backgroundColor = 'red'; + loading.style.width = '80px'; + loading.style.padding = '4px'; + + document.body.insertBefore(loading,document.body.firstChild); + } + HTML_AJAX.onOpen_Timeout = window.setTimeout(function() { loading.style.display = 'block'; },500); +} +HTML_AJAX.onLoad = function(request) { + if (HTML_AJAX.onOpen_Timeout) { + window.clearTimeout(HTML_AJAX.onOpen_Timeout); + HTML_AJAX.onOpen_Timeout = false; + } + var loading = document.getElementById('HTML_AJAX_LOADING'); + if (loading) { + loading.style.display = 'none'; + } +} +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ http://cvs.php.net/diff.php/pear/HTML_AJAX/js/Request.js?r1=1.4&r2=1.5&ty=u Index: pear/HTML_AJAX/js/Request.js diff -u pear/HTML_AJAX/js/Request.js:1.4 pear/HTML_AJAX/js/Request.js:1.5 --- pear/HTML_AJAX/js/Request.js:1.4 Mon Oct 24 23:26:14 2005 +++ pear/HTML_AJAX/js/Request.js Mon Nov 7 13:41:39 2005 @@ -1,97 +1,101 @@ -/** - * Class that contains everything needed to make a request - * This includes: - * The url were calling - * If were calling a remote method, the class and method name - * The payload, unserialized - * The timeout for async calls - * The callback method - * Optional event handlers: onError, onLoad, onSend - * A serializer instance - * - * @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_Request(serializer) { - this.serializer = serializer; -} -HTML_AJAX_Request.prototype = { - - // Instance of a serializer - serializer: null, - - // Is this an async request - isAsync: false, - - // HTTP verb - requestType: 'POST', - - // The actual URL the request is sent to - requestUrl: '', - - // Remote Class - className: null, - - // Remote Method - methodName: null, - - // Timeout in milliseconds for requests - timeout: 20000, - - // unserialized data, for rpc calls use add args, to send raw data just set this directly - args: null, - - // async callback method - callback: null, - - // Queue to push this request too - queue: 'default', - - /** - * Add an argument for the remote method - * @param string argument name - * @param mixed value - * @return void - * @throws Error code 1004 - */ - addArg: function(name, value) - { - if ( !this.args ) { - this.args = []; - } - if (!/[^a-zA-Z_0-9]/.test(name) ) { - this.args[name] = value; - } else { - throw new Error('Invalid parameter name ('+name+')'); - } - }, - - /** - * Get the payload in a serialized manner - */ - getSerializedPayload: function() { - return this.serializer.serialize(this.args); - }, - - /** - * Get the content type - */ - getContentType: function() { - return this.serializer.contentType; - }, - - /** - * Get the complete url, adding in any needed get params for rpc - */ - completeUrl: function() { - var url = this.requestUrl; - if (this.className || this.methodName) { - url += '?c='+escape(this.className)+'&m='+escape(this.methodName); - } - return url; - } -} -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +/** + * Class that contains everything needed to make a request + * This includes: + * The url were calling + * If were calling a remote method, the class and method name + * The payload, unserialized + * The timeout for async calls + * The callback method + * Optional event handlers: onError, onLoad, onSend + * A serializer instance + * + * @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_Request(serializer) { + this.serializer = serializer; +} +HTML_AJAX_Request.prototype = { + + // Instance of a serializer + serializer: null, + + // Is this an async request + isAsync: false, + + // HTTP verb + requestType: 'POST', + + // The actual URL the request is sent to + requestUrl: '', + + // Remote Class + className: null, + + // Remote Method + methodName: null, + + // Timeout in milliseconds for requests + timeout: 20000, + + // unserialized data, for rpc calls use add args, to send raw data just set this directly + args: null, + + // async callback method + callback: null, + + // Queue to push this request too + queue: 'default', + + /** + * Add an argument for the remote method + * @param string argument name + * @param mixed value + * @return void + * @throws Error code 1004 + */ + addArg: function(name, value) + { + if ( !this.args ) { + this.args = []; + } + if (!/[^a-zA-Z_0-9]/.test(name) ) { + this.args[name] = value; + } else { + throw new Error('Invalid parameter name ('+name+')'); + } + }, + + /** + * Get the payload in a serialized manner + */ + getSerializedPayload: function() { + return this.serializer.serialize(this.args); + }, + + /** + * Get the content type + */ + getContentType: function() { + return this.serializer.contentType; + }, + + /** + * Get the complete url, adding in any needed get params for rpc + */ + completeUrl: function() { + var url = new String(this.requestUrl); + var delimiter = '?'; + if (url.indexOf('?') >= 0) { + delimiter = '&'; + } + if (this.className || this.methodName) { + url += delimiter+'c='+escape(this.className)+'&m='+escape(this.methodName); + } + return url; + } +} +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ http://cvs.php.net/diff.php/pear/HTML_AJAX/js/build.php?r1=1.3&r2=1.4&ty=u Index: pear/HTML_AJAX/js/build.php diff -u pear/HTML_AJAX/js/build.php:1.3 pear/HTML_AJAX/js/build.php:1.4 --- pear/HTML_AJAX/js/build.php:1.3 Mon Oct 24 23:26:14 2005 +++ pear/HTML_AJAX/js/build.php Mon Nov 7 13:41:39 2005 @@ -1,74 +1,74 @@ -<?php -/** - * A simple script to build a single js file from the multiple sources - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - */ -// simple script contains a merged js file from multiple source files -// can optionaly strip whitespace - -$dest = "HTML_AJAX.js"; -if (isset($argv[1])) { - $dest = $argv[1]; -} -$strip = false; -if (isset($argv[2]) && $argv[2] == 'strip') { - $strip = true; -} - -$source = array('Main.js','Dispatcher.js','HttpClient.js','Request.js','JSON.js','Loading.js','util.js','behavior.js','cssQuery-p.js'); - -$stripPregs = array( - '/^\s+$/', - '/^\s*\/\/.*$/' - ); -$blockStart = '/^\s*\/\*.*$/'; -$blockEnd = '/^\s*\*\/\s*$/'; - -$out = ''; -foreach($source as $file) { - $s = ""; - if ($strip) { - $lines = file($file); - $inblock = false; - foreach($lines as $line) { - $keep = true; - if ($inblock) { - if (preg_match($blockEnd,$line)) { - $inblock = false; - $keep = false; - } - } - else if (preg_match($blockStart,$line)) { - $inblock = true; - } - - if (!$inblock) { - foreach($stripPregs as $preg) { - if (preg_match($preg,$line)) { - $keep = false; - break; - } - } - } - - if ($keep && !$inblock) { - $s .= trim($line)."\n"; - } - /* Enable to see what your striping out - else { - echo $line."<br>"; - }*/ - } - } - else { - $s = file_get_contents($file); - } - - $out .= "// $file\n"; - $out .= $s; -} - -$fp = fopen($dest,'w'); -fwrite($fp,$out); -fclose($fp); -?> +<?php +/** + * A simple script to build a single js file from the multiple sources + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + */ +// simple script contains a merged js file from multiple source files +// can optionaly strip whitespace + +$dest = "HTML_AJAX.js"; +if (isset($argv[1])) { + $dest = $argv[1]; +} +$strip = false; +if (isset($argv[2]) && $argv[2] == 'strip') { + $strip = true; +} + +$source = array('Main.js','Dispatcher.js','HttpClient.js','Request.js','JSON.js','Loading.js','util.js','behavior.js','cssQuery-p.js'); + +$stripPregs = array( + '/^\s+$/', + '/^\s*\/\/.*$/' + ); +$blockStart = '/^\s*\/\*.*$/'; +$blockEnd = '/^\s*\*\/\s*$/'; + +$out = ''; +foreach($source as $file) { + $s = ""; + if ($strip) { + $lines = file($file); + $inblock = false; + foreach($lines as $line) { + $keep = true; + if ($inblock) { + if (preg_match($blockEnd,$line)) { + $inblock = false; + $keep = false; + } + } + else if (preg_match($blockStart,$line)) { + $inblock = true; + } + + if (!$inblock) { + foreach($stripPregs as $preg) { + if (preg_match($preg,$line)) { + $keep = false; + break; + } + } + } + + if ($keep && !$inblock) { + $s .= trim($line)."\n"; + } + /* Enable to see what your striping out + else { + echo $line."<br>"; + }*/ + } + } + else { + $s = file_get_contents($file); + } + + $out .= "// $file\n"; + $out .= $s; +} + +$fp = fopen($dest,'w'); +fwrite($fp,$out); +fclose($fp); +?> http://cvs.php.net/diff.php/pear/HTML_AJAX/js/phpSerializer.js?r1=1.1&r2=1.2&ty=u Index: pear/HTML_AJAX/js/phpSerializer.js diff -u pear/HTML_AJAX/js/phpSerializer.js:1.1 pear/HTML_AJAX/js/phpSerializer.js:1.2 --- pear/HTML_AJAX/js/phpSerializer.js:1.1 Mon Oct 24 23:28:30 2005 +++ pear/HTML_AJAX/js/phpSerializer.js Mon Nov 7 13:41:39 2005 @@ -1,290 +1,290 @@ -/*************************************************************************** - - These functions can be used to serialize and unserialize data in a - format compatible with PHP's native serialization functions. - - Copyright (C) 2005 Arpad Ray <arpad@rajeczy.com> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to: - Free Software Foundation, Inc., - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -***************************************************************************/ - -// {{{ var HTML_AJAX_Serialize_PHP -var HTML_AJAX_Serializer_PHP = { - - var defaultEncoding = 'UTF-8'; - // {{{ serialize - /** - * 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> - * @version 0.0.2 - */ - serialize: function(inp) { - var type = HTML_AJAX_Serializer_PHP.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] = HTML_AJAX_Serializer_PHP.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 += HTML_AJAX_Serializer_PHP.serialize(okey) + - HTML_AJAX_Serializer_PHP.serialize(inp[key]); - count++; - } - val += ":" + count + ":{" + vals + "}"; - break; - } - if (type != "object" && type != "array") val += ";"; - return val; - } - // }}} - // {{{ unserialize - /** - * Reconstructs a serialized variable - * - * @param mixed inp the string to reconstruct - * @return mixed the variable represented by the input string - * @author Arpad Ray <arpad@rajeczy.com> - * @version 0.0.2 - */ - unserialize: function(inp) { - - if (inp == "" || inp.length < 2) { - unserializer.raiseError("input is too short"); - return; - } - var val, kret, vret, cval; - var type = inp.charAt(0); - var cont = inp.substring(2); - var size = 0; - var divpos = 0; - var endcont = 0; - var rest = ""; - var next = ""; - - switch (type) { - case "N": // null - if (inp.charAt(1) != ";") { - unserializer.raiseError("missing ; for null", cont); - } - // leave val undefined - rest = cont; - break; - case "b": // boolean - if (!/[01];/.test(cont.substring(0,2))) { - unserializer.raiseError("value not 0 or 1, or missing ; for boolean", cont); - } - val = (cont.charAt(0) == "1"); - rest = cont.substring(1); - break; - case "s": // string - val = ""; - divpos = cont.indexOf(":"); - if (divpos == -1) { - unserializer.raiseError("missing : for string", cont); - break; - } - size = parseInt(cont.substring(0, divpos)); - if (size == 0) { - if (cont.length - divpos < 4) { - unserializer.raiseError("string is too short", cont); - break; - } - rest = cont.substring(divpos + 4); - break; - } - if ((cont.length - divpos - size) < 4) { - unserializer.raiseError("string is too short", cont); - break; - } - if (cont.substring(divpos + 2 + size, divpos + 4 + size) != "\";") { - unserializer.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": // integer - case "d": // float - var 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) != ";") { - unserializer.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": // array - if (cont.length < 4) { - unserializer.raiseError("array is too short", cont); - return; - } - divpos = cont.indexOf(":", 1); - if (divpos == -1) { - unserializer.raiseError("missing : for array", cont); - return; - } - size = parseInt(cont.substring(1, divpos - 1)); - cont = cont.substring(divpos + 2); - val = new Array(); - if (cont.length < 1) { - unserializer.raiseError("array is too short", cont); - return; - } - for (var i = 0; i + 1 < size * 2 && !unserializer.error; i += 2) { - kret = unserialize(cont, 1); - if (unserializer.error || kret[0] == undefined || kret[1] == "") { - unserializer.raiseError("missing or invalid key, or missing value for array", cont); - break; - } - vret = unserialize(kret[1], 1); - if (unserializer.error) { - unserializer.raiseError("invalid value for array", cont); - break; - } - val[kret[0]] = vret[0]; - cont = vret[1]; - } - if (unserializer.error) { - return; - } - if (cont.charAt(0) != "}") { - unserializer.raiseError("missing ending }, or too many values for array", cont); - return; - } - rest = cont.substring(1); - break; - case "O": // object - divpos = cont.indexOf(":"); - if (divpos == -1) { - unserializer.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) != "\":") { - unserializer.raiseError("object name is too long, or missing \":", cont); - return; - } - var objprops = unserialize("a:" + cont.substring(divpos + 4 + size), 1); - if (unserializer.error) { - unserializer.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: - unserializer.raiseError("invalid input type", cont); - } - return (arguments.length == 1 ? val : [val, rest]); - } - // }}} - // {{{ gettype - /** - * Returns the type of a variable or its primitive equivalent - * - * @param inp - * the input variable - * @return mixed - * a string as returned by typeof - * @author - * Arpad Ray <arpad@rajeczy.com> - * @version - * 2005/9/29 - */ - gettype: function(inp) { - var type = typeof inp; - if (type == "object") { - var cons = inp.constructor.toString().toLowerCase(); - var types = ["boolean", "number", "string", "array"]; - for (key in types) { - if (cons.indexOf(types[key]) != -1) { - type = types[key]; - break; - } - } - } - return type; - } - // }}} -} -// }}} -function Unserializer() -{ - this.error = 0; - this.message = ""; - this.cont = ""; -} - -Unserializer.prototype.unserialize = function(inp) -{ - this.error = 0; - return unserialize(inp); -} - -Unserializer.prototype.getError = function() -{ - return this.message + "\n" + this.cont; -} - -Unserializer.prototype.raiseError = function(message, cont) -{ - this.error = 1; - this.message = message; - this.cont = cont; -} - +/*************************************************************************** + + These functions can be used to serialize and unserialize data in a + format compatible with PHP's native serialization functions. + + Copyright (C) 2005 Arpad Ray <arpad@rajeczy.com> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to: + Free Software Foundation, Inc., + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +***************************************************************************/ + +// {{{ var HTML_AJAX_Serialize_PHP +var HTML_AJAX_Serializer_PHP = { + + var defaultEncoding = 'UTF-8'; + // {{{ serialize + /** + * 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> + * @version 0.0.2 + */ + serialize: function(inp) { + var type = HTML_AJAX_Serializer_PHP.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] = HTML_AJAX_Serializer_PHP.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 += HTML_AJAX_Serializer_PHP.serialize(okey) + + HTML_AJAX_Serializer_PHP.serialize(inp[key]); + count++; + } + val += ":" + count + ":{" + vals + "}"; + break; + } + if (type != "object" && type != "array") val += ";"; + return val; + } + // }}} + // {{{ unserialize + /** + * Reconstructs a serialized variable + * + * @param mixed inp the string to reconstruct + * @return mixed the variable represented by the input string + * @author Arpad Ray <arpad@rajeczy.com> + * @version 0.0.2 + */ + unserialize: function(inp) { + + if (inp == "" || inp.length < 2) { + unserializer.raiseError("input is too short"); + return; + } + var val, kret, vret, cval; + var type = inp.charAt(0); + var cont = inp.substring(2); + var size = 0; + var divpos = 0; + var endcont = 0; + var rest = ""; + var next = ""; + + switch (type) { + case "N": // null + if (inp.charAt(1) != ";") { + unserializer.raiseError("missing ; for null", cont); + } + // leave val undefined + rest = cont; + break; + case "b": // boolean + if (!/[01];/.test(cont.substring(0,2))) { + unserializer.raiseError("value not 0 or 1, or missing ; for boolean", cont); + } + val = (cont.charAt(0) == "1"); + rest = cont.substring(1); + break; + case "s": // string + val = ""; + divpos = cont.indexOf(":"); + if (divpos == -1) { + unserializer.raiseError("missing : for string", cont); + break; + } + size = parseInt(cont.substring(0, divpos)); + if (size == 0) { + if (cont.length - divpos < 4) { + unserializer.raiseError("string is too short", cont); + break; + } + rest = cont.substring(divpos + 4); + break; + } + if ((cont.length - divpos - size) < 4) { + unserializer.raiseError("string is too short", cont); + break; + } + if (cont.substring(divpos + 2 + size, divpos + 4 + size) != "\";") { + unserializer.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": // integer + case "d": // float + var 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) != ";") { + unserializer.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": // array + if (cont.length < 4) { + unserializer.raiseError("array is too short", cont); + return; + } + divpos = cont.indexOf(":", 1); + if (divpos == -1) { + unserializer.raiseError("missing : for array", cont); + return; + } + size = parseInt(cont.substring(1, divpos - 1)); + cont = cont.substring(divpos + 2); + val = new Array(); + if (cont.length < 1) { + unserializer.raiseError("array is too short", cont); + return; + } + for (var i = 0; i + 1 < size * 2 && !unserializer.error; i += 2) { + kret = unserialize(cont, 1); + if (unserializer.error || kret[0] == undefined || kret[1] == "") { + unserializer.raiseError("missing or invalid key, or missing value for array", cont); + break; + } + vret = unserialize(kret[1], 1); + if (unserializer.error) { + unserializer.raiseError("invalid value for array", cont); + break; + } + val[kret[0]] = vret[0]; + cont = vret[1]; + } + if (unserializer.error) { + return; + } + if (cont.charAt(0) != "}") { + unserializer.raiseError("missing ending }, or too many values for array", cont); + return; + } + rest = cont.substring(1); + break; + case "O": // object + divpos = cont.indexOf(":"); + if (divpos == -1) { + unserializer.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) != "\":") { + unserializer.raiseError("object name is too long, or missing \":", cont); + return; + } + var objprops = unserialize("a:" + cont.substring(divpos + 4 + size), 1); + if (unserializer.error) { + unserializer.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: + unserializer.raiseError("invalid input type", cont); + } + return (arguments.length == 1 ? val : [val, rest]); + } + // }}} + // {{{ gettype + /** + * Returns the type of a variable or its primitive equivalent + * + * @param inp + * the input variable + * @return mixed + * a string as returned by typeof + * @author + * Arpad Ray <arpad@rajeczy.com> + * @version + * 2005/9/29 + */ + gettype: function(inp) { + var type = typeof inp; + if (type == "object") { + var cons = inp.constructor.toString().toLowerCase(); + var types = ["boolean", "number", "string", "array"]; + for (key in types) { + if (cons.indexOf(types[key]) != -1) { + type = types[key]; + break; + } + } + } + return type; + } + // }}} +} +// }}} +function Unserializer() +{ + this.error = 0; + this.message = ""; + this.cont = ""; +} + +Unserializer.prototype.unserialize = function(inp) +{ + this.error = 0; + return unserialize(inp); +} + +Unserializer.prototype.getError = function() +{ + return this.message + "\n" + this.cont; +} + +Unserializer.prototype.raiseError = function(message, cont) +{ + this.error = 1; + this.message = message; + this.cont = cont; +} + http://cvs.php.net/diff.php/pear/HTML_AJAX/js/util.js?r1=1.2&r2=1.3&ty=u Index: pear/HTML_AJAX/js/util.js diff -u pear/HTML_AJAX/js/util.js:1.2 pear/HTML_AJAX/js/util.js:1.3 --- pear/HTML_AJAX/js/util.js:1.2 Mon Oct 24 23:26:14 2005 +++ pear/HTML_AJAX/js/util.js Mon Nov 7 13:41:39 2005 @@ -1,45 +1,49 @@ -/** - * Utility methods - * - * @category HTML - * @package Ajax - * @author David Coallier <davidc@php.net> - * @copyright 2005 David Coallier - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - */ -// {{{ HTML_AJAX_Util -/** - * All the utilities we will be using thorough the classes - */ -var HTML_AJAX_Util = { - // Set the element event - setElementEvent: function(id, event, handler) { - var element = document.getElementById(id); - if (typeof element.addEventListener != "undefined") { //Dom2 - element.addEventListener(event, handler, false); - } else if (typeof element.attachEvent != "undefined") { //IE 5+ - element.attachEvent("on" + event, handler); - } else { - if (element["on" + event] != null) { - var oldHandler = element["on" + event]; - element["on" + event] = function(e) { - oldHander(e); - handler(e); - }; - } else { - element["on" + event] = handler; - } - } - }, - // simple non recursive variable dumper, don't rely on its output staying the same, its just for debugging and will get smarter at some point - varDump: function(input) { - var r = ""; - for(var i in input) { - r += i+':'+input[i]+"\n"; - } - return r; - } - -} -// }}} -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +/** + * Utility methods + * + * @category HTML + * @package Ajax + * @author David Coallier <davidc@php.net> + * @copyright 2005 David Coallier + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + */ +// {{{ HTML_AJAX_Util +/** + * All the utilities we will be using thorough the classes + */ +var HTML_AJAX_Util = { + // Set the element event + registerEvent: function(element, event, handler) { + //var element = document.getElementById(id); + if (typeof element.addEventListener != "undefined") { //Dom2 + element.addEventListener(event, handler, false); + } else if (typeof element.attachEvent != "undefined") { //IE 5+ + element.attachEvent("on" + event, handler); + } else { + if (element["on" + event] != null) { + var oldHandler = element["on" + event]; + element["on" + event] = function(e) { + oldHander(e); + handler(e); + }; + } else { + element["on" + event] = handler; + } + } + }, + // simple non recursive variable dumper, don't rely on its output staying the same, its just for debugging and will get smarter at some point + varDump: function(input) { + var r = ""; + for(var i in input) { + r += i+':'+input[i]+"\n"; + } + return r; + }, + getElementsByClassName: function(className, parentElement) { + var children = ($(parentElement) || document.body).getElementsByTagName('*'); + for(var i =0; i < children.length; i++) { + } + } +} +// }}} +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */