s4:heimdal_build/wscript_build: avoid global deps for hostcc stuff
[kai/samba-autobuild/.git] / swat2 / style / qooxdoo / widgets / core / QxData.js
1 /* Copyright (c): 2002-2005 (Germany): United Internet, 1&1, GMX, Schlund+Partner, Alturo */
2 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;};