/* This software is allowed to use under GPL or you need to obtain Commercial or Enterise License to use it in not GPL project. Please contact sales@dhtmlx.com for details */ dataProcessor.prototype._o_init = dataProcessor.prototype.init; dataProcessor.prototype.init=function(obj){ this._console=this._console||this._createConsole(); this.attachEvent("onValidatationError",function(rowId){ this._log("Validation error for ID="+(rowId||"[multiple]")); return true; }); return this._o_init(obj); } dataProcessor.prototype._createConsole=function(){ var c=document.createElement("DIV"); c.style.cssText='width:450px; height:420px; overflow:auto; position:absolute; z-index:99999; background-color:white; top:0px; right:0px; border:1px dashed black; font-family:Tahoma; Font-size:10pt;'; c.innerHTML="
[close] [clear]  DataProcessor
 Current state
 Log:
"; if (document.body) document.body.insertBefore(c,document.body.firstChild); else dhtmlxEvent(window,"load",function(){ document.body.insertBefore(c,document.body.firstChild); }) dhtmlxEvent(window,"dblclick",function(){ c.style.display=''; }) return c; } dataProcessor.prototype._error=function(data){ this._log(""+data+""); } dataProcessor.prototype._log=function(data){ var div=document.createElement("DIV"); div.innerHTML = data; var parent=this._console.childNodes[2]; parent.appendChild(div); parent.scrollTop=parent.scrollHeight; if (window.console && window.console.log) window.console.log("DataProcessor :: "+data.replace(" "," ").replace("","").replace("","")); } dataProcessor.prototype._updateStat=function(data){ var data=[" Current state"]; for(var i=0;i")+"
Current mode: "+this.updateMode; } dataProcessor.prototype.xml_analize=function(xml){ if (_isFF){ if (!xml.xmlDoc.responseXML) this._error("Not an XML, probably incorrect content type specified ( must be text/xml ), or some text output was started before XML data"); else if (xml.xmlDoc.responseXML.firstChild.tagName=="parsererror") this._error(xml.xmlDoc.responseXML.firstChild.textContent); else return true; } else if (_isIE){ if (xml.xmlDoc.responseXML.parseError.errorCode) this._error("XML error : "+xml.xmlDoc.responseXML.parseError.reason); else if (!xml.xmlDoc.responseXML.documentElement) this._error("Not an XML, probably incorrect content type specified ( must be text/xml ), or some text output was started before XML data"); else return true; } return false; } dataProcessor.wrap=function(name,before,after){ var d=dataProcessor.prototype; if (!d._wrap) d._wrap={}; d._wrap[name]=d[name]; d[name]=function(){ if (before) before.apply(this,arguments); var res=d._wrap[name].apply(this,arguments); if (after) after.apply(this,[arguments,res]); return res; } }; dataProcessor.wrap("setUpdated",function(rowId,state,mode){ this._log(" row "+rowId+" "+(state?"marked":"unmarked")+" ["+(mode||"updated")+","+(this.is_invalid(rowId)||"valid")+"]"); },function(){ this._updateStat(); }); dataProcessor.wrap("sendData",function(rowId){ if (rowId){ this._log(" Initiating data sending for "+rowId+""); if (this.obj.mytype=="tree"){ if (!this.obj._idpull[rowId]) this._log(" Error! item with such ID not exists "+rowId+""); } else { if (this.rowsAr && !this.obj.rowsAr[rowId]) this._log(" Error! row with such ID not exists "+rowId+""); } } },function(){ }); dataProcessor.wrap("sendAllData",function(){ this._log(" Initiating data sending for all rows "); },function(){ }); dataProcessor.logSingle=function(data,id){ var tdata = {}; if (id) tdata[id] = data; else tdata = data; var url = []; for (var key in tdata) { url.push("
"+key+""); var suburl = []; for (var ikey in tdata[key]) suburl.push(ikey+" = "+tdata[key][ikey]); url.push(suburl.join("
")); url.push("
"); } return url.join(""); } dataProcessor.wrap("_sendData",function(data,rowId){ if (rowId) this._log(" Sending in one-by-one mode, current ID = "+rowId); else this._log(" Sending all data at once"); this._log(" Server url: "+this.serverProcessor+" parameters"); var url = []; this._log("
"+dataProcessor.logSingle(data,rowId)+"
"); },function(){ }); dataProcessor.wrap("afterUpdate",function(that,b,c,d,xml){ that._log(" Server response received details
"+(xml.xmlDoc.responseText||"").replace(/\&/g,"&").replace(//g,">")+"
"); if (!that.xml_analize(xml)) return; var atag=xml.doXPath("//data/action"); if (!atag){ that._log(" No actions found"); var atag=xml.getXMLTopNode("data"); if (!atag) that._log(" XML not valid"); else that._log(" Incorrect content type - need to be text/xml"); } },function(){ }); dataProcessor.wrap("afterUpdateCallback",function(sid,tid,action){ if (this.obj.mytype=="tree"){ if (!this.obj._idpull[sid]) this._log("Incorrect SID, item with such ID not exists in grid"); } else { if (this.obj.rowsAr && !this.obj.rowsAr[sid]) this._log("Incorrect SID, row with such ID not exists in grid"); } this._log(" Action: "+action+" SID:"+sid+" TID:"+tid); },function(){ });