summaryrefslogtreecommitdiff
path: root/swat/style/qooxdoo/widgets/core/QxData.js
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-08-05 19:11:26 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:31:20 -0500
commit8808465e5b70fd6388ed02a2cfda6015ffc914e5 (patch)
tree6e4428825fa1fd21f5e5938a3c0fb16710471852 /swat/style/qooxdoo/widgets/core/QxData.js
parentb99bca56570c0b146128bc243d770bb354ae0cd5 (diff)
downloadsamba-8808465e5b70fd6388ed02a2cfda6015ffc914e5.tar.gz
samba-8808465e5b70fd6388ed02a2cfda6015ffc914e5.tar.bz2
samba-8808465e5b70fd6388ed02a2cfda6015ffc914e5.zip
r9133: a huge import of the qooxdoo infrastructure. I decided to import all the widgets to make experimenting easy during development. We can trim this back later to only the pieces we use
(This used to be commit 631a56da39ed0daae46ca89e57c10b09cf41c718)
Diffstat (limited to 'swat/style/qooxdoo/widgets/core/QxData.js')
-rw-r--r--swat/style/qooxdoo/widgets/core/QxData.js2
1 files changed, 2 insertions, 0 deletions
diff --git a/swat/style/qooxdoo/widgets/core/QxData.js b/swat/style/qooxdoo/widgets/core/QxData.js
new file mode 100644
index 0000000000..44b055c85f
--- /dev/null
+++ b/swat/style/qooxdoo/widgets/core/QxData.js
@@ -0,0 +1,2 @@
+/* Copyright (c): 2002-2005 (Germany): United Internet, 1&1, GMX, Schlund+Partner, Alturo */
+function QxData(c){QxTarget.call(this);this._h7=[];this._storeQueue=[];this._cache={};this._interval=new QxTimer(25);this._processRequestQueue=false;var o=this;this._interval.addEventListener("interval",function(){o.checkProcess();});(new QxTimerManager).add(this);};QxData.extend(QxTarget,"QxData");proto.loadData=function(dataKey){if(this.getDisposed()){return;};this._h7.push(dataKey);if(!this._interval.getEnabled()){this._interval.start();};};proto.checkProcess=function(){if(this.getDisposed()){return;};if(this._processRequestQueue){return;};this._processRequestQueue=true;while(this._h7.length>0){this.process(this._h7.shift(),new QxXmlHttpLoader);};this._processRequestQueue=false;this._interval.stop();};proto.process=function(dataKey,loader){if(this.getDisposed()){return;};this._storeQueue.push(dataKey);var o=this;loader.addEventListener("complete",function(e){o.processComplete(e.getData());loader.dispose();});try{loader.load(this.makeRequest(dataKey));}catch(ex){var t=dataKey.indexOf("[");var p0=dataKey.substring(0,t);this.dispatchEvent(new QxDataEvent("update"+p0.toFirstUp(),this),true);loader.dispose();throw new Error("Could not load data:"+ex);};};proto.makeRequest=function(dataKey){var t=dataKey.indexOf("[");var p0=dataKey.substring(0,t);var p1=dataKey.substring(t+1,dataKey.length-1);return "data/" + p0 + "/" + p1 + ".xml" + "?r=" + Math.round(Math.random()^Math.random()*100000);};proto.processComplete=function(xmlData){var req=this.getRequest(xmlData);var res=this.parseData(req,xmlData);this.mergeCacheData(res);this.dispatchEvent(new QxDataEvent("update"+req.toFirstUp(),this),true);};proto.getRequest=function(xmlData){return xmlData.documentElement.getElementsByTagName("PfxRequest")[0].getElementsByTagName("PfxSoap")[0].getAttribute("reqname");};proto.getResultXml=function(xmlData){return xmlData.documentElement.getElementsByTagName("PfxResult")[0];};proto.mapXmlToObject=function(xmlFrag){var r={};var c=xmlFrag.childNodes;for(var i=0;i<c.length;i++){if(c[i].nodeType==1){r[c[i].tagName]=c[i].firstChild.nodeValue;};};return r;};proto.parseData=function(req,xmlData){var handler=this["_parseData_"+req];if(typeof handler!="function"){throw new Error("QxData:The Parser function is not defined:_parseData_"+req+"!");};return handler.call(this,xmlData);};proto.mergeCacheData=function(res){for(i in res){this._cache[i]=res[i];};};proto.dispose=function(){if(this._disposed){return;};QxObject.prototype.dispose.call(this);if(typeof this._h7=="object"){for(var i=0;i<this._h7.length;i++){delete this._h7[i];};};delete this._h7;if(typeof this._storeQueue=="object"){for(var i=0;i<this._storeQueue.length;i++){delete this._storeQueue[i];};};delete this._storeQueue;if(typeof this._cache=="object"){for(i in this._cache){delete this._cache[i];};};this._cache=null;if(this._interval){this._interval.dispose();};this._interval=null;this._processRequestQueue=null;}; \ No newline at end of file