source: branches/2.2.0.1/calendar/js/dhtmlx/sources/dhtmlxdataprocessor_debug.js @ 4001

Revision 4001, 6.2 KB checked in by rafaelraymundo, 13 years ago (diff)

Ticket #1615 - Componente novo para agenda......................................

Line 
1dataProcessor.prototype._o_init = dataProcessor.prototype.init;
2dataProcessor.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
11dataProcessor.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]&nbsp;</sup></span><span style='cursor:pointer;float:right;' onclick='this.parentNode.parentNode.childNodes[2].innerHTML=\"\"'><sup>[clear]&nbsp;</sup></span>&nbsp;DataProcessor</div><div style='width:100%; height:200px; overflow-Y:scroll;'>&nbsp;Current state</div><div style='width:100%; height:200px; overflow-Y:scroll;'>&nbsp;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
25dataProcessor.prototype._error=function(data){
26        this._log("<span style='color:red'>"+data+"</span>");
27}
28dataProcessor.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("&nbsp;"," ").replace("<b>","").replace("</b>",""));
37   
38}
39dataProcessor.prototype._updateStat=function(data){
40    var data=["&nbsp;Current state"];
41    for(var i=0;i<this.updatedRows.length;i++)
42            data.push("&nbsp;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}
45dataProcessor.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
62dataProcessor.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
74dataProcessor.wrap("setUpdated",function(rowId,state,mode){
75        this._log("&nbsp;row <b>"+rowId+"</b> "+(state?"marked":"unmarked")+" ["+(mode||"updated")+","+(this.is_invalid(rowId)||"valid")+"]");
76},function(){
77        this._updateStat();
78});
79
80
81
82dataProcessor.wrap("sendData",function(rowId){
83        if (rowId){
84                this._log("&nbsp;Initiating data sending for <b>"+rowId+"</b>");
85                if (this.obj.mytype=="tree"){
86                if (!this.obj._idpull[rowId])
87                        this._log("&nbsp;Error! item with such ID not exists <b>"+rowId+"</b>");
88                } else {
89                        if (!this.obj.rowsAr[rowId])
90                        this._log("&nbsp;Error! row with such ID not exists <b>"+rowId+"</b>");
91        }
92        }
93},function(){
94       
95});
96
97dataProcessor.wrap("sendAllData",function(){
98        this._log("&nbsp;Initiating data sending for <b>all</b> rows ");
99},function(){
100       
101});
102dataProcessor.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}
122dataProcessor.wrap("_sendData",function(data,rowId){
123        if (rowId)
124                this._log("&nbsp;Sending in one-by-one mode, current ID = "+rowId);
125        else
126                this._log("&nbsp;Sending all data at once");
127        this._log("&nbsp;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
135dataProcessor.wrap("afterUpdate",function(that,b,c,d,xml){
136        that._log("&nbsp;Server response received <a onclick='this.nextSibling.style.display=\"block\"' href='#'>details</a><blockquote style='display:none'><code>"+(xml.xmlDoc.responseText||"").replace(/\&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")+"</code></blockquote>");                   
137        if (!that.xml_analize(xml)) return;
138        var atag=xml.doXPath("//data/action");
139        if (!atag){
140                that._log("&nbsp;No actions found");
141                var atag=xml.getXMLTopNode("data");
142                if (!atag) that._log("&nbsp;XML not valid");
143                else that._log("&nbsp;Incorrect content type - need to be text/xml");
144        }
145},function(){
146       
147});
148
149dataProcessor.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("&nbsp;Action: "+action+" SID:"+sid+" TID:"+tid);
156},function(){
157       
158});
159
160
161
162
163
164
Note: See TracBrowser for help on using the repository browser.