summaryrefslogtreecommitdiffstats
path: root/codebase/sources/ext/dhtmlxscheduler_offline.js
blob: ae6e1e60fc2b77be31669bcffe1040dce4dd906a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
@license
dhtmlxScheduler v.4.3.1 

This software is covered by GPL license. You also can obtain Commercial or Enterprise license to use it in non-GPL project - please contact sales@dhtmlx.com. Usage without proper license is prohibited.

(c) Dinamenta, UAB.
*/
scheduler.load=function(url,call){
	var type;
	if (typeof call == "string"){
		this._process=call;
		type = call;
		call = arguments[2];
	}

	this._load_url=url;
	this._after_call=call;
	if (url.$proxy) {
		url.load(this, typeof type == "string" ? type : null);
		return;
	}

	this._load(url,this._date);
};

scheduler._dp_init_backup = scheduler._dp_init;
scheduler._dp_init = function(dp) {
	dp._sendData = function(a1,rowId){
    	if (!a1) return; //nothing to send
		if (!this.callEvent("onBeforeDataSending",rowId?[rowId,this.getState(rowId),a1]:[null, null, a1])) return false;				
    	if (rowId)
			this._in_progress[rowId]=(new Date()).valueOf();
		if (this.serverProcessor.$proxy) {
			var mode = this._tMode!="POST" ? 'get' : 'post';
			var to_send = [];
			for (var i in a1)
				to_send.push({ id: i, data: a1[i], operation: this.getState(i)});
			this.serverProcessor._send(to_send, mode, this);
			return;
		}

		var a2=new dtmlXMLLoaderObject(this.afterUpdate,this,true);
		var a3 = this.serverProcessor+(this._user?(getUrlSymbol(this.serverProcessor)+["dhx_user="+this._user,"dhx_version="+this.obj.getUserData(0,"version")].join("&")):"");
		if (this._tMode!="POST")
        	a2.loadXML(a3+((a3.indexOf("?")!=-1)?"&":"?")+this.serialize(a1,rowId));
		else
        	a2.loadXML(a3,true,this.serialize(a1,rowId));
		this._waitMode++;
    };
	
	dp._updatesToParams = function(items) {
		var stack = {};
		for (var i = 0; i < items.length; i++)
			stack[items[i].id] = items[i].data;
		return this.serialize(stack);
	};

	dp._processResult = function(text, xml, loader) {
		if (loader.status != 200) {
			for (var i in this._in_progress) {
				var state = this.getState(i);
				this.afterUpdateCallback(i, i, state, null);
			}
			return;
		}
		xml = new dtmlXMLLoaderObject(function() {},this,true);
		xml.loadXMLString(text);
		xml.xmlDoc = loader;

		this.afterUpdate(this, null, null, null, xml);
	};
	this._dp_init_backup(dp);
};

if (window.dataProcessor)
	dataProcessor.prototype.init=function(obj){
		this.init_original(obj);
		obj._dataprocessor=this;
		
		this.setTransactionMode("POST",true);
		if (!this.serverProcessor.$proxy)
			this.serverProcessor+=(this.serverProcessor.indexOf("?")!=-1?"&":"?")+"editing=true";
	};