PageSourceSearch

https://eproc.poscofuturem.com:8449/pct/js/dhtmlx3/dhtmlxdataprocessor.js

js poscofuturem.com collected 2026-09-25 03:59:42 UTC 12,368 bytes, 328 lines download raw bytes

1//v.3.6 build 131108
2/*
3
4Copyright DHTMLX LTD. http://www.dhtmlx.com
5
6To use this component please contact [email protected] to obtain license
7
8*/
9function dataProcessor(a) {
10    this.serverProcessor = a;
11    this.action_param = "!nativeeditor_status";
12    this.object = null;
13    this.updatedRows = [];
14    this.autoUpdate = !0;
15    this.updateMode = "cell";
16    this._tMode = "GET";
17    this.post_delim = "_";
18    this._waitMode = 0;
19    this._in_progress = {};
20    this._invalid = {};
21    this.mandatoryFields = [];
22    this.messages = [];
23    this.styles = {
24        updated: "font-weight:bold;",
25        inserted: "font-weight:bold;",
26        deleted: "text-decoration : line-through;",
27        invalid: "background-color:FFE0E0;",
28        invalid_cell: "border-bottom:2px solid red;",
29        clear: "font-weight:normal;text-decoration:none;"
30    };
31    this.enableUTFencoding(!0);
32    dhtmlxEventable(this);
33    return this
34}
35dataProcessor.prototype = {
36    setTransactionMode: function (a, b) {
37        this._tMode = a;
38        this._tSend = b
39    },
40    escape: function (a) {
41        return this._utf ? encodeURIComponent(a) : escape(a)
42    },
43    enableUTFencoding: function (a) {
44        this._utf = convertStringToBoolean(a)
45    },
46    setDataColumns: function (a) {
47        this._columns = typeof a == "string" ? a.split(",") : a
48    },
49    getSyncState: function () {
50        return !this.updatedRows.length
51    },
52    enableDataNames: function (a) {
53        this._endnm = convertStringToBoolean(a)
54    },
55    enablePartialDataSend: function (a) {
56        this._changed = convertStringToBoolean(a)
57    },
58    setUpdateMode: function (a,
59        b) {
60        this.autoUpdate = a == "cell";
61        this.updateMode = a;
62        this.dnd = b
63    },
64    ignore: function (a, b) {
65        this._silent_mode = !0;
66        a.call(b || window);
67        this._silent_mode = !1
68    },
69    setUpdated: function (a, b, c) {
70        if (!this._silent_mode) {
71            var d = this.findRow(a),
72                c = c || "updated",
73                e = this.obj.getUserData(a, this.action_param);
74            e && c == "updated" && (c = e);
75            b ? (this.set_invalid(a, !1), this.updatedRows[d] = a, this.obj.setUserData(a, this.action_param, c), this._in_progress[a] && (this._in_progress[a] = "wait")) : this.is_invalid(a) || (this.updatedRows.splice(d, 1), this.obj.setUserData(a,
76                this.action_param, ""));
77            b || this._clearUpdateFlag(a);
78            this.markRow(a, b, c);
79            b && this.autoUpdate && this.sendData(a)
80        }
81    },
82    _clearUpdateFlag: function () {},
83    markRow: function (a, b, c) {
84        var d = "",
85            e = this.is_invalid(a);
86        e && (d = this.styles[e], b = !0);
87        if (this.callEvent("onRowMark", [a, b, c, e]) && (d = this.styles[b ? c : "clear"] + d, this.obj[this._methods[0]](a, d), e && e.details)) {
88            d += this.styles[e + "_cell"];
89            for (var f = 0; f < e.details.length; f++)
90                if (e.details[f]) this.obj[this._methods[1]](a, f, d)
91        }
92    },
93    getState: function (a) {
94        return this.obj.getUserData(a,
95            this.action_param)
96    },
97    is_invalid: function (a) {
98        return this._invalid[a]
99    },
100    set_invalid: function (a, b, c) {
101        c && (b = {
102            value: b,
103            details: c,
104            toString: function () {
105                return this.value.toString()
106            }
107        });
108        this._invalid[a] = b
109    },
110    checkBeforeUpdate: function () {
111        return !0
112    },
113    sendData: function (a) {
114        if (!this._waitMode || !(this.obj.mytype == "tree" || this.obj._h2)) {
115            this.obj.editStop && this.obj.editStop();
116            if (typeof a == "undefined" || this._tSend) return this.sendAllData();
117            if (this._in_progress[a]) return !1;
118            this.messages = [];
119            if (!this.checkBeforeUpdate(a) && this.callEvent("onValidationError", [a, this.messages])) return !1;
120            this._beforeSendData(this._getRowData(a), a)
121        }
122    },
123    _beforeSendData: function (a, b) {
124        if (!this.callEvent("onBeforeUpdate", [b, this.getState(b), a])) return !1;
125        this._sendData(a, b)
126    },
127    serialize: function (a, b) {
128        if (typeof a == "string") return a;
129        if (typeof b != "undefined") return this.serialize_one(a, "");
130        else {
131            var c = [],
132                d = [],
133                e;
134            for (e in a) a.hasOwnProperty(e) && (c.push(this.serialize_one(a[e], e + this.post_delim)), d.push(e));
135            c.push("ids=" + this.escape(d.join(",")));
136            dhtmlx.security_key && c.push("dhx_security=" +
137                dhtmlx.security_key);
138            return c.join("&")
139        }
140    },
141    serialize_one: function (a, b) {
142        if (typeof a == "string") return a;
143        var c = [],
144            d;
145        for (d in a) a.hasOwnProperty(d) && c.push(this.escape((b || "") + d) + "=" + this.escape(a[d]));
146        return c.join("&")
147    },
148    _sendData: function (a, b) {
149        if (a) {
150            if (!this.callEvent("onBeforeDataSending", b ? [b, this.getState(b), a] : [null, null, a])) return !1;
151            b && (this._in_progress[b] = (new Date).valueOf());
152            var c = new dtmlXMLLoaderObject(this.afterUpdate, this, !0),
153                d = this.serverProcessor + (this._user ? getUrlSymbol(this.serverProcessor) + ["dhx_user=" + this._user, "dhx_version=" + this.obj.getUserData(0, "version")].join("&") : "");
154            this._tMode != "POST" ? c.loadXML(d + (d.indexOf("?") != -1 ? "&" : "?") + this.serialize(a, b)) : c.loadXML(d, !0, this.serialize(a, b));
155            this._waitMode++
156        }
157    },
158    sendAllData: function () {
159        if (this.updatedRows.length) {
160            this.messages = [];
161            for (var a = !0, b = 0; b < this.updatedRows.length; b++) a &= this.checkBeforeUpdate(this.updatedRows[b]);
162            if (!a && !this.callEvent("onValidationError", ["", this.messages])) return !1;
163            if (this._tSend) this._sendData(this._getAllData());
164            else
165                for (b = 0; b < this.updatedRows.length; b++)
166                    if (!this._in_progress[this.updatedRows[b]] && !this.is_invalid(this.updatedRows[b]) && (this._beforeSendData(this._getRowData(this.updatedRows[b]), this.updatedRows[b]), this._waitMode && (this.obj.mytype == "tree" || this.obj._h2))) break
167        }
168    },
169    _getAllData: function () {
170        for (var a = {}, b = !1, c = 0; c < this.updatedRows.length; c++) {
171            var d = this.updatedRows[c];
172            !this._in_progress[d] && !this.is_invalid(d) && this.callEvent("onBeforeUpdate", [d, this.getState(d)]) && (a[d] = this._getRowData(d, d + this.post_delim),
173                b = !0, this._in_progress[d] = (new Date).valueOf())
174        }
175        return b ? a : null
176    },
177    setVerificator: function (a, b) {
178        this.mandatoryFields[a] = b || function (a) {
179            return a != ""
180        }
181    },
182    clearVerificator: function (a) {
183        this.mandatoryFields[a] = !1
184    },
185    findRow: function (a) {
186        for (var b = 0, b = 0; b < this.updatedRows.length; b++)
187            if (a == this.updatedRows[b]) break;
188        return b
189    },
190    defineAction: function (a, b) {
191        if (!this._uActions) this._uActions = [];
192        this._uActions[a] = b
193    },
194    afterUpdateCallback: function (a, b, c, d) {
195        var e = a,
196            f = c != "error" && c != "invalid";
197        f || this.set_invalid(a, c);
198        if (this._uActions &&
199            this._uActions[c] && !this._uActions[c](d)) return delete this._in_progress[e];
200        this._in_progress[e] != "wait" && this.setUpdated(a, !1);
201        var g = a;
202        switch (c) {
203        case "inserted":
204        case "insert":
205            b != a && (this.obj[this._methods[2]](a, b), a = b);
206            break;
207        case "delete":
208        case "deleted":
209            return this.obj.setUserData(a, this.action_param, "true_deleted"), this.obj[this._methods[3]](a), delete this._in_progress[e], this.callEvent("onAfterUpdate", [a, c, b, d])
210        }
211        this._in_progress[e] != "wait" ? (f && this.obj.setUserData(a, this.action_param, ""), delete this._in_progress[e]) :
212            (delete this._in_progress[e], this.setUpdated(b, !0, this.obj.getUserData(a, this.action_param)));
213        this.callEvent("onAfterUpdate", [g, c, b, d])
214    },
215    afterUpdate: function (a, b, c, d, e) {
216        e.getXMLTopNode("data");
217        if (e.xmlDoc.responseXML) {
218            for (var f = e.doXPath("//data/action"), g = 0; g < f.length; g++) {
219                var h = f[g],
220                    i = h.getAttribute("type"),
221                    j = h.getAttribute("sid"),
222                    k = h.getAttribute("tid");
223                a.afterUpdateCallback(j, k, i, h)
224            }
225            a.finalizeUpdate()
226        }
227    },
228    finalizeUpdate: function () {
229        this._waitMode && this._waitMode--;
230        (this.obj.mytype == "tree" || this.obj._h2) &&
231            this.updatedRows.length && this.sendData();
232        this.callEvent("onAfterUpdateFinish", []);
233        this.updatedRows.length || this.callEvent("onFullSync", [])
234    },
235    init: function (a) {
236        this.obj = a;
237        this.obj._dp_init && this.obj._dp_init(this)
238    },
239    setOnAfterUpdate: function (a) {
240        this.attachEvent("onAfterUpdate", a)
241    },
242    enableDebug: function () {},
243    setOnBeforeUpdateHandler: function (a) {
244        this.attachEvent("onBeforeDataSending", a)
245    },
246    setAutoUpdate: function (a, b) {
247        a = a || 2E3;
248        this._user = b || (new Date).valueOf();
249        this._need_update = !1;
250        this._loader = null;
251        this._update_busy = !1;
252        this.attachEvent("onAfterUpdate", function (a, b, c, g) {
253            this.afterAutoUpdate(a, b, c, g)
254        });
255        this.attachEvent("onFullSync", function () {
256            this.fullSync()
257        });
258        var c = this;
259        window.setInterval(function () {
260            c.loadUpdate()
261        }, a)
262    },
263    afterAutoUpdate: function (a, b) {
264        return b == "collision" ? (this._need_update = !0, !1) : !0
265    },
266    fullSync: function () {
267        if (this._need_update == !0) this._need_update = !1, this.loadUpdate();
268        return !0
269    },
270    getUpdates: function (a, b) {
271        if (this._update_busy) return !1;
272        else this._update_busy = !0;
273        this._loader = this._loader || new dtmlXMLLoaderObject(!0);
274        this._loader.async = !0;
275        this._loader.waitCall = b;
276        this._loader.loadXML(a)
277    },
278    _v: function (a) {
279        return a.firstChild ? a.firstChild.nodeValue : ""
280    },
281    _a: function (a) {
282        for (var b = [], c = 0; c < a.length; c++) b[c] = this._v(a[c]);
283        return b
284    },
285    loadUpdate: function () {
286        var a = this,
287            b = this.obj.getUserData(0, "version"),
288            c = this.serverProcessor + getUrlSymbol(this.serverProcessor) + ["dhx_user=" + this._user, "dhx_version=" + b].join("&"),
289            c = c.replace("editing=true&", "");
290        this.getUpdates(c, function () {
291            var b = a._loader.doXPath("//userdata");
292            a.obj.setUserData(0,
293                "version", a._v(b[0]));
294            var c = a._loader.doXPath("//update");
295            if (c.length) {
296                a._silent_mode = !0;
297                for (var f = 0; f < c.length; f++) {
298                    var g = c[f].getAttribute("status"),
299                        h = c[f].getAttribute("id"),
300                        i = c[f].getAttribute("parent");
301                    switch (g) {
302                    case "inserted":
303                        a.callEvent("insertCallback", [c[f], h, i]);
304                        break;
305                    case "updated":
306                        a.callEvent("updateCallback", [c[f], h, i]);
307                        break;
308                    case "deleted":
309                        a.callEvent("deleteCallback", [c[f], h, i])
310                    }
311                }
312                a._silent_mode = !1
313            }
314            a._update_busy = !1;
315            a = null
316        })
317    }
318};
319
320//v.3.6 build 131108
321
322/*
323
324Copyright DHTMLX LTD. http://www.dhtmlx.com
325
326To use this component please contact [email protected] to obtain license
327
328*/

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.