[4001] | 1 | dataProcessor.prototype._o_init = dataProcessor.prototype.init;
|
---|
| 2 | dataProcessor.prototype.init=function(obj){
|
---|
| 3 | this._console=this._console||this._createConsole();
|
---|
| 4 | this.attachEvent("onValidatationError",function(rowId){
|
---|
| 5 | this._log("Validation error for ID="+(rowId||"[multiple]"));
|
---|
| 6 | return true;
|
---|
| 7 | });
|
---|
| 8 | return this._o_init(obj);
|
---|
| 9 | }
|
---|
| 10 |
|
---|
| 11 | dataProcessor.prototype._createConsole=function(){
|
---|
| 12 | var c=document.createElement("DIV");
|
---|
| 13 | 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;';
|
---|
| 14 | c.innerHTML="<div style='width:100%; background-color:gray; font-weight:bold; color:white;'><span style='cursor:pointer;float:right;' onclick='this.parentNode.parentNode.style.display=\"none\"'><sup>[close] </sup></span><span style='cursor:pointer;float:right;' onclick='this.parentNode.parentNode.childNodes[2].innerHTML=\"\"'><sup>[clear] </sup></span> DataProcessor</div><div style='width:100%; height:200px; overflow-Y:scroll;'> Current state</div><div style='width:100%; height:200px; overflow-Y:scroll;'> Log:</div>";
|
---|
| 15 | if (document.body) document.body.insertBefore(c,document.body.firstChild);
|
---|
| 16 | else dhtmlxEvent(window,"load",function(){
|
---|
| 17 | document.body.insertBefore(c,document.body.firstChild);
|
---|
| 18 | })
|
---|
| 19 | dhtmlxEvent(window,"dblclick",function(){
|
---|
| 20 | c.style.display='';
|
---|
| 21 | })
|
---|
| 22 | return c;
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | dataProcessor.prototype._error=function(data){
|
---|
| 26 | this._log("<span style='color:red'>"+data+"</span>");
|
---|
| 27 | }
|
---|
| 28 | dataProcessor.prototype._log=function(data){
|
---|
| 29 | var div=document.createElement("DIV");
|
---|
| 30 | div.innerHTML = data;
|
---|
| 31 | var parent=this._console.childNodes[2];
|
---|
| 32 | parent.appendChild(div);
|
---|
| 33 | parent.scrollTop=parent.scrollHeight;
|
---|
| 34 |
|
---|
| 35 | if (window.console && window.console.log)
|
---|
| 36 | window.console.log("DataProcessor :: "+data.replace(" "," ").replace("<b>","").replace("</b>",""));
|
---|
| 37 |
|
---|
| 38 | }
|
---|
| 39 | dataProcessor.prototype._updateStat=function(data){
|
---|
| 40 | var data=[" Current state"];
|
---|
| 41 | for(var i=0;i<this.updatedRows.length;i++)
|
---|
| 42 | data.push(" ID:"+this.updatedRows[i]+" Status: "+(this.obj.getUserData(this.updatedRows[i],"!nativeeditor_status")||"updated")+", "+(this.is_invalid(this.updatedRows[i])||"valid"))
|
---|
| 43 | this._console.childNodes[1].innerHTML=data.join("<br/>")+"<hr/>Current mode: "+this.updateMode;
|
---|
| 44 | }
|
---|
| 45 | dataProcessor.prototype.xml_analize=function(xml){
|
---|
| 46 | if (_isFF){
|
---|
| 47 | if (!xml.xmlDoc.responseXML)
|
---|
| 48 | this._error("Not an XML, probably incorrect content type specified ( must be text/xml ), or some text output was started before XML data");
|
---|
| 49 | else if (xml.xmlDoc.responseXML.firstChild.tagName=="parsererror")
|
---|
| 50 | this._error(xml.xmlDoc.responseXML.firstChild.textContent);
|
---|
| 51 | else return true;
|
---|
| 52 | } else if (_isIE){
|
---|
| 53 | if (xml.xmlDoc.responseXML.parseError.errorCode)
|
---|
| 54 | this._error("XML error : "+xml.xmlDoc.responseXML.parseError.reason);
|
---|
| 55 | else if (!xml.xmlDoc.responseXML.documentElement)
|
---|
| 56 | this._error("Not an XML, probably incorrect content type specified ( must be text/xml ), or some text output was started before XML data");
|
---|
| 57 | else return true;
|
---|
| 58 | }
|
---|
| 59 | return false;
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | dataProcessor.wrap=function(name,before,after){
|
---|
| 63 | var d=dataProcessor.prototype;
|
---|
| 64 | if (!d._wrap) d._wrap={};
|
---|
| 65 | d._wrap[name]=d[name];
|
---|
| 66 | d[name]=function(){
|
---|
| 67 | if (before) before.apply(this,arguments);
|
---|
| 68 | var res=d._wrap[name].apply(this,arguments);
|
---|
| 69 | if (after) after.apply(this,[arguments,res]);
|
---|
| 70 | return res;
|
---|
| 71 | }
|
---|
| 72 | };
|
---|
| 73 |
|
---|
| 74 | dataProcessor.wrap("setUpdated",function(rowId,state,mode){
|
---|
| 75 | this._log(" row <b>"+rowId+"</b> "+(state?"marked":"unmarked")+" ["+(mode||"updated")+","+(this.is_invalid(rowId)||"valid")+"]");
|
---|
| 76 | },function(){
|
---|
| 77 | this._updateStat();
|
---|
| 78 | });
|
---|
| 79 |
|
---|
| 80 |
|
---|
| 81 |
|
---|
| 82 | dataProcessor.wrap("sendData",function(rowId){
|
---|
| 83 | if (rowId){
|
---|
| 84 | this._log(" Initiating data sending for <b>"+rowId+"</b>");
|
---|
| 85 | if (this.obj.mytype=="tree"){
|
---|
| 86 | if (!this.obj._idpull[rowId])
|
---|
| 87 | this._log(" Error! item with such ID not exists <b>"+rowId+"</b>");
|
---|
| 88 | } else {
|
---|
| 89 | if (!this.obj.rowsAr[rowId])
|
---|
| 90 | this._log(" Error! row with such ID not exists <b>"+rowId+"</b>");
|
---|
| 91 | }
|
---|
| 92 | }
|
---|
| 93 | },function(){
|
---|
| 94 |
|
---|
| 95 | });
|
---|
| 96 |
|
---|
| 97 | dataProcessor.wrap("sendAllData",function(){
|
---|
| 98 | this._log(" Initiating data sending for <b>all</b> rows ");
|
---|
| 99 | },function(){
|
---|
| 100 |
|
---|
| 101 | });
|
---|
| 102 | dataProcessor.logSingle=function(data,id){
|
---|
| 103 | var tdata = {};
|
---|
| 104 | if (id)
|
---|
| 105 | tdata[id] = data;
|
---|
| 106 | else
|
---|
| 107 | tdata = data;
|
---|
| 108 |
|
---|
| 109 | var url = [];
|
---|
| 110 | for (var key in tdata) {
|
---|
| 111 | url.push("<fieldset><legend>"+key+"</legend>");
|
---|
| 112 | var suburl = [];
|
---|
| 113 |
|
---|
| 114 | for (var ikey in tdata[key])
|
---|
| 115 | suburl.push(ikey+" = "+tdata[key][ikey]);
|
---|
| 116 |
|
---|
| 117 | url.push(suburl.join("<br>"));
|
---|
| 118 | url.push("</fieldset>");
|
---|
| 119 | }
|
---|
| 120 | return url.join("");
|
---|
| 121 | }
|
---|
| 122 | dataProcessor.wrap("_sendData",function(data,rowId){
|
---|
| 123 | if (rowId)
|
---|
| 124 | this._log(" Sending in one-by-one mode, current ID = "+rowId);
|
---|
| 125 | else
|
---|
| 126 | this._log(" Sending all data at once");
|
---|
| 127 | this._log(" Server url: "+this.serverProcessor+" <a onclick='this.parentNode.nextSibling.firstChild.style.display=\"block\"' href='#'>parameters</a>");
|
---|
| 128 | var url = [];
|
---|
| 129 | this._log("<blockquote style='display:none;'>"+dataProcessor.logSingle(data,rowId)+"<blockquote>");
|
---|
| 130 | },function(){
|
---|
| 131 |
|
---|
| 132 | });
|
---|
| 133 |
|
---|
| 134 |
|
---|
| 135 | dataProcessor.wrap("afterUpdate",function(that,b,c,d,xml){
|
---|
| 136 | that._log(" Server response received <a onclick='this.nextSibling.style.display=\"block\"' href='#'>details</a><blockquote style='display:none'><code>"+(xml.xmlDoc.responseText||"").replace(/\&/g,"&").replace(/</g,"<").replace(/>/g,">")+"</code></blockquote>");
|
---|
| 137 | if (!that.xml_analize(xml)) return;
|
---|
| 138 | var atag=xml.doXPath("//data/action");
|
---|
| 139 | if (!atag){
|
---|
| 140 | that._log(" No actions found");
|
---|
| 141 | var atag=xml.getXMLTopNode("data");
|
---|
| 142 | if (!atag) that._log(" XML not valid");
|
---|
| 143 | else that._log(" Incorrect content type - need to be text/xml");
|
---|
| 144 | }
|
---|
| 145 | },function(){
|
---|
| 146 |
|
---|
| 147 | });
|
---|
| 148 |
|
---|
| 149 | dataProcessor.wrap("afterUpdateCallback",function(sid,tid,action){
|
---|
| 150 | if (this.obj.mytype=="tree"){
|
---|
| 151 | if (!this.obj._idpull[sid]) this._log("Incorrect SID, item with such ID not exists in grid");
|
---|
| 152 | } else {
|
---|
| 153 | if (!this.obj.rowsAr[sid]) this._log("Incorrect SID, row with such ID not exists in grid");
|
---|
| 154 | }
|
---|
| 155 | this._log(" Action: "+action+" SID:"+sid+" TID:"+tid);
|
---|
| 156 | },function(){
|
---|
| 157 |
|
---|
| 158 | });
|
---|
| 159 |
|
---|
| 160 |
|
---|
| 161 |
|
---|
| 162 |
|
---|
| 163 |
|
---|
| 164 |
|
---|