@lmjs/core 1.0.7 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4143 @@
1
+ !function (a, b) {
2
+ "function" == typeof define && define.amd ? define([], b) : "undefined" != typeof module && module.exports ? module.exports = b() : a.ReconnectingWebSocket = b()
3
+ }(this, function () {
4
+ function a(b, c, d) {
5
+ function l(a, b) {
6
+ var c = document.createEvent("CustomEvent");
7
+ return c.initCustomEvent(a, !1, !1, b), c
8
+ }
9
+ var e = {
10
+ debug: !1,
11
+ automaticOpen: !0,
12
+ reconnectInterval: 1e3,
13
+ maxReconnectInterval: 3e4,
14
+ reconnectDecay: 1,
15
+ timeoutInterval: 3e3
16
+ };
17
+ d || (d = {});
18
+ for (var f in e) this[f] = "undefined" != typeof d[f] ? d[f] : e[f];
19
+ this.url = b, this.reconnectAttempts = 0, this.readyState = WebSocket.CONNECTING, this.protocol = null;
20
+ var h, g = this,
21
+ i = !1,
22
+ j = !1,
23
+ k = document.createElement("div");
24
+ k.addEventListener("open", function (a) {
25
+ g.onopen(a)
26
+ }), k.addEventListener("close", function (a) {
27
+ g.onclose(a)
28
+ }), k.addEventListener("connecting", function (a) {
29
+ g.onconnecting(a)
30
+ }), k.addEventListener("message", function (a) {
31
+ g.onmessage(a)
32
+ }), k.addEventListener("error", function (a) {
33
+ g.onerror(a)
34
+ }), this.addEventListener = k.addEventListener.bind(k), this.removeEventListener = k.removeEventListener.bind(k), this.dispatchEvent = k.dispatchEvent.bind(k), this.open = function (b) {
35
+
36
+ try {
37
+ h = new WebSocket(g.url, c || []), b || k.dispatchEvent(l("connecting")), (g.debug || a.debugAll) && console.debug("ReconnectingWebSocket", "attempt-connect", g.url);
38
+ var d = h,
39
+ e = setTimeout(function () {
40
+ (g.debug || a.debugAll) && console.debug("ReconnectingWebSocket", "connection-timeout", g.url), j = !0, j = !1;
41
+ if (d.readyState == 1) d.close();
42
+ }, g.timeoutInterval);
43
+ h.onopen = function () {
44
+ clearTimeout(e), (g.debug || a.debugAll) && console.debug("ReconnectingWebSocket", "onopen", g.url), g.protocol = h.protocol, g.readyState = WebSocket.OPEN, g.reconnectAttempts = 0;
45
+ var d = l("open");
46
+ d.isReconnect = b, b = !1, k.dispatchEvent(d)
47
+ }, h.onclose = function (c) {
48
+ if (clearTimeout(e), h = null, i) g.readyState = WebSocket.CLOSED, k.dispatchEvent(l("close"));
49
+ else {
50
+ g.readyState = WebSocket.CONNECTING;
51
+ var d = l("connecting");
52
+ d.code = c.code, d.reason = c.reason, d.wasClean = c.wasClean, k.dispatchEvent(d), b || j || ((g.debug || a.debugAll) && console.debug("ReconnectingWebSocket", "onclose", g.url), k.dispatchEvent(l("close")));
53
+ var e = g.reconnectInterval * Math.pow(g.reconnectDecay, g.reconnectAttempts);
54
+ setTimeout(function () {
55
+ g.reconnectAttempts++, g.open(!0)
56
+ }, e > g.maxReconnectInterval ? g.maxReconnectInterval : e)
57
+ }
58
+ }, h.onmessage = function (b) {
59
+ (g.debug || a.debugAll) && console.debug("ReconnectingWebSocket", "onmessage", g.url, b.data);
60
+ var c = l("message");
61
+ c.data = b.data, k.dispatchEvent(c)
62
+ }, h.onerror = function (b) {
63
+ (g.debug || a.debugAll) && console.debug("ReconnectingWebSocket", "onerror", g.url, b), k.dispatchEvent(l("error"))
64
+ }
65
+
66
+ } catch (error) {
67
+ // Handle the WebSocket connection error here
68
+ console.error('WebSocket connection error:', error);
69
+ }
70
+ }, 1 == this.automaticOpen && this.open(!1), this.send = function (b) {
71
+ if (h) return (g.debug || a.debugAll) && console.debug("ReconnectingWebSocket", "send", g.url, b), h.send(b);
72
+ throw "INVALID_STATE_ERR : Pausing to reconnect websocket"
73
+ }, this.close = function (a, b) {
74
+ "undefined" == typeof a && (a = 1e3), i = !0, h && h.close(a, b)
75
+ }, this.refresh = function () {
76
+ h && h.readyState == 1 && h.close()
77
+ }
78
+ }
79
+ return a.prototype.onopen = function () { }, a.prototype.onclose = function () { }, a.prototype.onconnecting = function () { }, a.prototype.onmessage = function () { }, a.prototype.onerror = function () { }, a.debugAll = !1, a.CONNECTING = WebSocket.CONNECTING, a.OPEN = WebSocket.OPEN, a.CLOSING = WebSocket.CLOSING, a.CLOSED = WebSocket.CLOSED, a
80
+ });
81
+
82
+ let _isTipped = false;
83
+ var _debugMode = false;
84
+ var _initialized = null;
85
+ var _dbcrs = {};
86
+ var _dbcrsTime = 200;
87
+ var _tickTime = 20;
88
+ var _scW = 0;
89
+ var cl = console.log;
90
+ if (!_vcData) var _vcData = undefined;
91
+ if (!_beaTn) var _beaTn = undefined;
92
+ var beas;
93
+ var appSettings;
94
+ var execEl = "";
95
+ var currentlyValidTags = new Array();
96
+ // var _upwrk = new WebWorker('/js/wRaws/up.js');
97
+ var _upwrk = new WebWorker('_upw');
98
+ // var _csswrk = new WebWorker('/js/csswrk.js');
99
+ var _csswrk = new WebWorker('_cssw');
100
+ // var _jswacrk = new WebWorker('_jswac');
101
+ // _jswacrk.start();
102
+ // _upwrk.start();
103
+ _csswrk.start();
104
+ var _ups = [];
105
+
106
+ (function (e, t) {
107
+ typeof module != "undefined" && module.exports
108
+ ? (module.exports = t())
109
+ : typeof define == "function" && define.amd
110
+ ? define(t)
111
+ : (this[e] = t());
112
+ })("bea", function () {
113
+ function p(e, t) {
114
+ for (var n = 0, i = e.length; n < i; ++n) if (!t(e[n])) return r;
115
+ return 1;
116
+ }
117
+ function d(e, t) {
118
+ p(e, function (e) {
119
+ return t(e), 1;
120
+ });
121
+ }
122
+ function v(e, t, n) {
123
+ function g(e) {
124
+ return e.call ? e() : u[e];
125
+ }
126
+ function y() {
127
+ if (!--h) {
128
+ (u[o] = 1), s && s();
129
+ for (var e in f) p(e.split("|"), g) && !d(f[e], g) && (f[e] = []);
130
+ }
131
+ }
132
+ e = e[i] ? e : [e];
133
+ var r = t && t.call,
134
+ s = r ? t : n,
135
+ o = r ? e.join("") : t,
136
+ h = e.length;
137
+ return (
138
+ setTimeout(function () {
139
+ d(e, function t(e, n) {
140
+ if (e === null) return y();
141
+ /*!n &&
142
+ !/^https?:\/\//.test(e) &&
143
+ c &&
144
+ (e = e.indexOf(".js") === -1 ? c + e + ".js" : c + e);*/
145
+ if (l[e])
146
+ return (
147
+ o && (a[o] = 1),
148
+ l[e] == 2
149
+ ? y()
150
+ : setTimeout(function () {
151
+ t(e, !0);
152
+ }, 0)
153
+ );
154
+ (l[e] = 1), o && (a[o] = 1), m(e, y);
155
+ });
156
+ }, 0),
157
+ v
158
+ );
159
+ }
160
+ function m(n, r) {
161
+ var i = e.createElement("script"),
162
+ u;
163
+ (i.onload =
164
+ i.onerror =
165
+ i[o] =
166
+ function () {
167
+ if ((i[s] && !/^c|loade/.test(i[s])) || u) return;
168
+ (i.onload = i[o] = null), (u = 1), (l[n] = 2), r();
169
+ }),
170
+ (i.async = 1),
171
+ i.setAttribute("crossorigin", "anonymous"),
172
+ i.setAttribute("data-permanent", 1),
173
+ (i.src = h ? n + (n.indexOf("?") === -1 ? "?" : "&") + h : n),
174
+ t.insertBefore(i, t.lastChild);
175
+ }
176
+ var e = document,
177
+ t = e.getElementsByTagName("head")[0],
178
+ n = "string",
179
+ r = !1,
180
+ i = "push",
181
+ s = "readyState",
182
+ o = "onreadystatechange",
183
+ u = {},
184
+ a = {},
185
+ f = {},
186
+ l = {},
187
+ c,
188
+ h;
189
+ return (
190
+ (v.get = m),
191
+ (v.order = function (e, t, n) {
192
+ (function r(i) {
193
+ (i = e.shift()), e.length ? v(i, r) : v(i, t, n);
194
+ })();
195
+ }),
196
+ (v.path = function (e) {
197
+ c = e;
198
+ }),
199
+ (v.urlArgs = function (e) {
200
+ h = e;
201
+ }),
202
+ (v.ready = function (e, t, n) {
203
+ e = e[i] ? e : [e];
204
+ var r = [];
205
+ return (
206
+ !d(e, function (e) {
207
+ u[e] || r[i](e);
208
+ }) &&
209
+ p(e, function (e) {
210
+ return u[e];
211
+ })
212
+ ? t()
213
+ : !(function (e) {
214
+ (f[e] = f[e] || []), f[e][i](t), n && n(r);
215
+ })(e.join("|")),
216
+ v
217
+ );
218
+ }),
219
+ (v.done = function (e) {
220
+ v([null], e);
221
+ }),
222
+ v
223
+ );
224
+ });
225
+
226
+ (function (n, t) {
227
+ this[n] = t();
228
+ })("sbea", function () {
229
+ return function (x) {
230
+ beas = x;
231
+ };
232
+ });
233
+
234
+ (function (n, t) {
235
+ this[n] = t();
236
+ })("Reactor", function () {
237
+ return function (o) {
238
+ appSettings = o;
239
+ if (o.Base) beas = o.Base;
240
+ else {
241
+ var getUrl = window.location;
242
+ var baseUrl = getUrl.protocol + "//" + getUrl.host + "/";
243
+ if (o.subDirectory) baseUrl = baseUrl + o.subDirectory + "/";
244
+ appSettings.Base = baseUrl;
245
+ }
246
+ if (o.App) execEl = o.App;
247
+ if (o.Additional) {
248
+ bea([o.Additional], "ready", function () { });
249
+ }
250
+ // 2026-09-18, real bug found and fixed: Reactor({init, tick, auth})
251
+ // is documented (lumenjs-spec.md §3, llms.md §3) and real V1 projects
252
+ // depend on it (app-wide bootstrap work in init() — auth/session
253
+ // setup, an SDK instance like `rx = new RX(...)`/`bea = new BEA(...)`,
254
+ // globals defaults; periodic work in tick(), e.g. re-highlighting
255
+ // code blocks after every render) — but nothing in this whole
256
+ // runtime ever read o.init/o.tick/o.auth at all. A real, unrelated-
257
+ // looking function (setAppFuncs(), earlier in this same file) does
258
+ // check appSettings.init — but is itself never called from
259
+ // anywhere in the shipped runtime, dead code calling more dead
260
+ // code. Confirmed via a real migrated V1 project end-to-end:
261
+ // `init()`-set globals (`globals.Settings`, an `rx`/`bea` SDK
262
+ // instance) were silently never set, with no error at all — every
263
+ // reference to them elsewhere threw "not defined" instead, easy to
264
+ // misdiagnose as an unrelated data/scoping bug (which is exactly
265
+ // what this took real, extensive tracing to rule out).
266
+ // init(): synchronous, called once, right here — Reactor(o) itself
267
+ // is always the first thing a real index.js does, before whatever
268
+ // triggers the first render (the ready-handler retry guard
269
+ // elsewhere in this file already waits on appSettings.Base, set
270
+ // just above, so no render can start before this function returns).
271
+ if (o.init && typeof o.init === "function") o.init();
272
+ // tick(): "after every re-render, anywhere" (documented) — hooked
273
+ // into _lm.prototype.renderAll in _re.js instead of duplicated
274
+ // here; see that file's own comment for why there, not here.
275
+ };
276
+ });
277
+
278
+ var fullTB = [
279
+ {
280
+ items: [
281
+ "Source",
282
+ "-",
283
+ "searchCode",
284
+ "autoFormat",
285
+ "CommentSelectedRange",
286
+ "UncommentSelectedRange",
287
+ "AutoComplete",
288
+ "-",
289
+ "Save",
290
+ "NewPage",
291
+ "Preview",
292
+ "Print",
293
+ "-",
294
+ "Templates",
295
+ "-",
296
+ "Cut",
297
+ "Copy",
298
+ "Paste",
299
+ "PasteText",
300
+ "PasteFromWord",
301
+ "PasteCode",
302
+ "-",
303
+ "Undo",
304
+ "Redo",
305
+ "-",
306
+ "SelectAll",
307
+ "-",
308
+ "Find",
309
+ "-",
310
+ "Image",
311
+ "CodeSnippet",
312
+ "Flash",
313
+ "Table",
314
+ "HorizontalRule",
315
+ "Smiley",
316
+ "SpecialChar",
317
+ "PageBreak",
318
+ "Iframe",
319
+ "VideoDetector",
320
+ "-",
321
+ "Blockquote",
322
+ "CreateDiv",
323
+ "simplebutton",
324
+ "-",
325
+ "Link",
326
+ "Unlink",
327
+ "Anchor",
328
+ "-",
329
+ "TextColor",
330
+ "BGColor",
331
+ "-",
332
+ "Bold",
333
+ "Italic",
334
+ "Underline",
335
+ "Strike",
336
+ "Subscript",
337
+ "Superscript",
338
+ "-",
339
+ "JustifyLeft",
340
+ "JustifyCenter",
341
+ "JustifyRight",
342
+ "JustifyBlock",
343
+ "-",
344
+ "BidiLtr",
345
+ "BidiRtl",
346
+ "-",
347
+ "NumberedList",
348
+ "BulletedList",
349
+ "-",
350
+ "Outdent",
351
+ "Indent",
352
+ "-",
353
+ "CopyFormatting",
354
+ "RemoveFormat",
355
+ "-",
356
+ "lineheight",
357
+ "letterspacing",
358
+ "Styles",
359
+ "Format",
360
+ "Font",
361
+ "FontSize",
362
+ "-",
363
+ "ShowBlocks",
364
+ ],
365
+ },
366
+ ];
367
+
368
+ var normalTB = [
369
+ {
370
+ name: "basicstyles",
371
+ groups: ["basicstyles", "cleanup"],
372
+ items: [
373
+ "Bold",
374
+ "Italic",
375
+ "Underline",
376
+ "Strike",
377
+ "Subscript",
378
+ "Superscript",
379
+ "-",
380
+ "JustifyLeft",
381
+ "JustifyCenter",
382
+ "JustifyRight",
383
+ "JustifyBlock",
384
+ "-",
385
+ "BidiLtr",
386
+ "BidiRtl",
387
+ "Language",
388
+ "-",
389
+ "Undo",
390
+ "Redo",
391
+ "-",
392
+ "SelectAll",
393
+ "-",
394
+ "CopyFormatting",
395
+ "RemoveFormat",
396
+ ],
397
+ },
398
+ "/",
399
+ {
400
+ items: [
401
+ "Find",
402
+ "-",
403
+ "Image",
404
+ "Table",
405
+ "HorizontalRule",
406
+ "Smiley",
407
+ "SpecialChar",
408
+ "Iframe",
409
+ "VideoDetector",
410
+ "-",
411
+ "Link",
412
+ "Unlink",
413
+ "Anchor",
414
+ ],
415
+ },
416
+ {
417
+ name: "paragraph",
418
+ groups: ["list", "indent", "blocks", "align", "bidi"],
419
+ items: [
420
+ "TextColor",
421
+ "BGColor",
422
+ "-",
423
+ "NumberedList",
424
+ "BulletedList",
425
+ "-",
426
+ "Outdent",
427
+ "Indent",
428
+ ],
429
+ },
430
+ "/",
431
+ {
432
+ name: "styles",
433
+ items: [
434
+ "lineheight",
435
+ "letterspacing",
436
+ "Styles",
437
+ "Format",
438
+ "Font",
439
+ "FontSize",
440
+ ],
441
+ },
442
+ ];
443
+
444
+ var miniTB = [
445
+ {
446
+ name: "basicstyles",
447
+ groups: ["basicstyles", "cleanup"],
448
+ items: [
449
+ "Bold",
450
+ "Italic",
451
+ "Underline",
452
+ "Strike",
453
+ "Subscript",
454
+ "Superscript",
455
+ "-",
456
+ "JustifyLeft",
457
+ "JustifyCenter",
458
+ "JustifyRight",
459
+ "JustifyBlock",
460
+ "-",
461
+ "BidiLtr",
462
+ "BidiRtl",
463
+ "Language",
464
+ "-",
465
+ "Link",
466
+ "Unlink",
467
+ "Anchor",
468
+ "-",
469
+ "CopyFormatting",
470
+ "RemoveFormat",
471
+ ],
472
+ },
473
+ "/",
474
+ {
475
+ name: "paragraph",
476
+ groups: ["list", "indent", "blocks", "align", "bidi"],
477
+ items: [
478
+ "TextColor",
479
+ "BGColor",
480
+ "-",
481
+ "NumberedList",
482
+ "BulletedList",
483
+ "-",
484
+ "Outdent",
485
+ "Indent",
486
+ ],
487
+ },
488
+ { name: "styles", items: ["Styles", "Format", "Font", "FontSize"] },
489
+ ];
490
+
491
+ (function (submit) {
492
+ HTMLFormElement.prototype.submit = function (data) {
493
+ $(this).submit();
494
+ return false;
495
+ // submit.call(this, data);
496
+ };
497
+ })(HTMLFormElement.prototype.submit);
498
+
499
+ HTMLElement.prototype.setAttributeNative = HTMLElement.prototype.setAttribute;
500
+ HTMLElement.prototype.removeAttributeNative = HTMLElement.prototype.removeAttribute;
501
+ HTMLElement.prototype.getAttributeNative = HTMLElement.prototype.getAttribute;
502
+ (function (setAttribute) {
503
+ HTMLElement.prototype.setAttribute = function (prop, val) {
504
+ if (prop.substr(0, 1) == "@") {
505
+ try {
506
+ this.events[prop] = val;
507
+ } catch (e) {
508
+
509
+ }
510
+ } else {
511
+ this.setAttributeNative(prop, val);
512
+ }
513
+ };
514
+ })(HTMLElement.prototype.setAttribute);
515
+ (function (removeAttribute) {
516
+ HTMLElement.prototype.removeAttribute = function (prop, val) {
517
+ if (prop.substr(0, 1) == "@") {
518
+ try {
519
+ delete this.events[prop];
520
+ } catch (e) {
521
+
522
+ }
523
+ } else {
524
+ this.removeAttributeNative(prop, val);
525
+ }
526
+ };
527
+ })(HTMLElement.prototype.removeAttribute);
528
+ (function (getAttribute) {
529
+ HTMLElement.prototype.getAttribute = function (prop, val) {
530
+ if (prop.substr(0, 1) == "@") {
531
+ try {
532
+ return this.events[prop];
533
+ } catch (e) {
534
+ return this.getAttributeNative(prop, val);
535
+ }
536
+ } else {
537
+ return this.getAttributeNative(prop, val);
538
+ }
539
+ };
540
+ })(HTMLElement.prototype.getAttribute);
541
+
542
+ /*jolie */
543
+ // (function(){
544
+ // // Store a reference to the original remove method.
545
+ // var originalRemoveMethod = jQuery.fn.append;
546
+ // // Define overriding method.
547
+ // jQuery.fn.append = function(){
548
+ // cl("arguments ",arguments)
549
+ // // Execute the original method.
550
+ // // originalRemoveMethod.apply( this, arguments);
551
+ // }
552
+ // })();
553
+
554
+ var XHRs = new Array();
555
+ if (localStorage.getItem("globals") === null)
556
+ localStorage.setItem("globals", JSON.stringify({}));
557
+ if (localStorage.getItem("_rx") === null)
558
+ localStorage.setItem("_rx", JSON.stringify({}));
559
+ var globals = clone(JSON.parse(localStorage.getItem("globals")));
560
+ let _rx = clone(JSON.parse(localStorage.getItem("_rx")));
561
+ var watch = {};
562
+ var popups = {
563
+ "modals": [],
564
+ "react-modals": [],
565
+ };
566
+ var cntrlon = 0;
567
+ var _gn = 0,
568
+ _worker;
569
+ var nodes = [];
570
+
571
+ var _jsuid = {};
572
+ // 'use strict';
573
+
574
+
575
+ // _jswacrk.on('msg', function (e) {
576
+ // let data = e.originalEvent.data;
577
+ // _vuid[data.key].resolve(data);
578
+ // });
579
+
580
+
581
+ function clone(item) {
582
+ if (!item) {
583
+ return item;
584
+ }
585
+
586
+ var types = [Number, String, Boolean],
587
+ result;
588
+
589
+ types.forEach(function (type) {
590
+ if (item instanceof type) {
591
+ result = type(item);
592
+ }
593
+ });
594
+
595
+ if (typeof result == "undefined") {
596
+ if (Object.prototype.toString.call(item) === "[object Array]") {
597
+ result = [];
598
+ item.forEach(function (child, index, array) {
599
+ result[index] = clone(child);
600
+ });
601
+ } else if (typeof item == "object") {
602
+ if (item.nodeType && typeof item.cloneNode == "function") {
603
+ result = item.cloneNode(true);
604
+ } else if (!item.prototype) {
605
+ if (item instanceof Date) {
606
+ result = new Date(item);
607
+ } else {
608
+ result = {};
609
+ for (var i in item) {
610
+ result[i] = clone(item[i]);
611
+ }
612
+ }
613
+ } else {
614
+ if (false && item.constructor) {
615
+ result = new item.constructor();
616
+ } else {
617
+ result = item;
618
+ }
619
+ }
620
+ } else {
621
+ result = item;
622
+ }
623
+ }
624
+
625
+ return result;
626
+ }
627
+
628
+ function isInput(o) {
629
+ if (
630
+ o.is(":checkbox") ||
631
+ o.is("input") ||
632
+ o.is("textarea") ||
633
+ o.is(":radio") ||
634
+ o.is("select")
635
+ )
636
+ return true;
637
+ return false;
638
+ }
639
+
640
+ function getVal(o) {
641
+ if (isInput(o)) {
642
+ return $.trim(o.val());
643
+ }
644
+ return o.html();
645
+ }
646
+
647
+ function setVal(o, v) {
648
+ if (isInput(o)) {
649
+ o.val(v);
650
+ } else o.html(v);
651
+ }
652
+
653
+ function iterateConditions(text) {
654
+ var results = [];
655
+ var opts = text.split("##");
656
+ var iff = opts.shift();
657
+ opts = opts.join("##");
658
+ if (opts.indexOf("#else#") > -1) var hasElse = true;
659
+ if (opts.indexOf("#elseif#") > -1) var hasElseIfs = true;
660
+ if (hasElse) {
661
+ opts = opts.split("#else#");
662
+ var elsee = opts.pop();
663
+ opts = opts.join("");
664
+ }
665
+ if (hasElseIfs) {
666
+ results["elseif"] = [];
667
+ var elseifs = opts.split("#elseif#");
668
+ var ifOpts = elseifs.shift();
669
+ results["if"] = { cond: iff, val: ifOpts };
670
+ for (var index = 0; index < elseifs.length; index++) {
671
+ var elf = elseifs[index].split("##");
672
+ results["elseif"].push({ cond: elf[0], val: elf[1] });
673
+ }
674
+ if (hasElse) results["else"] = elsee;
675
+ } else if (hasElse) {
676
+ results["if"] = { cond: iff, val: opts };
677
+ if (hasElse) results["else"] = elsee;
678
+ } else {
679
+ results["if"] = { cond: iff, val: opts };
680
+ }
681
+ return results;
682
+ }
683
+
684
+ function wait() {
685
+ _loader.show();
686
+ _initialized = false;
687
+ }
688
+ function resume() {
689
+ _loader.hide();
690
+ _initialized = true;
691
+ }
692
+
693
+ const pause = (msec) => new Promise((resolve, _) => {
694
+ setTimeout(resolve, msec);
695
+ });
696
+
697
+ // 2026-09-14: guarded against firing before Reactor() has run (which sets
698
+ // appSettings, read by getURLNodes() below) — found testing a real project
699
+ // end-to-end. $(document).ready() fires SYNCHRONOUSLY, at registration
700
+ // time, whenever the document is already non-"loading" by the time this
701
+ // line runs, which this framework's own single, large concatenated bundle
702
+ // reliably triggers in practice. index.js (the only thing that calls
703
+ // Reactor()) is loaded and run separately — see index-bootstrap.js — and
704
+ // there's no ordering guarantee between that and this registration.
705
+ // Retries on a short timer instead, matching the same "hasn't loaded yet"
706
+ // pattern renderView() already uses elsewhere in this codebase.
707
+ function _lumenReadyHandler() {
708
+ if (typeof appSettings === 'undefined' || !appSettings) {
709
+ setTimeout(_lumenReadyHandler, 10);
710
+ return;
711
+ }
712
+ nodes = getURLNodes();
713
+
714
+ if (_initialized == null) _initialized = true;
715
+ $("html").removeClass("no_js");
716
+ // $('script:not("[tpl],[type="beajs"],[_dd]")').remove();
717
+ if (!$("[exec]").length)
718
+ $("body").append({ beajs: true, body: "<div exec class=h></div>" });
719
+ $(document).keyup(function (e) {
720
+ cntrlon = 0;
721
+ });
722
+ $(document).keydown(function (e) {
723
+ if (e.ctrlKey || e.metaKey) {
724
+ cntrlon = 1;
725
+ }
726
+ });
727
+ goToNode();
728
+ }
729
+ $(document).ready(_lumenReadyHandler);
730
+
731
+ function updateLocalVariable(k) {
732
+ if (k == "_rx") _rx = clone(JSON.parse(localStorage.getItem("_rx")));
733
+ else globals = clone(JSON.parse(localStorage.getItem("globals")));
734
+ }
735
+
736
+ function setGlobals(x) {
737
+ localStorage.setItem("globals", JSON.stringify(x));
738
+ globals = clone(JSON.parse(localStorage.getItem("globals")));
739
+ }
740
+
741
+ function setRX(x) {
742
+ localStorage.setItem("_rx", JSON.stringify(x));
743
+ _rx = clone(JSON.parse(localStorage.getItem("_rx")));
744
+ }
745
+
746
+ $(window).on("storage", function (e) {
747
+ if (e.originalEvent.key == "globals") {
748
+ if (localStorage.getItem("globals") != null) updateLocalVariable();
749
+ else setGlobals(globals);
750
+ } else if (e.originalEvent.key == "_rx") {
751
+ if (localStorage.getItem("_rx") != null) updateLocalVariable("_rx");
752
+ else setRX(_rx);
753
+ }
754
+ });
755
+
756
+ var _work = function () {
757
+ if (!$(".prog").length)
758
+ $("body").append(
759
+ '<div class="prog"><div class=bar role=bar></div><div class=spinner role=spinner><div class="spinner-icon"></div></div></div>'
760
+ );
761
+ _worker = setTimeout(function () {
762
+ _gn = incri(_gn);
763
+ barSet(_gn, 200);
764
+ _work();
765
+ }, 200);
766
+ };
767
+
768
+ $(document)
769
+ .ajaxStart(function () {
770
+ _gn = 0;
771
+ _work();
772
+ if (typeof heartbeat === "function") heartbeat();
773
+ })
774
+ .ajaxStop(function () {
775
+ _gn = 0;
776
+ barSet(1, 200);
777
+ if (typeof heartbeat === "function") heartbeat();
778
+ globalWatch();
779
+ })
780
+ .ajaxError(function (e, xhr, opt) {
781
+ if (xhr.statusText == "error") {
782
+ if (xhr.status == "422") $("[exec]").html(xhr.responseText);
783
+ else if (xhr.status == "0") {
784
+ $("[dropzone].pending").removeClass("pending").addClass("error");
785
+ $("body").addClass("no-internet-connection");
786
+ }
787
+ }
788
+ if (typeof heartbeat === "function") heartbeat();
789
+ globalWatch();
790
+ _gn = 0;
791
+ barSet(1, 200);
792
+ });
793
+
794
+ (function ($) {
795
+ $.extend({
796
+ inArrayIn: function (elem, arr, i) {
797
+ if (typeof elem !== "string") {
798
+ return $.inArray.apply(this, arguments);
799
+ }
800
+ if (arr) {
801
+ var len = arr.length;
802
+ i = i ? (i < 0 ? Math.max(0, len + i) : i) : 0;
803
+ elem = elem.toLowerCase();
804
+ for (; i < len; i++) {
805
+ if (i in arr && arr[i].toLowerCase() == elem) {
806
+ return i;
807
+ }
808
+ }
809
+ }
810
+ return -1;
811
+ },
812
+ });
813
+ })(jQuery);
814
+
815
+ $.fn.priorityOn = function (type, selector, data, fn) {
816
+ this.each(function () {
817
+ var $this = $(this);
818
+
819
+ var types = type.split(" ");
820
+
821
+ for (var t in types) {
822
+ $this.on(types[t], selector, data, fn);
823
+
824
+ var currentBindings = $._data(this, "events")[types[t]];
825
+ if ($.isArray(currentBindings)) {
826
+ currentBindings.unshift(currentBindings.pop());
827
+ }
828
+ }
829
+ });
830
+ return this;
831
+ };
832
+
833
+ $.fn.onClose = function (selector, data, fn) {
834
+ this.each(function () {
835
+ var el = $(this);
836
+ var types = ["close"];
837
+ for (var t in types) {
838
+ el.on(types[t], selector, data, fn);
839
+ }
840
+ });
841
+ return this;
842
+ };
843
+
844
+ $.fn.attach = function (type, selector, data, fn) {
845
+ var el = $(this);
846
+ var types = type.split(" ");
847
+ for (var t in types) {
848
+ var lu =
849
+ "$.fn.on" +
850
+ types[t] +
851
+ " = function (selector, data, fn) {" +
852
+ "" +
853
+ " var el = $(this);" +
854
+ ' var types = ["' +
855
+ types[t] +
856
+ '"];' +
857
+ " for (var t in types) {" +
858
+ " el.live(types[t], selector, data, fn);" +
859
+ " }" +
860
+ " return this;" +
861
+ "};";
862
+ try {
863
+ eval(lu);
864
+ } catch (e) { }
865
+ }
866
+ return this;
867
+ };
868
+
869
+ $.fn.hasAttr = function (k) {
870
+ return this.attr(k) !== undefined;
871
+ };
872
+
873
+ $.fn.hasKey = function (k) {
874
+ return typeof this.data(k) !== "undefined";
875
+ };
876
+
877
+ function dotsIntoObjs(keys, value) {
878
+ var tempObject = {};
879
+ var container = tempObject;
880
+ keys.split(".").map((k, i, values) => {
881
+ container = container[k] = i == values.length - 1 ? value : {};
882
+ });
883
+ return tempObject;
884
+ }
885
+
886
+ $.fn.set = function (name, value) {
887
+ var splitter = name.split(".");
888
+ if (splitter.length > 1) {
889
+ var key = splitter.shift();
890
+ return this.data(key, dotsIntoObjs(splitter.join("."), value));
891
+ }
892
+ return this.data(name, value);
893
+ };
894
+
895
+ $.fn.props = function () {
896
+ return this.data("props");
897
+ };
898
+
899
+ $.fn.scope = function (_sview) {
900
+ var _scopedVariables = _sview(this, this.data("props") ?? {}) ?? {};
901
+ for (var x = 0; x < Object.keys(_scopedVariables).length; x++) {
902
+ var _key = Object.keys(_scopedVariables)[x];
903
+ var val = _scopedVariables[_key];
904
+ this.set(_key, val);
905
+ }
906
+ };
907
+
908
+ $.fn.isOverflown = function () {
909
+ return (
910
+ $(this)[0].scrollHeight > $(this)[0].clientHeight ||
911
+ $(this)[0].scrollWidth > $(this)[0].clientWidth
912
+ );
913
+ };
914
+
915
+ function removeEmptyElement(arr) {
916
+ var filtered = arr.filter(function (el) {
917
+ return el;
918
+ });
919
+ return filtered;
920
+ }
921
+
922
+ function findInObject(object, property, value) {
923
+ for (var i = 0; i < object.length; i += 1) {
924
+ if (object[i][property] === value) {
925
+ return i;
926
+ }
927
+ }
928
+ }
929
+
930
+ function compareUs(object1, object2) {
931
+ var areObjects = isObject(object1) && isObject(object2);
932
+ if (!areObjects) {
933
+ if (typeof object1 == "number" && typeof object2 == "number") {
934
+ if (isNaN(object1) && isNaN(object2)) return true;
935
+ }
936
+ return object1 == object2;
937
+ }
938
+ const keys1 = Object.keys(object1);
939
+ const keys2 = Object.keys(object2);
940
+ if (keys1.length !== keys2.length) {
941
+ return false;
942
+ }
943
+ // cl("compareUs", object1, object2);
944
+ for (const key of keys1) {
945
+ const val1 = object1[key];
946
+ const val2 = object2[key];
947
+ const areObjects = isObject(val1) && isObject(val2);
948
+ // cl("Aree", areObjects, val1, val2, compareUs(val1, val2));
949
+ if (
950
+ (areObjects && !compareUs(val1, val2)) ||
951
+ (!areObjects && val1 !== val2)
952
+ ) {
953
+ return false;
954
+ }
955
+ }
956
+ return true;
957
+ }
958
+
959
+ function deepCompare(object1, object2, path = '') {
960
+ const areObjects = isObject(object1) && isObject(object2);
961
+
962
+ if (!areObjects) {
963
+ if (typeof object1 === "number" && typeof object2 === "number") {
964
+ if (isNaN(object1) && isNaN(object2)) {
965
+ return true;
966
+ }
967
+ }
968
+
969
+ if (object1 !== object2) {
970
+ // cl(`Difference at ${path}:`);
971
+ // cl(` - ${path}: ${object1}`);
972
+ // cl(` + ${path}: ${object2}`);
973
+ return false;
974
+ }
975
+
976
+ return true;
977
+ }
978
+
979
+ const keys1 = Object.keys(object1);
980
+ const keys2 = Object.keys(object2);
981
+
982
+ if (keys1.length !== keys2.length) {
983
+ // cl(`Difference at ${path}:`);
984
+ // cl(` - ${path}: ${keys1.length} keys`);
985
+ // cl(` + ${path}: ${keys2.length} keys`);
986
+ return false;
987
+ }
988
+
989
+ for (const key of keys1) {
990
+ const newPath = path ? `${path}.${key}` : key;
991
+ const val1 = object1[key];
992
+ const val2 = object2[key];
993
+ const areNestedObjects = isObject(val1) && isObject(val2);
994
+
995
+ if (!deepCompare(val1, val2, newPath)) {
996
+ return false;
997
+ }
998
+ }
999
+
1000
+ return true;
1001
+ }
1002
+
1003
+ function isObject(object) {
1004
+ return object != null && typeof object === "object";
1005
+ }
1006
+
1007
+ (function (old) {
1008
+ $.fn.attr = function () {
1009
+ if (arguments.length === 0) {
1010
+ if (this.length === 0) {
1011
+ return null;
1012
+ }
1013
+
1014
+ var obj = {};
1015
+ $.each(this[0].attributes, function () {
1016
+ if (this.specified) {
1017
+ obj[this.name] = this.value;
1018
+ }
1019
+ });
1020
+ return obj;
1021
+ }
1022
+
1023
+ return old.apply(this, arguments);
1024
+ };
1025
+ })($.fn.attr);
1026
+
1027
+ function st(b) {
1028
+ if (!isNaN(b))
1029
+ $("html,body")
1030
+ .stop()
1031
+ .animate({ scrollTop: b + "px" }, { duration: 400 });
1032
+ else
1033
+ $("html,body")
1034
+ .stop()
1035
+ .animate({ scrollTop: $(b).offset().top + "px" }, { duration: 400 });
1036
+ }
1037
+
1038
+ function pushURL(url, d) {
1039
+ // url = url.toLowerCase();
1040
+ if (url || url == "") {
1041
+ if (history && history.pushState) {
1042
+ history.pushState(
1043
+ {},
1044
+ "",
1045
+ appSettings.Base + "/" + url.replace(new RegExp("^[" + "/" + "]+"), "")
1046
+ );
1047
+ goToNode(d);
1048
+ } else {
1049
+ parent.location.href = url;
1050
+ }
1051
+ } else {
1052
+ alert(url);
1053
+ }
1054
+ }
1055
+
1056
+ function formatBytes(bytes, decimals) {
1057
+ if (bytes == 0) return "0 Bytes";
1058
+ var k = 1024,
1059
+ dm = decimals <= 0 ? 0 : decimals || 2,
1060
+ sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
1061
+ i = Math.floor(Math.log(bytes) / Math.log(k));
1062
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
1063
+ }
1064
+
1065
+ function passwordContainsSymbol(value) {
1066
+ var containsSymbol = false,
1067
+ symbols = "-!§$%&/()=?.:,~;'#+*-/\\|{}[]_<>\"".split("");
1068
+
1069
+ $.each(symbols, function (index, symbol) {
1070
+ if (value.indexOf(symbol) > -1) {
1071
+ containsSymbol = true;
1072
+
1073
+ return false;
1074
+ }
1075
+ });
1076
+
1077
+ return containsSymbol;
1078
+ }
1079
+
1080
+ function passwordStrength(pass) {
1081
+ var s = 0,
1082
+ n;
1083
+
1084
+ if (pass.length > 5) s += 10;
1085
+ if (/[a-z]/.test(pass)) s += 1;
1086
+ if (/[A-Z]/.test(pass)) s += 1;
1087
+ if (/[0-9]/.test(pass)) s += 1;
1088
+ if (passwordContainsSymbol(pass)) s += 1;
1089
+
1090
+ if (s == 14) n = "very-strong";
1091
+ else if (s == 13) n = "strong";
1092
+ else if (s == 12) n = "medium";
1093
+ else if (s == 11) n = "weak";
1094
+ else n = "";
1095
+ if (/\s/g.test(pass)) n = "has-spaces";
1096
+
1097
+ return n;
1098
+ }
1099
+
1100
+ function passwordValid(pass) {
1101
+ var n = passwordStrength(pass);
1102
+ if (n == "strong" || n == "very-strong") return true;
1103
+ return false;
1104
+ }
1105
+
1106
+ function incri(n) {
1107
+ var amount;
1108
+ if (n > 1) {
1109
+ return 0.994;
1110
+ } else {
1111
+ if (n >= 0 && n < 0.2) {
1112
+ amount = 0.1;
1113
+ } else if (n >= 0.2 && n < 0.5) {
1114
+ amount = 0.04;
1115
+ } else if (n >= 0.5 && n < 0.8) {
1116
+ amount = 0.02;
1117
+ } else if (n >= 0.8 && n < 0.99) {
1118
+ amount = 0.005;
1119
+ } else {
1120
+ amount = 0.0005;
1121
+ }
1122
+
1123
+ n = n + amount;
1124
+ if (n < 0.08) n = 0.08;
1125
+ else if (n > 0.994) n = 0.994;
1126
+ return n;
1127
+ }
1128
+ }
1129
+
1130
+ function barSet(n, speed) {
1131
+ clearTimeout(_worker);
1132
+ if (n < 0.08) n = 0.08;
1133
+ else if (n > 1) n = 1;
1134
+ // cl(n);
1135
+ var bar = $('.bar[role="bar"]');
1136
+ // bar.css("margin-left");
1137
+ bar.css({
1138
+ transition: "all " + speed + "ms linear",
1139
+ "-webkit-transition": "all " + speed + "ms linear",
1140
+ "-moz-transition": "all " + speed + "ms linear",
1141
+ "-o-transition": "all " + speed + "ms linear",
1142
+ });
1143
+ if ($("body").hasClass("rtl"))
1144
+ bar.css({
1145
+ "margin-right": -100 + n * 100 + "%",
1146
+ });
1147
+ else
1148
+ bar.css({
1149
+ "margin-left": -100 + n * 100 + "%",
1150
+ });
1151
+
1152
+ if (n == 1) {
1153
+ _worker = setTimeout(function () {
1154
+ $(".prog").animate(
1155
+ { opacity: 0 },
1156
+ {
1157
+ duration: speed,
1158
+ complete: function () {
1159
+ $(".prog").remove();
1160
+ },
1161
+ }
1162
+ );
1163
+ }, speed);
1164
+ }
1165
+ }
1166
+
1167
+ function getFormData(form) {
1168
+ var unindexed_array = form.serializeArray();
1169
+ var indexed_array = {};
1170
+ $.map(unindexed_array, function (n, i) {
1171
+ if (n["name"].includes("[]")) {
1172
+ var key = n["name"].split("[]")[0];
1173
+ if (!indexed_array.hasOwnProperty(key)) indexed_array[key] = [];
1174
+ indexed_array[key].push(n["value"]);
1175
+ } else {
1176
+ indexed_array[n["name"]] = n["value"];
1177
+ }
1178
+ });
1179
+ return indexed_array;
1180
+ }
1181
+
1182
+ $(window).on("popstate", function () {
1183
+ if (history && history.pushState) goToNode();
1184
+ });
1185
+
1186
+ var getLocation = function (href) {
1187
+ var l = document.createElement("a");
1188
+ l.href = href;
1189
+ return l;
1190
+ };
1191
+
1192
+ function getURLNodes() {
1193
+ appSettings.Base = appSettings.Base.replace(
1194
+ new RegExp("[" + "/" + "]+$"),
1195
+ ""
1196
+ );
1197
+ var base = getLocation(appSettings.Base);
1198
+ if (base.origin != window.location.origin) {
1199
+ appSettings.Base = window.location.origin + base.pathname;
1200
+ var base = getLocation(appSettings.Base);
1201
+ }
1202
+ var _nodes =
1203
+ base.pathname != "/"
1204
+ ? window.location.pathname
1205
+ .split(base.pathname)
1206
+ .join("")
1207
+ .replace(new RegExp("^[" + "/" + "]+"), "")
1208
+ .split("/")
1209
+ : location.href
1210
+ .split(appSettings.Base)
1211
+ .join("")
1212
+ .replace(new RegExp("^[" + "/" + "]+"), "")
1213
+ .split("?")[0]
1214
+ .split("/");
1215
+
1216
+ // let authFunc = (appSettings.auth && typeof appSettings.auth === "function") ? appSettings.auth : (typeof Auth === "function" ? Auth : null);
1217
+ // if (typeof authFunc === 'function') authFunc();
1218
+ if (!_nodes[0]) _nodes[0] = appSettings.defaultView ?? "home";
1219
+ return _nodes;
1220
+ }
1221
+ var prevNodes = [];
1222
+ function goToNode(d) {
1223
+ if (_initialized) {
1224
+ prevNodes = clone(nodes);
1225
+ nodes = getURLNodes();
1226
+ renderView(nodes[0], null, d);
1227
+ } else {
1228
+ setTimeout(function () {
1229
+ goToNode(d);
1230
+ }, 100);
1231
+ }
1232
+ }
1233
+ var View = {};
1234
+
1235
+ function setError(e, t) {
1236
+ if (!e) {
1237
+ console.warn(t);
1238
+ return;
1239
+ }
1240
+ console.warn(t, e.message);
1241
+ }
1242
+
1243
+ function renderTpl(el, n, vars) {
1244
+ if (!el.length) return;
1245
+ if (el.data("_status") == "error") return;
1246
+ if (!el.hasKey("_re")) {
1247
+ if (el.data("_status") == "pending") {
1248
+ getTpl(n, el, vars);
1249
+ }
1250
+ setTimeout(function () {
1251
+ renderTpl(el, n, vars);
1252
+ }, _tickTime);
1253
+ }
1254
+ }
1255
+
1256
+ function prepareNode(n, rep) {
1257
+ var _arr = n.split("/");
1258
+ if (_arr.length > 1) {
1259
+ for (var i = _arr.length - 1; i >= _arr.length - 1; i--)
1260
+ _arr[i] = _arr[i];//.toLowerCase();
1261
+ n = _arr.join("/");
1262
+ } else n = n;//.toLowerCase();
1263
+ return rep ? n.replace(new RegExp("^[" + "/" + "]+"), "") : n;
1264
+ }
1265
+
1266
+ var _esps = {};
1267
+ var _Views = {};
1268
+ function setAppFuncs() {
1269
+ let initFunc =
1270
+ appSettings.init && typeof appSettings.init === "function"
1271
+ ? appSettings.init
1272
+ : typeof init === "function"
1273
+ ? init
1274
+ : null;
1275
+ if (typeof initFunc === "function") initFunc();
1276
+ }
1277
+
1278
+
1279
+ function getView(n, el, d) {
1280
+ let filePath = "src/views/" + n + ".view";
1281
+ let fileKey = btoa(filePath);
1282
+ if ($("body").hasKey("view_" + fileKey)) {
1283
+ renderView(n, el, d, true);
1284
+ } else {
1285
+ if (_vcData && _vcData["views"].hasOwnProperty(fileKey)) {
1286
+ $("body").data("view_" + fileKey, _vcData["views"][fileKey]);
1287
+ renderView(n, el, d, true);
1288
+ return;
1289
+ }
1290
+ if (Nuke && Nuke._ws && Nuke._ws.readyState) {
1291
+ Nuke.emit("getview", fileKey, function (e) {
1292
+ var r = e.data;
1293
+ $("body").data("view_" + fileKey, r);
1294
+ renderView(n, el, d, true);
1295
+ });
1296
+ } else {
1297
+ setTimeout(() => {
1298
+ getView(n, el, d);
1299
+ }, _tickTime);
1300
+ // prom.reject();
1301
+ }
1302
+ }
1303
+ }
1304
+
1305
+ // function getWidgets(settings, getWidgetsFiles, render) {
1306
+ // let count = 0,
1307
+ // promed = 0;
1308
+ // if (settings.hasFooter) {
1309
+ // count++;
1310
+ // var fileName = settings.hasFooter == true ? "footer" : settings.hasFooter;
1311
+ // if (render) renderWidget(fileName, "footer");
1312
+ // else {
1313
+ // var prom = defer();
1314
+ // getWidget(fileName, "footer", prom);
1315
+ // prom
1316
+ // .then(function (val) {
1317
+ // promed++;
1318
+ // if (promed == count) getWidgetsFiles.resolve();
1319
+ // })
1320
+ // .catch((reason) => {
1321
+ // promed++;
1322
+ // if (promed == count) getWidgetsFiles.resolve();
1323
+ // });
1324
+ // }
1325
+ // } else {
1326
+ // $("[footer]").html("");
1327
+ // }
1328
+ // if (settings.hasNav) {
1329
+ // count++;
1330
+ // var fileName = settings.hasNav == true ? "nav" : settings.hasNav;
1331
+ // if (render) renderWidget(fileName, "nav");
1332
+ // else {
1333
+ // var prom = defer();
1334
+ // getWidget(fileName, "nav", prom);
1335
+ // prom
1336
+ // .then(function (val) {
1337
+ // promed++;
1338
+ // if (promed == count) getWidgetsFiles.resolve();
1339
+ // })
1340
+ // .catch((reason) => {
1341
+ // promed++;
1342
+ // if (promed == count) getWidgetsFiles.resolve();
1343
+ // });
1344
+ // }
1345
+ // } else {
1346
+ // $("[nav]").html("");
1347
+ // }
1348
+ // if (settings.hasHeader) {
1349
+ // count++;
1350
+ // var fileName = settings.hasHeader == true ? "header" : settings.hasHeader;
1351
+ // if (render) renderWidget(fileName, "header");
1352
+ // else {
1353
+ // var prom = defer();
1354
+ // getWidget(fileName, "header", prom);
1355
+ // prom
1356
+ // .then(function (val) {
1357
+ // promed++;
1358
+ // if (promed == count) getWidgetsFiles.resolve();
1359
+ // })
1360
+ // .catch((reason) => {
1361
+ // promed++;
1362
+ // if (promed == count) getWidgetsFiles.resolve();
1363
+ // });
1364
+ // }
1365
+ // } else {
1366
+ // $("[header]").html("");
1367
+ // }
1368
+ // if (!count) getWidgetsFiles.resolve();
1369
+ // }
1370
+
1371
+ // function renderWidget(n, b) {
1372
+ // let filePath = "src/views/widgets/" + n + ".view";
1373
+ // let fileKey = btoa(filePath);
1374
+ // if ($("body").hasKey("view_" + fileKey)) {
1375
+ // var widget = $("body").data("view_" + fileKey);
1376
+ // if (
1377
+ // $("[" + b + "]").attr("kd") != fileKey ||
1378
+ // $("[" + b + "]").html() == "" ||
1379
+ // $("[" + b + "]").hasClass("_render")
1380
+ // )
1381
+ // $("[" + b + "]")
1382
+ // .removeClass("_render")
1383
+ // .html(widget)
1384
+ // .attr("kd", fileKey);
1385
+ // } else {
1386
+ // cl("noooo", "view_" + fileKey);
1387
+ // }
1388
+ // }
1389
+
1390
+ // function getWidget(n, b, prom) {
1391
+ // let filePath = "src/views/widgets/" + n + ".view";
1392
+ // let fileKey = btoa(filePath);
1393
+ // if ($("body").hasKey("view_" + fileKey)) {
1394
+ // prom.resolve();
1395
+ // } else {
1396
+ // if (_vcData && _vcData["views"].hasOwnProperty(fileKey)) {
1397
+ // $("body").data("view_" + fileKey, _vcData["views"][fileKey]);
1398
+ // prom.resolve();
1399
+ // return;
1400
+ // }
1401
+ // if (Nuke && Nuke._ws && Nuke._ws.readyState) {
1402
+ // Nuke.emit("getview", fileKey, function (e) {
1403
+ // var r = e.data;
1404
+ // $("body").data("view_" + fileKey, r);
1405
+ // prom.resolve();
1406
+ // });
1407
+ // } else {
1408
+ // setTimeout(() => {
1409
+ // getWidget(n, b, prom);
1410
+ // }, _tickTime);
1411
+ // // prom.reject();
1412
+ // }
1413
+ // }
1414
+ // }
1415
+
1416
+ function fileToDataURL(file) {
1417
+ var reader = new FileReader();
1418
+ return new Promise(function (resolve, reject) {
1419
+ reader.onload = function (event) {
1420
+ resolve(event.target.result);
1421
+ };
1422
+ reader.readAsDataURL(file);
1423
+ });
1424
+ }
1425
+
1426
+ function readFilesAsDataURL(files) {
1427
+ return Promise.all(files.map(fileToDataURL));
1428
+ }
1429
+
1430
+ function defer() {
1431
+ var res, rej;
1432
+ var promise = new Promise((resolve, reject) => {
1433
+ res = resolve;
1434
+ rej = reject;
1435
+ });
1436
+ promise.resolve = res;
1437
+ promise.reject = rej;
1438
+ promise.success = res;
1439
+ promise.failed = rej;
1440
+ return promise;
1441
+ }
1442
+
1443
+ function getTpl(n, el, vaz) {
1444
+ // cl([n, el, vaz]);
1445
+ let filePath = "src/tpls/" + n + ".tpl";
1446
+ let fileKey = btoa(filePath);
1447
+ if (el.data("_status") != "pending") return;
1448
+ el.data("_status", "getting");
1449
+ if ($("body").hasKey("tpl_" + fileKey)) {
1450
+ let r = $("body").data("tpl_" + fileKey);
1451
+ el.html(r);
1452
+ if (!setRe(el, vaz)) setError(null, "Error in rendering template " + n);
1453
+ } else {
1454
+ if (_vcData && _vcData["tpls"].hasOwnProperty(fileKey)) {
1455
+ $("body").data("tpl_" + fileKey, _vcData["tpls"][fileKey]);
1456
+ el.html(_vcData["tpls"][fileKey]);
1457
+ if (!setRe(el, vaz)) setError(null, "Error in rendering template " + n);
1458
+ return;
1459
+ }
1460
+ if (Nuke && Nuke._ws && Nuke._ws.readyState) {
1461
+ Nuke.emit("gettpl", fileKey, function (e) {
1462
+ var r = e.data;
1463
+ $("body").data("tpl_" + fileKey, r);
1464
+ el.html(r);
1465
+ if (!setRe(el, vaz)) setError(null, "Error in rendering template " + n);
1466
+ });
1467
+ } else {
1468
+ setTimeout(() => {
1469
+ getTpl(n, el, vaz);
1470
+ }, _tickTime);
1471
+ // prom.reject();
1472
+ }
1473
+ }
1474
+ }
1475
+
1476
+ function setRe(_el, vaz) {
1477
+ try {
1478
+ if (!_el.hasKey("_vars")) {
1479
+ if (_debugMode) cl("The Data Arrived", vaz);
1480
+ let data = {};
1481
+ let vars = vaz.split(",");
1482
+ vars = vars.map((s) => s.trim());
1483
+
1484
+ let binds = [];
1485
+ let dataNamesValues = [];
1486
+
1487
+ var _subView = _el.closest("[view]");
1488
+
1489
+ for (let x = 0; x < vars.length; x++) {
1490
+ if (vars[x] != "") {
1491
+ try {
1492
+ let varName = vars[x];
1493
+ let varValue = vars[x];
1494
+ let NameAs = null;
1495
+
1496
+ if (varName.indexOf(" as ") !== -1) {
1497
+ varName = varName.split(" as ");
1498
+ varValue = varName[0];
1499
+ varName = varName[1];
1500
+ NameAs = vars[x];
1501
+ }
1502
+
1503
+ let val = "";
1504
+ if (_subView.length) {
1505
+ val = _subView.hasKey(varValue)
1506
+ ? _subView.data(varValue)
1507
+ : eval(varValue);
1508
+ } else val = eval(varValue);
1509
+ dataNamesValues.push({
1510
+ Name: varName,
1511
+ NameAs: NameAs,
1512
+ Value: val,
1513
+ });
1514
+ } catch (e) {
1515
+ let varName = vars[x];
1516
+ let varValue = vars[x];
1517
+ let NameAs = null;
1518
+
1519
+ if (varName.indexOf(" as ") !== -1) {
1520
+ varName = varName.split(" as ");
1521
+ varValue = varName[0];
1522
+ varName = varName[1];
1523
+ NameAs = vars[x];
1524
+ }
1525
+
1526
+ dataNamesValues.push({
1527
+ Name: varName,
1528
+ NameAs: NameAs,
1529
+ Value: undefined,
1530
+ });
1531
+ setError(e, "Error in bind variables for " + vars[x]);
1532
+ }
1533
+ }
1534
+ }
1535
+
1536
+ for (let x = 0; x < dataNamesValues.length; x++) {
1537
+ let dn = dataNamesValues[x];
1538
+ binds.push({
1539
+ dataName: dn["Name"],
1540
+ dataNameAs: dn["NameAs"],
1541
+ dataValue: clone(dn["Value"]),
1542
+ });
1543
+ data[dn["Name"]] = dn["Value"];
1544
+ }
1545
+ if (_debugMode) cl(["The Data Set", data, binds]);
1546
+ if (
1547
+ appSettings.beforetick &&
1548
+ typeof appSettings.beforetick === "function"
1549
+ )
1550
+ appSettings.beforetick();
1551
+ _el.data("_vars", binds).data("_re", new RenderEngine(_el, data));
1552
+ globalWatch();
1553
+ }
1554
+ _el.data("_status", "complete");
1555
+ return true;
1556
+ } catch (e) {
1557
+ _el.data("_status", "error");
1558
+ return false;
1559
+ }
1560
+ return false;
1561
+ }
1562
+
1563
+ function parseFromString(html) {
1564
+ return doc = new DOMParser().parseFromString(html, "text/html");
1565
+ }
1566
+ // function htmlDecode(input) {
1567
+ // var doc = new DOMParser().parseFromString(input, "text/html");
1568
+ // return doc.documentElement.textContent;
1569
+ // }
1570
+
1571
+ var _binds = {};
1572
+ let _oldGlobals = clone(globals);
1573
+ let _oldRX = clone(_rx);
1574
+ let _watch = clone($("body").data("_watch"));
1575
+
1576
+ $("body").data("_watch", {
1577
+ old: {},
1578
+ list: [],
1579
+ });
1580
+
1581
+ //NNNNNEEEEDDDD TO TURN ON
1582
+ // setInterval(function () {
1583
+ // if (!compareUs(_oldGlobals, globals)) {
1584
+ // _oldGlobals = clone(globals);
1585
+ // localStorage.setItem("globals", JSON.stringify(_oldGlobals));
1586
+ // }
1587
+ // if (!compareUs(_oldRX, _rx)) {
1588
+ // _oldRX = clone(_rx);
1589
+ // localStorage.setItem("_rx", JSON.stringify(_oldRX));
1590
+ // }
1591
+ // }, _tickTime);
1592
+
1593
+ function reloads() {
1594
+ $("[crslf].flickity-enabled.reload-on-bind").each(function () {
1595
+ var el = $(this);
1596
+ el.flickity("destroy");
1597
+ var opts = el.attr("crslf-opts");
1598
+ if (!opts) opts = {};
1599
+ else opts = JSON.parse(opts);
1600
+ el.flickity(opts);
1601
+ var flkty = el.data("flickity");
1602
+ flkty.on("dragStart", () =>
1603
+ flkty.slider.childNodes.forEach(
1604
+ (slide) => (slide.style.pointerEvents = "none")
1605
+ )
1606
+ );
1607
+ flkty.on("dragEnd", () =>
1608
+ flkty.slider.childNodes.forEach(
1609
+ (slide) => (slide.style.pointerEvents = "all")
1610
+ )
1611
+ );
1612
+ });
1613
+ $("[crsl].crsl-initialized").each(function () {
1614
+ $(this).crsl("refresh");
1615
+ });
1616
+ let tickFunc =
1617
+ appSettings.tick && typeof appSettings.tick === "function"
1618
+ ? appSettings.tick
1619
+ : typeof tick === "function"
1620
+ ? tick
1621
+ : null;
1622
+ if (typeof tickFunc === "function") tickFunc();
1623
+
1624
+ scsc.reset();
1625
+ dgsc.reset();
1626
+ applyTriggers();
1627
+ setTimeout(() => {
1628
+ scsc.reset();
1629
+ dgsc.reset();
1630
+ applyTriggers();
1631
+ }, _tickTime * 2);
1632
+ }
1633
+
1634
+ function renderViewsTpls() {
1635
+
1636
+
1637
+ $("[view]").each(function (i) {
1638
+ var el = $(this);
1639
+
1640
+ if (
1641
+ el.data("_status") != "pending" &&
1642
+ el.data("_status") != "error" &&
1643
+ el.data("_status") != "getting" &&
1644
+ el.data("_status") != "complete"
1645
+ ) {
1646
+ var modal = el.closest("popup");
1647
+ var n = el.attr("view");
1648
+ var _props = el.attr(":props") ?? null;
1649
+ var _binds = el.attr(":props-bind") ?? null;
1650
+ el.data("_status", "pending");
1651
+
1652
+ let nn = n;
1653
+ var _arr = nn.split("/");
1654
+ if (_arr.length > 1) {
1655
+ for (var i = _arr.length - 1; i >= _arr.length - 1; i--) {
1656
+ _arr[i] = _arr[i].toLowerCase();
1657
+ }
1658
+ nn = _arr.join("/");
1659
+ } else {
1660
+ nn = nn.toLowerCase();
1661
+ }
1662
+
1663
+ var _queryParams = nn.split("?");
1664
+ nn = _queryParams.shift();
1665
+
1666
+
1667
+
1668
+
1669
+
1670
+ if (el.attr(":data")) {
1671
+ let vaz = el.attr(":data");
1672
+ let data = {};
1673
+ let vars = vaz.split(",");
1674
+ let dataNamesValues = [];
1675
+ let binds = [];
1676
+ vars = vars.map((s) => s.trim());
1677
+ for (let x = 0; x < vars.length; x++) {
1678
+ if (vars[x] != "") {
1679
+ try {
1680
+ let varName = vars[x];
1681
+ let varValue = vars[x];
1682
+ let NameAs = null;
1683
+
1684
+ if (varName.indexOf(" as ") !== -1) {
1685
+ varName = varName.split(" as ");
1686
+ varValue = varName[0];
1687
+ varName = varName[1];
1688
+ NameAs = vars[x];
1689
+ }
1690
+
1691
+ let val = "";
1692
+ val = eval(varValue);
1693
+ dataNamesValues.push({
1694
+ Name: varName,
1695
+ NameAs: NameAs,
1696
+ Value: val,
1697
+ });
1698
+ } catch (e) {
1699
+ cl(e);
1700
+ let varName = vars[x];
1701
+ let varValue = vars[x];
1702
+ let NameAs = null;
1703
+
1704
+ if (varName.indexOf(" as ") !== -1) {
1705
+ varName = varName.split(" as ");
1706
+ varValue = varName[0];
1707
+ varName = varName[1];
1708
+ NameAs = vars[x];
1709
+ }
1710
+
1711
+ dataNamesValues.push({
1712
+ Name: varName,
1713
+ NameAs: NameAs,
1714
+ Value: undefined,
1715
+ });
1716
+ setError(e, "Error in bind variables for " + vars[x]);
1717
+ }
1718
+ }
1719
+ }
1720
+
1721
+ for (let x = 0; x < dataNamesValues.length; x++) {
1722
+ let dn = dataNamesValues[x];
1723
+ binds.push({
1724
+ dataName: dn["Name"],
1725
+ dataNameAs: dn["NameAs"],
1726
+ dataValue: clone(dn["Value"]),
1727
+ });
1728
+ data[dn["Name"]] = dn["Value"];
1729
+ }
1730
+
1731
+ el.data("props", data);
1732
+
1733
+
1734
+
1735
+
1736
+
1737
+ } else {
1738
+ var _d = paraToObj(getBind(_binds, _props));
1739
+
1740
+ el.data("params", paraToObj(_queryParams));
1741
+ if (modal.length) _d["modal"] = modal.data("props");
1742
+ el.data("props", _d);
1743
+ }
1744
+
1745
+ if (n == "" || !n || n.split("/").slice(-1) == "") {
1746
+ el.data("_status", "error");
1747
+ } else {
1748
+ renderView(n, el, _d);
1749
+ }
1750
+ }
1751
+ });
1752
+
1753
+ // $("[tpl],[comp]").each(function () {
1754
+ // let el = $(this);
1755
+ // if (
1756
+ // el.data("_status") != "pending" &&
1757
+ // el.data("_status") != "error" &&
1758
+ // el.data("_status") != "getting" &&
1759
+ // el.data("_status") != "complete"
1760
+ // ) {
1761
+ // var modal = el.closest("modal");
1762
+ // if (!modal.length) {
1763
+ // let n = el.attr("tpl") ?? el.attr("comp");
1764
+ // el.data("_status", "pending");
1765
+ // if (n == "" || !n || n.split("/").slice(-1) == "") {
1766
+ // el.data("_status", "error");
1767
+ // } else renderTpl(el, n, el.attr(":data") ?? "");
1768
+ // }
1769
+ // }
1770
+ // });
1771
+ }
1772
+
1773
+
1774
+ function renderPlugins() {
1775
+ $(
1776
+ "[crslf]:not(.flickity-enabled,[comp],[tpl],[view]),[crslf][comp]:not(.flickity-enabled),[crslf][tpl]:not(.flickity-enabled),[crslf][view]:not(.flickity-enabled)"
1777
+ ).each(function () {
1778
+ var el = $(this);
1779
+
1780
+ if (el.hasAttr("[tpl]") || el.hasAttr("[comp]") || el.hasAttr("[view]")) {
1781
+ if (el.data("_status") != "complete") return;
1782
+ }
1783
+
1784
+ var opts = el.attr("crslf-opts");
1785
+ if (!opts) opts = {};
1786
+ else opts = JSON.parse(opts);
1787
+ el.flickity(opts);
1788
+ var flkty = el.data("flickity");
1789
+ flkty.on("dragStart", () =>
1790
+ flkty.slider.childNodes.forEach(
1791
+ (slide) => (slide.style.pointerEvents = "none")
1792
+ )
1793
+ );
1794
+ flkty.on("dragEnd", () =>
1795
+ flkty.slider.childNodes.forEach(
1796
+ (slide) => (slide.style.pointerEvents = "all")
1797
+ )
1798
+ );
1799
+ setTimeout(function () {
1800
+ globalWatch();
1801
+ }, 600);
1802
+ });
1803
+ $(
1804
+ "[crsl]:not(.crsl-initialized,[comp],[tpl],[view]),[crsl][comp]:not(.crsl-initialized),[crsl][tpl]:not(.crsl-initialized),[crsl][view]:not(.crsl-initialized)"
1805
+ ).each(function () {
1806
+ var el = $(this);
1807
+ if (el.hasAttr("[tpl]") || el.hasAttr("[comp]") || el.hasAttr("[view]")) {
1808
+ if (el.data("_status") != "complete") return;
1809
+ }
1810
+
1811
+ el.crsl();
1812
+ el.on(
1813
+ "setPosition beforeChange",
1814
+ function (event, slick, currentSlide, nextSlide) {
1815
+ $(window).trigger("scroll.scsc");
1816
+ $(window).trigger("resize");
1817
+ }
1818
+ );
1819
+ });
1820
+
1821
+ $("[up]:not([upid])").each(function () {
1822
+ var u = _ups.length;
1823
+ var t = $(this);
1824
+ var mxf = t.attr('data-mxf') ? t.attr('data-mxf') : 10;
1825
+ if (!t.hasAttr("upid")) {
1826
+ var sl = "up_" + u;
1827
+ t.attr("upid", sl);
1828
+ t.prepend(`<input ` + (mxf > 1 ? 'multiple' : '') + ` type="file" ` + "" + ` files style="display:none;" />`);
1829
+ _ups.push(t);
1830
+ }
1831
+ });
1832
+
1833
+ $("form:not(.binded,[norm])").each(function () {
1834
+ var el = $(this);
1835
+ var reset = false;
1836
+ if (el.hasAttr("reset")) reset = true;
1837
+ var actn = el.attr("action") ?? "";
1838
+ var local = false;
1839
+ el.addClass("binded");
1840
+
1841
+ if (actn == "") {
1842
+ actn = getURLNodes().join("/");
1843
+ local = true;
1844
+ } else local = isPathLocal(actn);
1845
+
1846
+ if (el.hasAttr("o-sub")) {
1847
+ el.ajaxForm({
1848
+ beforeSubmit: function (formData, f, options) {
1849
+ // options["url"] = beas + "a" + f.attr('action');
1850
+ let formDataMapped = {};
1851
+ let formDataMappedAdditionals = {};
1852
+ formDataMapped = Object.assign(
1853
+ {},
1854
+ ...formData.map((x) => {
1855
+ if (x.type == "file") {
1856
+ if (!formDataMappedAdditionals.hasOwnProperty(x.name))
1857
+ formDataMappedAdditionals[x.name] = [];
1858
+ formDataMappedAdditionals[x.name].push(x["value"]);
1859
+
1860
+ return undefined;
1861
+ }
1862
+ if (x["name"].includes("[]")) {
1863
+ var key = x["name"].split("[]").join("");
1864
+ if (!formDataMappedAdditionals.hasOwnProperty(key))
1865
+ formDataMappedAdditionals[key] = [];
1866
+ formDataMappedAdditionals[key].push(x["value"]);
1867
+ return undefined;
1868
+ }
1869
+
1870
+ return { [x.name]: x.value };
1871
+ })
1872
+ );
1873
+
1874
+ formDataMapped = { ...formDataMapped, ...formDataMappedAdditionals };
1875
+
1876
+ // var d = getFormData(f);
1877
+ if (f.hasAttr("b-sub")) {
1878
+ var bfs = f.attr("b-sub");
1879
+ if (typeof window[bfs] === "function") {
1880
+ checkFormInputs(f);
1881
+ if (window[bfs](f, formDataMapped) === false) return false;
1882
+ }
1883
+ }
1884
+ if (!checkFormInputs(f)) return false;
1885
+ if (f.hasAttr("o-sub")) {
1886
+ var ofs = f.attr("o-sub");
1887
+ if (typeof window[ofs] === "function") {
1888
+ window[ofs](f, formDataMapped);
1889
+ }
1890
+ }
1891
+ return false;
1892
+ },
1893
+ clearForm: reset,
1894
+ resetForm: reset,
1895
+ success: function (responseText, statusText, xhr, f) { },
1896
+ timeout: 300000,
1897
+ error: function (xhr, textStatus, errorThrown) { },
1898
+ });
1899
+
1900
+ // el.attr('onsubmit','return false;');
1901
+ // el.on('submit',function(ev){
1902
+ // ev.preventDefault();
1903
+ // ev.stopPropagation();
1904
+
1905
+ // if(!checkFormInputs(el)) return false;
1906
+
1907
+ // var d = getFormData(el);
1908
+ // if (el.hasAttr('b-sub')) {
1909
+ // var bfs = el.attr('b-sub');
1910
+ // if (typeof window[bfs] === "function") {
1911
+ // if (window[bfs](el,d) === false) return false;
1912
+ // }
1913
+ // }
1914
+ // if (el.hasAttr('o-sub')) {
1915
+ // var ofs = el.attr('o-sub');
1916
+ // if (typeof window[ofs] === "function") {
1917
+ // window[ofs](el,d);
1918
+ // }
1919
+ // }
1920
+ // });
1921
+ } else {
1922
+ if (local) {
1923
+ el.ajaxForm({
1924
+ beforeSubmit: function (formData, f, options) {
1925
+ // options["url"] = beas + "a" + f.attr('action');
1926
+ if (!checkFormInputs(f)) return false;
1927
+ let formDataMapped = {};
1928
+ let formDataMappedAdditionals = {};
1929
+ formDataMapped = Object.assign(
1930
+ {},
1931
+ ...formData.map((x) => {
1932
+ if (x.type == "file") {
1933
+ if (!formDataMappedAdditionals.hasOwnProperty(x.name))
1934
+ formDataMappedAdditionals[x.name] = [];
1935
+ formDataMappedAdditionals[x.name].push(x["value"]);
1936
+
1937
+ return undefined;
1938
+ }
1939
+ if (x["name"].includes("[]")) {
1940
+ var key = x["name"].split("[]").join("");
1941
+ if (!formDataMappedAdditionals.hasOwnProperty(key))
1942
+ formDataMappedAdditionals[key] = [];
1943
+ formDataMappedAdditionals[key].push(x["value"]);
1944
+ return undefined;
1945
+ }
1946
+
1947
+ return { [x.name]: x.value };
1948
+ })
1949
+ );
1950
+
1951
+ formDataMapped = {
1952
+ ...formDataMapped,
1953
+ ...formDataMappedAdditionals,
1954
+ };
1955
+ try {
1956
+ // var d = getFormData(f);
1957
+ if (f.hasAttr("b-sub")) {
1958
+ var bfs = f.attr("b-sub");
1959
+ if (typeof window[bfs] === "function") {
1960
+ if (window[bfs](f, formDataMapped) === false) return false;
1961
+ }
1962
+ }
1963
+ var actn = f.attr("action") ?? "";
1964
+ if (actn == "") {
1965
+ actn = getURLNodes().join("/");
1966
+ }
1967
+ if (validateInputs(f)) {
1968
+ var d = getFormData(f);
1969
+ if (f.attr("method")?.toLowerCase() == "get") {
1970
+ actn = addOrChangeParameters(actn, d);
1971
+ }
1972
+ pushURL(actn, d);
1973
+ }
1974
+ } catch (e) {
1975
+ cl(e);
1976
+ }
1977
+ return false;
1978
+ },
1979
+ clearForm: reset,
1980
+ resetForm: reset,
1981
+ success: function (responseText, statusText, xhr, f) { },
1982
+ timeout: 300000,
1983
+ error: function (xhr, textStatus, errorThrown) { },
1984
+ });
1985
+
1986
+ // el.attr('onsubmit','return false;');
1987
+ // el.on('submit',function(ev){
1988
+ // ev.preventDefault();
1989
+ // ev.stopPropagation();
1990
+
1991
+ // if(!checkFormInputs(el)) return false;
1992
+ // try{
1993
+ // var d = getFormData(el);
1994
+ // if (el.hasAttr('b-sub')) {
1995
+ // var bfs = el.attr('b-sub');
1996
+ // if (typeof window[bfs] === "function") {
1997
+ // if (window[bfs](el,d) === false) return false;
1998
+ // }
1999
+ // }
2000
+ // var actn = el.attr('action')??"";
2001
+ // if(actn==""){
2002
+ // actn = getURLNodes().join("/");
2003
+ // }
2004
+ // if(validateInputs(el)){
2005
+ // if(el.attr('method')?.toLowerCase()=="get"){
2006
+ // var d = getFormData(el);
2007
+ // actn = addOrChangeParameters(actn, d);
2008
+ // }
2009
+ // pushURL(actn,d);
2010
+ // }
2011
+ // } catch(e){
2012
+ // cl(e);
2013
+ // }
2014
+ // });
2015
+ }
2016
+ }
2017
+ });
2018
+
2019
+ $("[editor]").each(function (i) {
2020
+ var editor = $(this);
2021
+ editor.removeAttr("editor");
2022
+ var TB = normalTB;
2023
+ if (editor.is("[mini]")) TB = miniTB;
2024
+ else if (editor.is("[full]")) TB = fullTB;
2025
+
2026
+ if (CKEDITOR !== undefined) {
2027
+ /*CKEDITOR.plugins.addExternal( 'autocomplete', 'https://s.beacdn.com/j/autocomplete/plugin.js' );*/
2028
+ CKEDITOR.replace(this, {
2029
+ uiColor: "#ffffff",
2030
+ language: $("html").attr("lang"),
2031
+ allowedContent: true,
2032
+ //extraPlugins: 'autocomplete',
2033
+ enterMode: CKEDITOR.ENTER_BR,
2034
+ toolbar: TB,
2035
+ on: {
2036
+ instanceReady: function (evt) {
2037
+ var itemTemplate =
2038
+ '<li class="l" data-id="{id}">' +
2039
+ '<div><strong class="item-title">{name}</strong></div>' +
2040
+ "<div><i>{description}</i></div>" +
2041
+ "</li>",
2042
+ outputTemplate = "<span class=hash>{linked}</span>&nbsp;";
2043
+
2044
+ var autocomplete = new CKEDITOR.plugins.autocomplete(evt.editor, {
2045
+ textTestCallback: function (range) {
2046
+ if (!range.collapsed) {
2047
+ return null;
2048
+ }
2049
+ //cl(range);
2050
+
2051
+ //var range = new CKEDITOR.dom.range( evt.editor.document );
2052
+ //cl(range);
2053
+
2054
+ return CKEDITOR.plugins.textMatch.match(
2055
+ range,
2056
+ function (text, offset) {
2057
+ var left = text.slice(0, offset);
2058
+ var matchHash = left.match(/#\d*$/);
2059
+ var matchAt = left.match(
2060
+ /(@)[A-Za-z]+(?!\.)(?!.*\.$)(?!.*?\.\.)[a-zA-Z0-9.]+[A-Za-z0-9]{6,30}$/
2061
+ );
2062
+
2063
+ if (
2064
+ (!matchHash || matchHash == "#") &&
2065
+ (!matchAt || matchAt == "@")
2066
+ ) {
2067
+ return null;
2068
+ }
2069
+ var match = matchHash;
2070
+ if (!match) match = matchAt;
2071
+
2072
+ return { start: match.index, end: offset };
2073
+ }
2074
+ );
2075
+ },
2076
+ dataCallback: function (matchInfo, callback) {
2077
+ var query = matchInfo.query;
2078
+
2079
+ if (myR["[ck]"]) myR["[ck]"].abort();
2080
+
2081
+ clearTimeout(debounceTimeout["[ck]"]);
2082
+ debounceTimeout["[ck]"] = setTimeout(function () {
2083
+ myR["[ck]"] = $.post(
2084
+ beas + "a" + "/hashes/get",
2085
+ { id: query },
2086
+ function (result) {
2087
+ if (result) {
2088
+ result = $.parseJSON(result);
2089
+ var suggestions = result.filter(function (item) {
2090
+ return (
2091
+ String(item.name).indexOf(query.substring(1)) == 0
2092
+ );
2093
+ });
2094
+ callback(suggestions);
2095
+ }
2096
+ }
2097
+ );
2098
+ }, 500);
2099
+ },
2100
+ itemTemplate: itemTemplate,
2101
+ outputTemplate: outputTemplate,
2102
+ throttle: 100,
2103
+ });
2104
+
2105
+ autocomplete.getHtmlToInsert = function (item) {
2106
+ return this.outputTemplate.output(item);
2107
+ };
2108
+ },
2109
+ change: function (ev) {
2110
+ if ($.trim(ev.editor.getData()).length == 0)
2111
+ editor
2112
+ .closest(".fields")
2113
+ .addClass("is-empty")
2114
+ .removeClass("is-not-empty");
2115
+ else
2116
+ editor
2117
+ .closest(".fields")
2118
+ .removeClass("is-empty error")
2119
+ .addClass("is-not-empty");
2120
+ editor.val(ev.editor.getData()).trigger("change");
2121
+ },
2122
+ focus: function (ev) {
2123
+ editor.closest(".fields").addClass("focused");
2124
+ if ($.trim(ev.editor.getData()).length == 0)
2125
+ editor
2126
+ .closest(".fields")
2127
+ .addClass("is-empty")
2128
+ .removeClass("is-not-empty");
2129
+ else
2130
+ editor
2131
+ .closest(".fields")
2132
+ .removeClass("is-empty error")
2133
+ .addClass("is-not-empty");
2134
+ },
2135
+ blur: function (ev) {
2136
+ editor.closest(".fields").removeClass("focused");
2137
+ if ($.trim(ev.editor.getData()).length == 0)
2138
+ editor
2139
+ .closest(".fields")
2140
+ .addClass("is-empty")
2141
+ .removeClass("is-not-empty");
2142
+ else
2143
+ editor
2144
+ .closest(".fields")
2145
+ .removeClass("is-empty error")
2146
+ .addClass("is-not-empty");
2147
+ },
2148
+ },
2149
+ });
2150
+ }
2151
+ });
2152
+
2153
+ $(".cke_autocomplete_panel").each(function () {
2154
+ if ($(this).html() == "") $(this).remove();
2155
+ });
2156
+
2157
+ $("[tags]:not(.tag-editor-hidden-src)").each(function () {
2158
+ var t = $(this);
2159
+
2160
+ var u = currentlyValidTags.length;
2161
+ t.attr("data-u", u);
2162
+ var del = t.attr("dl") ? t.attr("dl") : ", ";
2163
+ var maxTags = t.attr("mt") ? t.attr("mt") : 50;
2164
+ var maxLength = t.attr("ml") ? t.attr("ml") : 100;
2165
+ var plchldr = t.attr("placeholder") ? t.attr("placeholder") : "";
2166
+ var tagslower = t.attr("tags-lower") ? true : false;
2167
+ var autocomplete = t.attr("acs")
2168
+ ? {
2169
+ delay: 250,
2170
+ autoFocus: true,
2171
+ position: { collision: "flip" },
2172
+ source: function (request, response) {
2173
+ $.post(beas + "a" + t.attr("acs"), request, response);
2174
+ },
2175
+ minLength: 1,
2176
+ select: function (event, ui) {
2177
+ /*t.trigger('change');*/
2178
+ // cl(ui);
2179
+ if (ui.item == null) {
2180
+ t.val("");
2181
+ /*t.focus();*/
2182
+ }
2183
+ },
2184
+ change: function (event, ui) {
2185
+ if (ui.item == null) {
2186
+ t.val("");
2187
+ /*t.focus();*/
2188
+ }
2189
+ },
2190
+ }
2191
+ : null;
2192
+ t.tagEditor({
2193
+ autocomplete: autocomplete,
2194
+ delimiter: del,
2195
+ removeDuplicates: true,
2196
+ forceLowercase: tagslower,
2197
+ placeholder: plchldr,
2198
+ animateDelete: 50,
2199
+ maxLength: maxLength,
2200
+ maxTags: maxTags,
2201
+ onChange: function (field, editor, tags) {
2202
+ field.trigger("change");
2203
+ },
2204
+ beforeTagSave: function (field, editor, tags, tag, val) {
2205
+ if (!t.attr("sts")) {
2206
+ if ($.inArrayIn(val, tags) !== -1) {
2207
+ return false;
2208
+ }
2209
+ } else {
2210
+ if ($.inArray(tag, currentlyValidTags[u][tags]) == -1) {
2211
+ return false;
2212
+ }
2213
+ }
2214
+
2215
+ if (t.attr("tags-before")) {
2216
+ var bfs = t.attr("tags-before");
2217
+ if (typeof window[bfs] === "function") {
2218
+ if (window[bfs](t, field, editor, tags, tag, val) === false)
2219
+ return false;
2220
+ }
2221
+ }
2222
+ },
2223
+ });
2224
+ currentlyValidTags.push(t);
2225
+ });
2226
+
2227
+ $("[slct]:not(.select2-hidden-accessible)").each(function () {
2228
+ var t = $(this);
2229
+ var plchldr = t.attr("placeholder") ? t.attr("placeholder") : "";
2230
+ var dropdownParent = t.attr("prnt") ? t.attr("prnt") : "body";
2231
+ var tpl = t.attr("slct-tpl") ? t.attr("slct-tpl") : null;
2232
+ var dir = t.attr("slct-dir") ? t.attr("slct-dir") : "ltr";
2233
+ // var lang = t.attr('slct-lang') ? t.attr('slct-lang') : 'en';
2234
+ var minResultsForSearch = t.attr("mins") ? t.attr("mins") : "";
2235
+ if (dropdownParent == "self") dropdownParent = t.parent();
2236
+ else dropdownParent = $(dropdownParent);
2237
+ var allowNewTags = t.attr("ntgs") ? true : false;
2238
+ var ax = t.attr("axs")
2239
+ ? {
2240
+ url: t.attr("axs"),
2241
+ dataType: "json",
2242
+ delay: 250,
2243
+ }
2244
+ : null;
2245
+ t.select2({
2246
+ dropdownParent: dropdownParent,
2247
+ placeholder: plchldr,
2248
+ dir: dir,
2249
+ // language: lang,
2250
+ allowClear: false,
2251
+ tags: allowNewTags,
2252
+ ajax: ax,
2253
+ minimumResultsForSearch: minResultsForSearch,
2254
+ templateSelection: function (data, container) {
2255
+ /*if(data.newTag) {
2256
+
2257
+ }*/
2258
+ /*$(data.element).attr('data-custom-attribute', data.customValue);*/
2259
+
2260
+ if (data.newTag) {
2261
+ /*alert(data.text);
2262
+ var new_state = $(data.text).text();
2263
+ alert(new_state);*/
2264
+ if (allowNewTags && t.attr("ntgs") != "true") {
2265
+ var tag = data.text;
2266
+ var id = data.id;
2267
+ $.post(beas + "a" + t.attr("ntgs"), { tag: tag }, function (r) {
2268
+ if (r == "true") {
2269
+ var newOption = new Option(tag, id, true, true);
2270
+ t.append(newOption).trigger("change");
2271
+ } else {
2272
+ alert("Error adding tag! Please Try again.");
2273
+ t.val(null).trigger("change");
2274
+ }
2275
+ });
2276
+ return data.text;
2277
+ } else {
2278
+ return data.text;
2279
+ }
2280
+ } else {
2281
+ return data.text;
2282
+ }
2283
+ },
2284
+ templateResult: function (state) {
2285
+ /*if (!state.id) {
2286
+ return state.text;
2287
+ }*/
2288
+ if (tpl) {
2289
+ if (typeof window[tpl] === "function") return window[tpl](state);
2290
+ }
2291
+ if (state.newTag) {
2292
+ if (allowNewTags && t.attr("ntgs") != "true") {
2293
+ var new_state = $("<span>+ Add <b>" + state.text + "</b></span>");
2294
+
2295
+ return new_state;
2296
+ }
2297
+ return state.text;
2298
+ } else return state.text;
2299
+
2300
+ /*return state.text;*/
2301
+ },
2302
+ tokenSeparators: [","] /*[',', ' ']*/,
2303
+ createTag: function (params) {
2304
+ var term = $.trim(params.term);
2305
+
2306
+ if (term === "") {
2307
+ return null;
2308
+ }
2309
+
2310
+ return {
2311
+ id: term,
2312
+ text: term,
2313
+ newTag: true,
2314
+ };
2315
+ },
2316
+ insertTag: function (data, tag) {
2317
+ /* Insert the tag at the end of the results */
2318
+ data.push(tag);
2319
+ },
2320
+ });
2321
+
2322
+ if (t.attr("nosearch"))
2323
+ t.on("select2:opening select2:closing", function (event) {
2324
+ var searchfield = $(this).parent().find(".select2-search__field");
2325
+ searchfield.prop("disabled", true);
2326
+ });
2327
+ });
2328
+
2329
+ $("[sl]:not(.select2-hidden-accessible)").each(function () {
2330
+ var t = $(this);
2331
+ try {
2332
+
2333
+ var plchldr = t.attr("placeholder") ? t.attr("placeholder") : "";
2334
+ var dir = $("body").hasClass("rtl") ? "rtl" : "ltr";
2335
+ var nr = t.attr("sl-nrmsg") ? t.attr("sl-nrmsg") : "No results found";
2336
+ var minResultsForSearch = t.attr("sl-mins") ? t.attr("sl-mins") : 10;
2337
+ var allowNewTags = t.attr("sl-ntgs") ? true : false;
2338
+ var dropdownParent = t.attr("sl-prt") ? t.attr("sl-prt") : "body";
2339
+ if (dropdownParent == "self") dropdownParent = t.parent();
2340
+ else dropdownParent = $(dropdownParent);
2341
+
2342
+ var query = t.attr("sl-query") ? t.attr("sl-query") : null;
2343
+
2344
+ var uniquer = Date.now();
2345
+ if (typeof window[query] === "function") {
2346
+ let dbcrID = "dbcr_" + (Object.keys(_dbcrs).length + 1);
2347
+
2348
+ t.select2.amd.define(
2349
+ "adapt_" + uniquer,
2350
+ ["select2/data/array", "select2/utils"],
2351
+ function (ArrayAdapter, Utils) {
2352
+ function CustomDataAdapter($element, options) {
2353
+ CustomDataAdapter.__super__.constructor.call(
2354
+ this,
2355
+ $element,
2356
+ options
2357
+ );
2358
+ }
2359
+ Utils.Extend(CustomDataAdapter, ArrayAdapter);
2360
+ CustomDataAdapter.prototype.query = function (params, callback) {
2361
+ clearTimeout(_dbcrs[dbcrID]);
2362
+ let _t = t;
2363
+ _dbcrs[dbcrID] = setTimeout(
2364
+ function () {
2365
+ window[query](params, callback, _t);
2366
+ },
2367
+ !_dbcrs.hasOwnProperty(dbcrID) ? 0 : _dbcrsTime
2368
+ );
2369
+ };
2370
+
2371
+ return CustomDataAdapter;
2372
+ }
2373
+ );
2374
+
2375
+ t.select2({
2376
+ dropdownParent: dropdownParent,
2377
+ minimumResultsForSearch: minResultsForSearch,
2378
+ placeholder: plchldr,
2379
+ dir: dir,
2380
+ tags: allowNewTags,
2381
+ allowClear: false,
2382
+ language: {
2383
+ noResults: function () {
2384
+ return nr;
2385
+ },
2386
+ },
2387
+ ...(t.select2.amd.require("adapt_" + uniquer)
2388
+ ? { ajax: {}, dataAdapter: t.select2.amd.require("adapt_" + uniquer) }
2389
+ : {}),
2390
+ });
2391
+ } else {
2392
+ t.select2({
2393
+ dropdownParent: dropdownParent,
2394
+ minimumResultsForSearch: minResultsForSearch,
2395
+ placeholder: plchldr,
2396
+ dir: dir,
2397
+ tags: allowNewTags,
2398
+ allowClear: false,
2399
+ language: {
2400
+ noResults: function () {
2401
+ return nr;
2402
+ },
2403
+ },
2404
+ });
2405
+ }
2406
+
2407
+ if (t.attr("sl-nosrch"))
2408
+ t.on("select2:opening select2:closing", function (event) {
2409
+ var searchfield = $(this).parent().find(".select2-search__field");
2410
+ searchfield.prop("disabled", true);
2411
+ });
2412
+ if (t.attr("sl-class")) {
2413
+ t.on("select2:opening", function (event) {
2414
+ dropdownParent.addClass(t.attr("sl-class"));
2415
+ });
2416
+ t.on("select2:closing", function (event) {
2417
+ dropdownParent.removeClass(t.attr("sl-class"));
2418
+ });
2419
+ }
2420
+
2421
+ } catch (e) {
2422
+ cl(e);
2423
+ }
2424
+ // t.empty().trigger('change');
2425
+ });
2426
+
2427
+ $("[pinnable]:not(.pinnable)").each(function () {
2428
+ var t = $(this);
2429
+ var offsetU = t.attr("pinnable-offset-up") ?? 100;
2430
+ var offsetD = t.attr("pinnable-offset-down") ?? 50;
2431
+ var options = {
2432
+ // vertical offset in px before element is first unpinned
2433
+ offset: 0,
2434
+ // or you can specify offset individually for up/down scroll
2435
+ offset: {
2436
+ up: offsetU,
2437
+ down: offsetD,
2438
+ },
2439
+ // scroll tolerance in px before state changes
2440
+ tolerance: 0,
2441
+ // or you can specify tolerance individually for up/down scroll
2442
+ tolerance: {
2443
+ up: 5,
2444
+ down: 0,
2445
+ },
2446
+ // css classes to apply
2447
+ classes: {
2448
+ // when element is initialised
2449
+ initial: "pinnable",
2450
+ // when scrolling up
2451
+ pinned: "pinnable--pinned",
2452
+ // when scrolling down
2453
+ unpinned: "pinnable--unpinned",
2454
+ // when above offset
2455
+ top: "pinnable--top",
2456
+ // when below offset
2457
+ notTop: "pinnable--not-top",
2458
+ // when at bottom of scroll area
2459
+ bottom: "pinnable--bottom",
2460
+ // when not at bottom of scroll area
2461
+ notBottom: "pinnable--not-bottom",
2462
+ // when frozen method has been called
2463
+ frozen: "pinnable--frozen",
2464
+ // multiple classes are also supported with a space-separated list
2465
+ pinned: "pinnable--pinned",
2466
+ },
2467
+ // element to listen to scroll events on, defaults to `window`
2468
+ // scroller: `window`,
2469
+ // callback when pinned, `this` is pinnable object
2470
+ onPin: function () { },
2471
+ // callback when unpinned, `this` is pinnable object
2472
+ onUnpin: function () { },
2473
+ // callback when above offset, `this` is pinnable object
2474
+ onTop: function () { },
2475
+ // callback when below offset, `this` is pinnable object
2476
+ onNotTop: function () { },
2477
+ // callback when at bottom of page, `this` is pinnable object
2478
+ onBottom: function () { },
2479
+ // callback when moving away from bottom of page, `this` is pinnable object
2480
+ onNotBottom: function () { },
2481
+ };
2482
+ var pinnable = new Headroom(t[0], options);
2483
+ pinnable.init();
2484
+ });
2485
+
2486
+ $("[sort]").each(function (e) {
2487
+ let t = $(this);
2488
+ if (t.hasClass("ui-sortable")) return;
2489
+ let opts = {
2490
+ delay: 50,
2491
+ placeholder: "g_rows_helper",
2492
+ scrollSpeed: 40,
2493
+ opacity: 1,
2494
+ };
2495
+ opts = avc(t, "sort-axis", opts);
2496
+ opts = avc(t, "sort-handle", opts);
2497
+ opts = avc(t, "sort-cancel", opts);
2498
+ opts = avc(t, "sort-cursor", opts, "grabbing");
2499
+ opts = avc(t, "sort-helper", opts, "clone");
2500
+ if (opts.hasOwnProperty("helper") && opts["helper"] != "clone") {
2501
+ if (typeof window[opts["helper"]] === "function")
2502
+ opts["helper"] = window[opts["helper"]];
2503
+ }
2504
+ opts = avc(t, "sort-placeholder", opts);
2505
+ opts = avc(t, "sort-opacity", opts);
2506
+ opts = avc(t, "sort-items", opts);
2507
+ opts = avc(t, "sort-tolerance", opts, "pointer");
2508
+ opts = avc(t, "sort-revert", opts, false);
2509
+ opts = avc(t, "sort-forcePlaceholderSize", opts);
2510
+ opts = avc(t, "sort-containment", opts, "parent");
2511
+ opts = avc(t, "sort-connectWith", opts);
2512
+ if (opts.hasOwnProperty("forceplaceholdersize")) {
2513
+ opts["forcePlaceholderSize"] = opts["forceplaceholdersize"];
2514
+ delete opts["forceplaceholdersize"];
2515
+ }
2516
+ // cl(opts);
2517
+ t.sortable(opts);
2518
+ });
2519
+
2520
+ $("[drag]").each(function (e) {
2521
+ let t = $(this);
2522
+ let opts = {
2523
+ // delay: 50,
2524
+ // placeholder: "g_rows_helper",
2525
+ // scrollSpeed: 40,
2526
+ // opacity: 1,
2527
+ };
2528
+ // opts = avc(t, 'axis', opts);
2529
+ // opts = avc(t, 'handle', opts);
2530
+ // opts = avc(t, 'cancel', opts);
2531
+ // opts = avc(t, 'cursor', opts, 'grabbing');
2532
+ // opts = avc(t, 'helper', opts, 'clone');
2533
+ // opts = avc(t, 'placeholder', opts);
2534
+ opts = avc(t, "drag-connectToSortable", opts);
2535
+ opts = avc(t, "drag-scroll", opts, true);
2536
+ opts = avc(t, "drag-revert", opts, true);
2537
+ opts = avc(t, "drag-helper", opts, "clone");
2538
+ opts = avc(t, "drag-containment", opts, false);
2539
+ opts = avc(t, "drag-cursor", opts, "auto");
2540
+ opts = avc(t, "drag-appendTo", opts, "parent");
2541
+ opts = avc(t, "drag-disabled", opts, false);
2542
+
2543
+ if (opts.disabled == "false") delete opts.disabled;
2544
+ if (opts.hasOwnProperty("appendto")) {
2545
+ opts.appendTo = opts["appendto"];
2546
+ delete opts["appendto"];
2547
+ }
2548
+
2549
+ if (opts.hasOwnProperty("helper") && opts["helper"] != "clone") {
2550
+ if (typeof window[opts["helper"]] === "function")
2551
+ opts["helper"] = window[opts["helper"]];
2552
+ }
2553
+ if (opts.hasOwnProperty("connecttosortable")) {
2554
+ opts["connectToSortable"] = opts["connecttosortable"];
2555
+ delete opts["connecttosortable"];
2556
+ }
2557
+ // opts = avc(t, 'containment', opts, 'parent');
2558
+ // opts = avc(t, 'connectWith', opts);
2559
+ t.draggable(opts);
2560
+ });
2561
+
2562
+
2563
+ $("[drop]").each(function (e) {
2564
+ let t = $(this);
2565
+ let opts = {};
2566
+
2567
+ opts = avc(t, "drop-accept", opts);
2568
+ opts = avc(t, "drop-greedy", opts);
2569
+ opts = avc(t, "drop-hoverClass", opts);
2570
+ opts = avc(t, "drop-disabled", opts, false);
2571
+
2572
+ if (opts.disabled == "false") delete opts.disabled;
2573
+
2574
+ if (opts.hasOwnProperty("hoverclass")) {
2575
+ opts.hoverClass = opts["hoverclass"];
2576
+ delete opts["hoverclass"];
2577
+ }
2578
+
2579
+ t.droppable(opts);
2580
+ });
2581
+
2582
+ $("body").on("touchstart mouseover", function (e) {
2583
+ let isTippedOe = true;
2584
+ if ($(e.target).closest(".oe").length) {
2585
+ let oe = $(e.target).closest(".oe");
2586
+ if (
2587
+ (oe.find("[tip]").length || oe.hasAttr("tip")) &&
2588
+ oe.isOverflown() &&
2589
+ $(window).width() > 480
2590
+ ) {
2591
+ isTippedOe = true;
2592
+ } else isTippedOe = false;
2593
+ }
2594
+ if ($(e.target).closest("[tip]").length && isTippedOe) {
2595
+ var target = $(e.target).closest("[tip]");
2596
+ var tip = `<tip class="pa ${target.attr(
2597
+ "tip-class"
2598
+ )}"><div class="pa [[P]]"><span>[[T]]</span></div></tip>`;
2599
+ if (target.find("droplet").length == 0) {
2600
+ var t = target.attr("tip");
2601
+ var p = target.attr("tip-pos");
2602
+ if (!p) p = "";
2603
+ $("tip").remove();
2604
+ $("body").append(tip.replace("[[T]]", t).replace("[[P]]", p));
2605
+ _isTipped = true;
2606
+ let _tipSc = target;
2607
+ while (true) {
2608
+ if (_isScrollable(_tipSc) || _tipSc[0] == $("body")[0]) break;
2609
+ _tipSc = _tipSc.parent();
2610
+ }
2611
+ var self = target;
2612
+ _setPos(self, p, _tipSc);
2613
+ _setPos(self, p, _tipSc);
2614
+ target.data("_tipSc", _tipSc);
2615
+ _tipSc.unbind("scroll.kuku").bind("scroll.kuku", function () {
2616
+ _setPos(self, p, _tipSc);
2617
+ });
2618
+ } else {
2619
+ $("tip").remove();
2620
+ _isTipped = false;
2621
+ }
2622
+ } else {
2623
+ $("body").unbind("scroll.kuku");
2624
+ $("tip").remove();
2625
+ _isTipped = false;
2626
+ }
2627
+ });
2628
+
2629
+ $("[numeric]").each(function () {
2630
+ $(this).removeAttr("numeric").numeric();
2631
+ });
2632
+
2633
+ $("[pattern]").each(function () {
2634
+ $(this).data("pattern", $(this).attr("pattern")).removeAttr("pattern");
2635
+ });
2636
+
2637
+ $("[integer]:not([pve])").each(function () {
2638
+ $(this).removeAttr("integer").numeric(
2639
+ {
2640
+ decimal: false,
2641
+ } /*, function () { alert("Integers only!"); this.value = ""; this.focus(); }*/
2642
+ );
2643
+ });
2644
+ $("[integer][pve]").each(function () {
2645
+ $(this).removeAttr("integer").numeric(
2646
+ {
2647
+ decimal: false,
2648
+ negative: false,
2649
+ } /*, function () { alert("Positive integers only!"); this.value = ""; this.focus(); }*/
2650
+ );
2651
+ });
2652
+ $("[decimal]:not([pve])").each(function () {
2653
+ var places = -1;
2654
+ if ($(this).is("[dp0]")) places = 0;
2655
+ else if ($(this).is("[dp1]")) places = 1;
2656
+ else if ($(this).is("[dp2]")) places = 2;
2657
+ else if ($(this).is("[dp3]")) places = 3;
2658
+ else if ($(this).is("[dp4]")) places = 4;
2659
+ if (places >= 0)
2660
+ $(this)
2661
+ .removeAttr("decimal")
2662
+ .numeric(
2663
+ {
2664
+ decimalPlaces: places,
2665
+ decimal: places == 0 ? false : ".",
2666
+ } /*, function () { alert("Decimals Only!"); this.value = ""; this.focus(); }*/
2667
+ );
2668
+ else
2669
+ $(this)
2670
+ .removeAttr("decimal")
2671
+ .numeric(
2672
+ {} /*, function () { alert("Decimals Only!"); this.value = ""; this.focus(); }*/
2673
+ );
2674
+ });
2675
+ $("[decimal][pve]").each(function () {
2676
+ var places = -1;
2677
+ if ($(this).is("[dp0]")) places = 0;
2678
+ else if ($(this).is("[dp1]")) places = 1;
2679
+ else if ($(this).is("[dp2]")) places = 2;
2680
+ else if ($(this).is("[dp3]")) places = 3;
2681
+ else if ($(this).is("[dp4]")) places = 4;
2682
+ if (places >= 0)
2683
+ $(this)
2684
+ .removeAttr("decimal")
2685
+ .numeric(
2686
+ {
2687
+ negative: false,
2688
+ decimalPlaces: places,
2689
+ decimal: places == 0 ? false : ".",
2690
+ } /*, function () { alert("Positive Decimals Only!"); this.value = ""; this.focus(); }*/
2691
+ );
2692
+ else
2693
+ $(this).removeAttr("decimal").numeric(
2694
+ {
2695
+ negative: false,
2696
+ } /*, function () { alert("Positive Decimals Only!"); this.value = ""; this.focus(); }*/
2697
+ );
2698
+ });
2699
+
2700
+ $("[time]").each(function () {
2701
+ dtp($(this), "time");
2702
+ });
2703
+ $("[date]").each(function () {
2704
+ dtp($(this), "date");
2705
+ });
2706
+ $("[datetime]").each(function () {
2707
+ dtp($(this), "datetime");
2708
+ });
2709
+
2710
+ $("[color]").each(function () {
2711
+ $(this).removeAttr("color").colorpicker({
2712
+ format: "rgba",
2713
+ });
2714
+ });
2715
+ }
2716
+
2717
+ function dtp(el, t) {
2718
+ el.removeAttr(t);
2719
+ let opts = {
2720
+ format:
2721
+ t == "date" ? "yyyy-mm-dd" : t == "time" ? "hh:ii" : "yyyy-mm-dd hh:ii",
2722
+ weekStart: el.attr("date-week-start") ?? 1,
2723
+ startView: t == "time" ? 1 : 2,
2724
+ minView: el.attr("minview") ? el.attr("minview") : t == "time" ? 0 : t == "datetime" ? 0 : 2,
2725
+ maxView: el.attr("maxview") ? el.attr("maxview") : t == "time" ? 1 : 4,
2726
+ todayBtn: t == "time" ? 0 : el.attr("date-today") == "false" ? 0 : 1,
2727
+ todayHighlight: t == "time" ? 0 : el.attr("date-today") == "false" ? 0 : 1,
2728
+ language: el.attr("date-lang") ?? "en",
2729
+ minuteStep: el.attr("date-minute-step") ?? 5,
2730
+ pickerPosition: "top-right",
2731
+ autoclose: 1,
2732
+ showMeridian: false,
2733
+ };
2734
+ if (el.attr("date-start")) opts["startDate"] = el.attr("date-start");
2735
+ if (el.attr("date-end")) opts["endDate"] = el.attr("date-end");
2736
+ if (el.attr("date-value")) opts["date"] = el.attr("date-value");
2737
+
2738
+ el.datetimepicker(opts);
2739
+
2740
+ if (t == "time") {
2741
+ el.on("show", function (ev) {
2742
+ $(
2743
+ ".table-condensed > thead, .table-condensed > thead > tr > th, .table-condensed > thead > tr > th > i"
2744
+ ).attr(
2745
+ "style",
2746
+ "visibility: hidden; font-size:0px !Important; overflow: hidden; height: 0px;"
2747
+ );
2748
+ }).on("hide", function (ev) {
2749
+ $(
2750
+ ".table-condensed > thead, .table-condensed > thead > tr > th, .table-condensed > thead > tr > th > i"
2751
+ ).attr("style", "visibility: visible;");
2752
+ });
2753
+ }
2754
+ if (el.attr("date-link-start")) {
2755
+ el.on("change", function (e) {
2756
+ let dp1 = el.data("datetimepicker");
2757
+ let dp2 = $(el.attr("date-link-start")).data("datetimepicker");
2758
+ dp2.setStartDate(dp1.getFormattedDate());
2759
+ if (
2760
+ dp2.getFormattedDate() < dp1.getFormattedDate() ||
2761
+ dp2.getFormattedDate() == ""
2762
+ )
2763
+ $(el.attr("date-link-start")).val(dp1.getFormattedDate());
2764
+ });
2765
+ } else if (el.attr("date-link-end")) {
2766
+ el.on("change", function (e) {
2767
+ let dp1 = $(el.attr("date-link-end")).data("datetimepicker");
2768
+ let dp2 = el.data("datetimepicker");
2769
+ dp1.setEndDate(dp2.getFormattedDate());
2770
+ // if(dp2.getFormattedDate()<dp1.getFormattedDate() || dp2.getFormattedDate()=='') $(el.attr('date-link-start')).val(dp1.getFormattedDate());
2771
+ });
2772
+ opts["useCurrent"] = false;
2773
+ }
2774
+ }
2775
+
2776
+ function avc(t, n, o, d = null) {
2777
+ if (t.attr(n.toLowerCase()))
2778
+ o[n.toLowerCase().split("sort-").join("").split("drop-").join("").split("drag-").join("")] = t.attr(
2779
+ n.toLowerCase()
2780
+ );
2781
+ else if (d != null)
2782
+ o[n.toLowerCase().split("sort-").join("").split("drop-").join("").split("drag-").join("")] = d;
2783
+ return o;
2784
+ }
2785
+
2786
+ function applyTriggers() {
2787
+ $("[click]").each(function () {
2788
+ $(this).trigger("click").removeAttr("click");
2789
+ });
2790
+ $("[focus]").each(function () {
2791
+ $(this).trigger("focus").removeAttr("focus");
2792
+ });
2793
+
2794
+ let _Ns = [];
2795
+ for (let x = 9; x >= 0; x--) {
2796
+ let _els = $("[n" + x + "]");
2797
+ _els.each(function () {
2798
+ let _el = $(this);
2799
+ // if (!_el.data('_Ns')) {
2800
+ let _d = {};
2801
+ for (let y = 9; y >= 0; y--) {
2802
+ if (_el.hasAttr("n" + y)) {
2803
+ _d["n" + y] = _el.attr("n" + y).split(",");
2804
+ }
2805
+ }
2806
+ _el.data('_Ns', _d);
2807
+ _Ns.push(_el);
2808
+ // _el.removeClass("active");
2809
+ // }
2810
+ });
2811
+ }
2812
+
2813
+ for (let i = 0; i < _Ns.length; i++) {
2814
+ const _n = _Ns[i];
2815
+ let _act = [];
2816
+ let attrs = _n.data('_Ns');
2817
+
2818
+ for (const nK in attrs) {
2819
+ if (Object.hasOwnProperty.call(attrs, nK)) {
2820
+ const nV = attrs[nK];
2821
+ let index = nK.slice(1);
2822
+ if (nV.indexOf(nodes[index]) != -1) {
2823
+ _act.push(true);
2824
+ } else {
2825
+ _act.push(false);
2826
+ break;
2827
+ }
2828
+ }
2829
+ }
2830
+ setTimeout(() => {
2831
+ if (_act.indexOf(false) != -1) _n.removeClass("active");
2832
+ else _n.addClass("active");
2833
+ });
2834
+ }
2835
+
2836
+
2837
+ // if (nodes[x]) {
2838
+ // $("[n" + x + "]").each(function () {
2839
+ // let attr = $(this)
2840
+ // .attr("n" + x)
2841
+ // .split(",");
2842
+ // for (let index = 0; index < attr.length; index++) {
2843
+ // if (attr[index] == nodes[x]) {
2844
+ // $(this).addClass("active");
2845
+ // }
2846
+ // }
2847
+ // });
2848
+ // }
2849
+
2850
+
2851
+ if (typeof viewLoaded === "function" && !_viewLoaded) {
2852
+ _viewLoaded = true;
2853
+ viewLoaded();
2854
+ }
2855
+ $(
2856
+ "[\\@scroll],[\\@scroll-start],[\\@scroll-end],[\\@scroll-left],[\\@scroll-right],[\\@scroll-top],[\\@scroll-bottom]"
2857
+ )
2858
+ .unbind("scroll touchmove scrollstart scrollend")
2859
+ .on("scroll touchmove scrollstart scrollend", function (ev) {
2860
+ let el = $(this);
2861
+ if (ev.type == "scrollend") {
2862
+ var newScrollLeft = el.scrollLeft(),
2863
+ newScrollTop = el.scrollTop(),
2864
+ width = el.width(),
2865
+ scrollWidth = el.get(0).scrollWidth,
2866
+ scrollHeight = el.get(0).scrollHeight;
2867
+
2868
+ var hasScX = el.prop("scrollWidth") > el.width();
2869
+ var hasScY = el.prop("scrollHeight") > el.height();
2870
+
2871
+ if (newScrollLeft == 0) {
2872
+ processEv(ev, el, "scroll-left");
2873
+ } else if (
2874
+ Math.round(
2875
+ scrollWidth - newScrollLeft - width - (hasScY ? -_scW : 0)
2876
+ ) == 0
2877
+ ) {
2878
+ processEv(ev, el, "scroll-right");
2879
+ }
2880
+ if (newScrollTop == 0) {
2881
+ processEv(ev, el, "scroll-top");
2882
+ } else if (
2883
+ newScrollTop + el.innerHeight() >=
2884
+ scrollHeight - (hasScX ? -_scW : 0)
2885
+ ) {
2886
+ processEv(ev, el, "scroll-bottom");
2887
+ }
2888
+ }
2889
+ processEv(
2890
+ ev,
2891
+ el,
2892
+ ev.type.length == 6 ? "scroll" : ev.type.split("scroll").join("scroll-")
2893
+ );
2894
+ });
2895
+ }
2896
+
2897
+ _viewLoaded = false;
2898
+ function globalWatch() {
2899
+ if (!_initialized) return;
2900
+
2901
+
2902
+ return;
2903
+
2904
+ $("[beajs=1]").remove();
2905
+ $('script[type="beajs"]').each(function () {
2906
+ var html = $(this).html();
2907
+ $(this).remove();
2908
+ var myScript = document.createElement("script");
2909
+ myScript.setAttribute("beajs", "1");
2910
+ myScript.textContent = html;
2911
+ document.body.appendChild(myScript);
2912
+ });
2913
+ let bindsCount = 0;
2914
+ let prom = defer();
2915
+ $("[bind]:not(.binded)").each(function () {
2916
+ bindsCount++;
2917
+ let _el = $(this);
2918
+ _el.addClass("binded");
2919
+ if (!setRe(_el, _el.attr("bind")))
2920
+ setError(
2921
+ null,
2922
+ "Error in binding for the element that has these in its bind attribute " +
2923
+ _el.attr("bind")
2924
+ );
2925
+ });
2926
+ prom
2927
+ .then(function (val) {
2928
+ renderViewsTpls();
2929
+ renderPlugins();
2930
+ loadPics();
2931
+ reloads();
2932
+ let tickFunc =
2933
+ appSettings.tick && typeof appSettings.tick === "function"
2934
+ ? appSettings.tick
2935
+ : typeof tick === "function"
2936
+ ? tick
2937
+ : null;
2938
+ if (typeof tickFunc === "function") tickFunc();
2939
+ })
2940
+ .catch((reason) => {
2941
+ renderViewsTpls();
2942
+ renderPlugins();
2943
+ loadPics();
2944
+ reloads();
2945
+ let tickFunc =
2946
+ appSettings.tick && typeof appSettings.tick === "function"
2947
+ ? appSettings.tick
2948
+ : typeof tick === "function"
2949
+ ? tick
2950
+ : null;
2951
+ if (typeof tickFunc === "function") tickFunc();
2952
+ });
2953
+ if (bindsCount == 0) {
2954
+ prom.resolve();
2955
+ }
2956
+ reloads();
2957
+ let tickFunc =
2958
+ appSettings.tick && typeof appSettings.tick === "function"
2959
+ ? appSettings.tick
2960
+ : typeof tick === "function"
2961
+ ? tick
2962
+ : null;
2963
+ if (typeof tickFunc === "function") tickFunc();
2964
+ }
2965
+
2966
+ function loadPics() {
2967
+ $("[lazy]").each(function () {
2968
+ let _el = $(this);
2969
+ _el.lazy({
2970
+ effect: "show",
2971
+ bind: "event",
2972
+ // effectTime: 200,
2973
+ threshold: 200 /*Amount of pixels below the viewport, in which all images gets loaded before the user sees them.*/,
2974
+ visibleOnly: false /*Determine if only visible elements should be load.*/,
2975
+ beforeLoad: function (element) {
2976
+ /*alert('before loading ' + element.attr('data-src'));*/
2977
+ _el.removeAttr("lazy");
2978
+ },
2979
+ afterLoad: function (element) {
2980
+ /*alert('after loading ' + element.attr('data-src'));*/
2981
+ },
2982
+ onError: function (element) {
2983
+ /*alert('error loading ' + element.attr('data-src'));*/
2984
+ cl("error loading " + _el.attr("data-src"));
2985
+ },
2986
+ onFinishedAll: function () {
2987
+ /*alert('finish all');*/
2988
+ },
2989
+ });
2990
+ });
2991
+ }
2992
+
2993
+ function paraToObj(para) {
2994
+ if (para == "") return JSON.parse("{}");
2995
+ return JSON.parse(
2996
+ '{"' +
2997
+ decodeURI(para)
2998
+ .replace(/"/g, '\\"')
2999
+ .replace(/&/g, '","')
3000
+ .replace(/=/g, '":"') +
3001
+ '"}'
3002
+ );
3003
+ }
3004
+
3005
+ function getBind(b, d) {
3006
+ d = d ? d.split("&") : new Array();
3007
+ if (b) {
3008
+ var binder = b.split(",");
3009
+ for (var x = 0; x < binder.length; x++) {
3010
+ var finder = binder[x].split(" as ");
3011
+ if (finder[0].indexOf(" attr ") !== -1) {
3012
+ var findz = finder[0].split(" attr ");
3013
+ d.push(finder[1] + "=" + $.trim($(findz[0]).attr(findz[1])));
3014
+ } else if (finder[0].indexOf(" find ") !== -1) {
3015
+ var findz = finder[0].split(" find ");
3016
+ var val = getVal($(findz[0]).find(findz[1]));
3017
+ d.push(finder[1] + "=" + $.trim(val));
3018
+ } else if (finder[0].indexOf(" from ") !== -1) {
3019
+ var findz = finder[0].split(" from ");
3020
+ if (findz[1].toLowerCase() == "ls") {
3021
+ d.push(finder[1] + "=" + localStorage.getItem(findz[0]));
3022
+ } else {
3023
+ d.push(finder[1] + "=" + findz[0]);
3024
+ }
3025
+ } else d.push(finder[1] + "=" + getVal($(finder[0])));
3026
+ }
3027
+ }
3028
+ d = d.join("&");
3029
+ return d;
3030
+ }
3031
+
3032
+ function isPathLocal(path) {
3033
+ var local = false;
3034
+ var l = getLocation(path);
3035
+ var l2 = getLocation(appSettings.Base);
3036
+ var url = "home";
3037
+ local = l.hostname == l2.hostname;
3038
+ return local;
3039
+ }
3040
+
3041
+ function checkFormInputs(f, inp, classesOnly) {
3042
+ var inputs = inp ? [inp] : f.find("[\\:required]:not([disabled])");
3043
+ for (var i = 0; i < inputs.length; i++) {
3044
+ let el = $(inputs[i]);
3045
+ let pat = el.data("pattern");
3046
+ let req = el.hasAttr(":required");
3047
+ let lbl = el.closest("label");
3048
+ let fs = el.closest("fieldset");
3049
+ let max = el.attr("max");
3050
+ let max_num = el.attr("max-num");
3051
+ let min_num = el.attr("min-num");
3052
+ let v = el.val();
3053
+ var or = el.attr("or");
3054
+ if (or != "") {
3055
+ var or = f.find("[name='" + or + "']");
3056
+ }
3057
+ var into;
3058
+ let allCls =
3059
+ "is-not-checked is-checked is-valid is-not-empty is-empty is-invalid error success not-4-chars not-on-pattern";
3060
+ el.removeClass(allCls);
3061
+ el.parent().removeClass(allCls);
3062
+ if (lbl.length) lbl.removeClass(allCls);
3063
+ if (fs.length) fs.removeClass(allCls);
3064
+ if (el.is(":checkbox") || el.is(":radio")) {
3065
+ var isCheck = "is-not-checked" + (req ? " is-invalid" : "");
3066
+ if (el.is(":checked")) {
3067
+ isCheck = "is-checked" + (req ? " is-valid" : "");
3068
+ } else {
3069
+ if (or.length) {
3070
+ if (or.is(":checked")) {
3071
+ isCheck = "is-checked" + (req ? " is-valid" : "");
3072
+ }
3073
+ }
3074
+ }
3075
+ if (el.is(":radio")) {
3076
+ f.find("[name='" + el.attr("Name") + "']:radio")
3077
+ .not(el[0])
3078
+ .each(function () {
3079
+ let _el = $(this);
3080
+ let _req = _el.hasAttr(":required");
3081
+ var _isCheck = "is-not-checked" + (_req ? " is-invalid" : "");
3082
+ var _or = _el.attr("or");
3083
+ let _lbl = _el.closest("label");
3084
+ // let _fs = _el.closest("fieldset");
3085
+ _el.removeClass(allCls);
3086
+ _el.parent().removeClass(allCls);
3087
+ if (_lbl.length) _lbl.removeClass(allCls);
3088
+ // if (_fs.length) _fs.removeClass(allCls);
3089
+ if (_or != "") {
3090
+ var _or = f.find("[name='" + _or + "']");
3091
+ }
3092
+ if (_el.is(":checked")) {
3093
+ _isCheck = "is-checked" + (_req ? " is-valid" : "");
3094
+ } else {
3095
+ if (_or.length) {
3096
+ if (_or.is(":checked")) {
3097
+ _isCheck = "is-checked" + (_req ? " is-valid" : "");
3098
+ }
3099
+ }
3100
+ }
3101
+ if (_el.parent().prop("nodeName") != "FORM")
3102
+ _el.parent().addClass(_isCheck);
3103
+ if (_lbl.length) _lbl.addClass(_isCheck);
3104
+ // if (_fs.length) _fs.addClass(_isCheck);
3105
+ _el.addClass(_isCheck);
3106
+ });
3107
+ }
3108
+
3109
+ if (el.parent().prop("nodeName") != "FORM") el.parent().addClass(isCheck);
3110
+ if (lbl.length) lbl.addClass(isCheck);
3111
+ // if (fs.length) fs.addClass(isCheck);
3112
+ el.addClass(isCheck);
3113
+ } else {
3114
+ var isV = "is-empty" + (req ? " is-invalid" : "");
3115
+ if (el.is("[username]")) {
3116
+ if (v.length && v.length < 4) {
3117
+ isV = "not-4-chars is-not-empty" + (req ? " is-invalid" : "");
3118
+ } else {
3119
+ let vld = true;
3120
+ var k = v.match(/[a-z]+(?!\.)(?!.*\.$)(?!.*?\_\_)[a-z0-9_]+[a-z0-9]/);
3121
+ if (!k) {
3122
+ vld = false;
3123
+ } else {
3124
+ if (k.input != k[0]) {
3125
+ vld = false;
3126
+ }
3127
+ }
3128
+ if (vld) isV = "is-not-empty" + (req ? " is-valid" : "");
3129
+ else isV = "not-on-pattern is-not-empty" + (req ? " is-invalid" : "");
3130
+ }
3131
+ } else if (el.is("[password]")) {
3132
+ if (!passwordValid(v)) {
3133
+ isV = "is-not-empty" + (req ? " is-invalid" : "");
3134
+ } else {
3135
+ isV = "is-not-empty" + (req ? " is-valid" : "");
3136
+ }
3137
+ } else if (el.is("[rpassword]")) {
3138
+ if ($.trim(v) != $.trim(f.find("[password]").val())) {
3139
+ isV = "is-not-empty" + (req ? " is-invalid" : "");
3140
+ } else {
3141
+ isV = "is-not-empty" + (req ? " is-valid" : "");
3142
+ }
3143
+ } else {
3144
+ if ($.trim(v).length != 0) {
3145
+ if (max != "" && !isNaN(max)) {
3146
+ if ($.trim(v).length > max) {
3147
+ el.val($.trim($.trim(v).substr(0, max)));
3148
+ }
3149
+ }
3150
+ if (min_num != "" && !isNaN(min_num)) {
3151
+ if (!isNaN($.trim(v))) {
3152
+ if (parseFloat($.trim(v)) < parseFloat(min_num))
3153
+ el.val($.trim(min_num));
3154
+ } else {
3155
+ el.val(min_num);
3156
+ }
3157
+ }
3158
+
3159
+ if (max_num != "" && !isNaN(max_num)) {
3160
+ if (!isNaN($.trim(v))) {
3161
+ if (parseFloat($.trim(v)) > parseFloat(max_num))
3162
+ el.val($.trim(max_num));
3163
+ } else {
3164
+ if (min_num != "" && !isNaN(min_num)) el.val($.trim(min_num));
3165
+ else el.val("0");
3166
+ }
3167
+ }
3168
+ isV = "is-not-empty";
3169
+ if (pat != "") {
3170
+ pat = new RegExp(pat);
3171
+ if (pat.test($.trim(v))) {
3172
+ isV += req ? " is-valid" : "";
3173
+ } else {
3174
+ isV += req ? " is-invalid" : "";
3175
+ el.val("");
3176
+ }
3177
+ } else isV += req ? " is-valid" : "";
3178
+ } else {
3179
+ if (or.length) {
3180
+ if ($.trim(or.val()).length != 0) {
3181
+ isV = "is-not-empty" + (req ? " is-valid" : "");
3182
+ }
3183
+ }
3184
+ }
3185
+ }
3186
+ if (el.parent().prop("nodeName") != "FORM") el.parent().addClass(isV);
3187
+ if (lbl.length) lbl.addClass(isV);
3188
+ // if (fs.length) fs.addClass(isV);
3189
+ el.addClass(isV);
3190
+ }
3191
+
3192
+ var isRadioChecked = false;
3193
+ if (el.is(":radio")) {
3194
+ if (el.hasClass("is-invalid")) {
3195
+ f.find("[name='" + el.attr("Name") + "']:radio")
3196
+ .not(el[0])
3197
+ .each(function () {
3198
+ if ($(this).hasClass("is-valid")) {
3199
+ isRadioChecked = true;
3200
+ }
3201
+ });
3202
+ } else {
3203
+ isRadioChecked = true;
3204
+ }
3205
+ }
3206
+
3207
+ if (el.hasClass("is-invalid") || (el.is(":radio") && !isRadioChecked)) {
3208
+ if (el.hasAttr("data-into")) {
3209
+ let intoTxt = el.data("into");
3210
+ if (lbl.length) into = lbl.find(intoTxt);
3211
+ if (!into) if (fs.length) into = fs.find(intoTxt);
3212
+ if (!into) into = $(intoTxt);
3213
+ if (into.length) {
3214
+ if (el.is("[password]")) {
3215
+ if ($.trim(v).length == 0) into.text(el.attr("data-empty"));
3216
+ else if (el.hasAttr("data-wpm")) into.text(el.attr("data-wpm"));
3217
+ let rpass = f.find("[rpassword]");
3218
+ if (rpass.length)
3219
+ if ($.trim(rpass.val()).length != 0)
3220
+ checkFormInputs(f, rpass, true);
3221
+ } else if (el.is("[rpassword]")) {
3222
+ if ($.trim(v).length == 0) into.text(el.attr("data-empty"));
3223
+ else if (el.hasAttr("data-pnm")) into.text(el.attr("data-pnm"));
3224
+ } else if (el.is("[username]")) {
3225
+ let txt = el.hasAttr("data-empty")
3226
+ ? el.attr("data-empty")
3227
+ : el.attr("placeholder");
3228
+ if ($.trim(v).length == 0) into.text(txt);
3229
+ else {
3230
+ if (el.hasClass("not-4-chars")) {
3231
+ if (el.hasAttr("data-4-chars")) txt = el.attr("data-4-chars");
3232
+ } else if (el.hasClass("not-on-pattern")) {
3233
+ if (el.hasAttr("data-chars-not-allowed"))
3234
+ txt = el.attr("data-chars-not-allowed");
3235
+ }
3236
+ into.text(txt);
3237
+ }
3238
+ } else if (el.hasAttr("data-empty")) {
3239
+ into.text(el.attr("data-empty"));
3240
+ } else {
3241
+ if (el.is(":checkbox") || el.is(":radio")) {
3242
+ // alert("checkbox or radio don't have data-empty attribute");
3243
+ into.text(el.attr("placeholder"));
3244
+ } else {
3245
+ into.text(el.attr("placeholder"));
3246
+ }
3247
+ }
3248
+ }
3249
+ }
3250
+ if (!classesOnly) {
3251
+ if (el.is(":radio")) {
3252
+ if (!isRadioChecked) {
3253
+ if (fs.length) fs.addClass(isCheck);
3254
+ el.focus();
3255
+ return false;
3256
+ }
3257
+ } else {
3258
+ if (fs.length) fs.addClass(isV);
3259
+ el.focus();
3260
+ return false;
3261
+ }
3262
+ } else {
3263
+ if (el.is(":radio")) {
3264
+ if (!isRadioChecked) {
3265
+ if (fs.length) fs.addClass(isCheck);
3266
+ }
3267
+ } else {
3268
+ if (fs.length) fs.addClass(isV);
3269
+ }
3270
+ }
3271
+ } else if (el.hasClass("is-valid")) {
3272
+ if (el.hasAttr("data-into")) {
3273
+ let intoTxt = el.data("into");
3274
+ if (lbl.length) into = lbl.find(intoTxt);
3275
+ if (fs.length) into = fs.find(intoTxt);
3276
+ if (!into) into = $(intoTxt);
3277
+ if (into.length) {
3278
+ into.text("");
3279
+ }
3280
+ }
3281
+ }
3282
+ }
3283
+
3284
+ return true;
3285
+ }
3286
+ function validateInputs(f) {
3287
+ if (f.hasAttr("ax-before")) {
3288
+ var bfs = f.attr("ax-before");
3289
+ if (typeof window[bfs] === "function") {
3290
+ if (window[bfs](f) === false) return false;
3291
+ }
3292
+ }
3293
+
3294
+ var inps = [];
3295
+ f.find("input.required,select.required,textarea.required").each(function () {
3296
+ inps.push($(this).attr("name"));
3297
+ });
3298
+ for (var i = 0; i < inps.length; i++) {
3299
+ var inp = f.find("input[name='" + inps[i] + "']");
3300
+ var sel = f.find('select[name="' + inps[i] + '"]');
3301
+ var txt = f.find('textarea[name="' + inps[i] + '"]');
3302
+ var e = inp;
3303
+ if (!e.length) e = sel;
3304
+ if (!e.length) e = txt;
3305
+ var or = e.attr("or");
3306
+
3307
+ if (or != "") {
3308
+ var inp2 = f.find("input[name='" + or + "']");
3309
+ var sel2 = f.find('select[name="' + or + '"]');
3310
+ var txt2 = f.find('textarea[name="' + or + '"]');
3311
+ var or = inp2;
3312
+ if (!or.length) or = sel2;
3313
+ if (!or.length) or = txt2;
3314
+ }
3315
+
3316
+ if (e.is(":checkbox") || e.is(":radio")) {
3317
+ if (!e.is(":checked")) {
3318
+ if (or.length) {
3319
+ if (!or.is(":checked")) {
3320
+ alert(e.attr("placeholder") + " or " + or.attr("placeholder"));
3321
+ e.addClass("error");
3322
+ e.focus();
3323
+ return false;
3324
+ }
3325
+ } else {
3326
+ alert(e.attr("placeholder"));
3327
+ e.addClass("error");
3328
+ e.focus();
3329
+ return false;
3330
+ }
3331
+ }
3332
+ } else {
3333
+ if ($.trim(e.val()).length == 0) {
3334
+ if (or.length) {
3335
+ if ($.trim(or.val()).length == 0) {
3336
+ alert(e.attr("placeholder") + " or " + or.attr("placeholder"));
3337
+ e.addClass("error");
3338
+ e.focus();
3339
+ return false;
3340
+ }
3341
+ } else {
3342
+ alert(e.attr("placeholder"));
3343
+ e.addClass("error");
3344
+ e.focus();
3345
+ return false;
3346
+ }
3347
+ }
3348
+
3349
+ if (e.is("[password]")) {
3350
+ if (!passwordValid(e.val())) {
3351
+ alert(e.attr("data-wpm"));
3352
+ e.addClass("error");
3353
+ e.focus();
3354
+ return false;
3355
+ }
3356
+ }
3357
+ if (e.is("[rpassword]")) {
3358
+ if (
3359
+ $.trim(e.val()) != $.trim(e.closest("form").find("[password]").val())
3360
+ ) {
3361
+ e.addClass("error");
3362
+ alert(e.attr("data-pnm"));
3363
+ e.focus();
3364
+ return false;
3365
+ }
3366
+ e.removeClass("error");
3367
+ $(".passStrength").remove();
3368
+ }
3369
+ }
3370
+ }
3371
+
3372
+ return true;
3373
+ }
3374
+
3375
+
3376
+ let _cookies = {
3377
+ getItem: function (sKey) {
3378
+ if (!sKey) { return null; }
3379
+ return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null;
3380
+ },
3381
+ setItem: function (sKey, sValue, vEnd, sPath, sDomain, bSecure) {
3382
+ if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) { return false; }
3383
+ var sExpires = "";
3384
+ if (vEnd) {
3385
+ switch (vEnd.constructor) {
3386
+ case Number:
3387
+ sExpires = vEnd === Infinity ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; max-age=" + vEnd;
3388
+ break;
3389
+ case String:
3390
+ sExpires = "; expires=" + vEnd;
3391
+ break;
3392
+ case Date:
3393
+ sExpires = "; expires=" + vEnd.toUTCString();
3394
+ break;
3395
+ }
3396
+ }
3397
+ if (!sPath) sPath = "/";
3398
+ document.cookie = encodeURIComponent(sKey) + "=" + encodeURIComponent(sValue) + sExpires + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "") + (bSecure ? "; secure" : "");
3399
+ return true;
3400
+ },
3401
+ removeItem: function (sKey, sPath, sDomain) {
3402
+ if (!this.hasItem(sKey)) { return false; }
3403
+ document.cookie = encodeURIComponent(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT" + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "");
3404
+ return true;
3405
+ },
3406
+ hasItem: function (sKey) {
3407
+ if (!sKey) { return false; }
3408
+ return (new RegExp("(?:^|;\\s*)" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie);
3409
+ },
3410
+ keys: function () {
3411
+ var aKeys = document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, "").split(/\s*(?:\=[^;]*)?;\s*/);
3412
+ for (var nLen = aKeys.length, nIdx = 0; nIdx < nLen; nIdx++) { aKeys[nIdx] = decodeURIComponent(aKeys[nIdx]); }
3413
+ return aKeys;
3414
+ }
3415
+ };
3416
+ var cookies = new Proxy(_cookies, {
3417
+ get(target, key) {
3418
+ return target[key] ?? target.getItem(key) ?? undefined;
3419
+ },
3420
+ set(target, key, value) {
3421
+ if (key in target) {
3422
+ return false;
3423
+ }
3424
+ return target.setItem(key, value);
3425
+ },
3426
+ deleteProperty(target, key) {
3427
+ if (!(key in target)) {
3428
+ return false;
3429
+ }
3430
+ return target.removeItem(key);
3431
+ },
3432
+ ownKeys(target) {
3433
+ return target.keys();
3434
+ },
3435
+ has(target, key) {
3436
+ return key in target || target.hasItem(key);
3437
+ },
3438
+ defineProperty(target, key, descriptor) {
3439
+ if (descriptor && "value" in descriptor) {
3440
+ target.setItem(key, descriptor.value);
3441
+ }
3442
+ return target;
3443
+ },
3444
+ getOwnPropertyDescriptor(target, key) {
3445
+ const value = target.getItem(key);
3446
+ return value
3447
+ ? {
3448
+ value,
3449
+ enumerable: true,
3450
+ configurable: true,
3451
+ }
3452
+ : undefined;
3453
+ },
3454
+ });
3455
+
3456
+ function getCookie(n) {
3457
+ return cookies[n];
3458
+ }
3459
+
3460
+ function setCookie(n, v, d, p, e) {
3461
+ var now = new Date();
3462
+ var time = now.getTime();
3463
+ if (!e) e = time + 24 * 60 * 60 * 1000 * 365;
3464
+ else e = time + e;
3465
+ if (!d) d = window.location.hostname;
3466
+ if (!p) p = "/";
3467
+ now.setTime(e);
3468
+ return cookies.setItem(n, v, now.toGMTString(), p, d, true);
3469
+ }
3470
+
3471
+ function getComData(c, fromHTML) {
3472
+ if (fromHTML) {
3473
+ try {
3474
+ var el = $("<div></div>");
3475
+ el.html(c.html());
3476
+ var k = {};
3477
+
3478
+ var mtitle = $("modal-title", el).html();
3479
+ if (!mtitle) mtitle = "";
3480
+
3481
+ var mbody = $("modal-body", el).html();
3482
+ if (!mbody) mbody = "";
3483
+
3484
+ var mdesc = $("modal-description", el).html();
3485
+ if (!mdesc) mdesc = "";
3486
+
3487
+ var mfoot = $("modal-footer", el).html();
3488
+ if (!mfoot) mfoot = "";
3489
+
3490
+ k.Title = mtitle;
3491
+ k.Body = mbody;
3492
+ k.Description = mdesc;
3493
+ k.Footer = mfoot;
3494
+ c = k;
3495
+ return c;
3496
+ } catch (e) {
3497
+ return false;
3498
+ }
3499
+
3500
+ return false;
3501
+ }
3502
+ try {
3503
+ c = c
3504
+ .contents()
3505
+ .filter(function () {
3506
+ return this.nodeType === 8;
3507
+ })
3508
+ .get(0);
3509
+
3510
+ if (c.nodeValue == "") return false;
3511
+ try {
3512
+ c = JSON.parse(c.nodeValue);
3513
+ } catch (e) {
3514
+ try {
3515
+ c = JSON.parse(atob(c.nodeValue));
3516
+ } catch (e) {
3517
+ try {
3518
+ var el = $("<div></div>");
3519
+ el.html(c.nodeValue);
3520
+ var k = {};
3521
+
3522
+ var mtitle = $("modal-title", el).html();
3523
+ if (!mtitle) mtitle = "";
3524
+
3525
+ var mbody = $("modal-body", el).html();
3526
+ if (!mbody) mbody = "";
3527
+
3528
+ var mdesc = $("modal-description", el).html();
3529
+ if (!mdesc) mdesc = "";
3530
+
3531
+ var mfoot = $("modal-footer", el).html();
3532
+ if (!mfoot) mfoot = "";
3533
+
3534
+ k.Title = mtitle;
3535
+ k.Body = mbody;
3536
+ k.Description = mdesc;
3537
+ k.Footer = mfoot;
3538
+ c = k;
3539
+ } catch (e) {
3540
+ return false;
3541
+ }
3542
+ }
3543
+ }
3544
+ return c;
3545
+ } catch (e) {
3546
+ return false;
3547
+ }
3548
+ }
3549
+
3550
+ function addOrChangeParameters(url, params) {
3551
+ let splitParams = {};
3552
+ let splitPath = /(.*)[?](.*)/.exec(url);
3553
+ if (splitPath && splitPath[2])
3554
+ splitPath[2].split("&").forEach((k) => {
3555
+ let d = k.split("=");
3556
+ splitParams[d[0]] = d[1];
3557
+ });
3558
+ let newParams = Object.assign(splitParams, params);
3559
+ let finalParams = Object.keys(newParams)
3560
+ .map((a) => a + "=" + newParams[a])
3561
+ .join("&");
3562
+ return splitPath ? splitPath[1] + "?" + finalParams : url + "?" + finalParams;
3563
+ }
3564
+
3565
+ //class SDK//
3566
+ class BEA {
3567
+ Cart = null;
3568
+ Products = null;
3569
+ Authorize = null;
3570
+ Pay = null;
3571
+ localCache = true;
3572
+ _prom = null;
3573
+ proms = [];
3574
+ l = "En";
3575
+ fields = {
3576
+ Section: "Section,Title,Text",
3577
+ Product: "Name,Price,Quantity",
3578
+ };
3579
+ constructor(options) {
3580
+ if (options === undefined) options = {};
3581
+ if (!Object.keys(options).length == 0) {
3582
+ if (options.hasOwnProperty("fields")) {
3583
+ for (var i in options["fields"]) {
3584
+ this.fields[i] = options["fields"][i];
3585
+ }
3586
+ }
3587
+ if (options.hasOwnProperty("localisation")) this.l = options.localisation;
3588
+ if (options.hasOwnProperty("locale") && options.locale === true) {
3589
+ this.getLocale();
3590
+ }
3591
+ if (options.hasOwnProperty("sections") && options.sections === true) {
3592
+ this.getSections();
3593
+ }
3594
+ if (
3595
+ options.hasOwnProperty("localCache") &&
3596
+ options.localCache === false
3597
+ ) {
3598
+ this.localCache = false;
3599
+ }
3600
+ }
3601
+ this.Cart = new Cart(this);
3602
+ this.Products = new Products(this);
3603
+ this.Authorize = new Authorize(this);
3604
+ this.Pay = new Pay(this);
3605
+ this._prom = Promise.all(this.proms);
3606
+ }
3607
+
3608
+ request(className, data, async, type, a) {
3609
+ var prom = defer();
3610
+ var x;
3611
+ API.req(className, data, null, type, a ?? 0).then((r) => {
3612
+ if (async) {
3613
+ prom.resolve(r);
3614
+ } else {
3615
+ x = r.results;
3616
+ }
3617
+ });
3618
+ if (async) return prom;
3619
+ return x;
3620
+ }
3621
+
3622
+ getSections() {
3623
+ var sec = new Section(this);
3624
+ this.proms.push(sec._prom);
3625
+ return sec.get();
3626
+ }
3627
+
3628
+ getLocale() {
3629
+ var loc = new Locale(this);
3630
+ this.proms.push(loc._prom);
3631
+ return loc.get();
3632
+ }
3633
+
3634
+ order() {
3635
+ let prom = defer();
3636
+ var ids = "";
3637
+ var productsInfo;
3638
+ var user;
3639
+ var orderData = {
3640
+ User: "",
3641
+ productItems: [],
3642
+ Amount: 0,
3643
+ };
3644
+
3645
+ user = this.Authorize.me();
3646
+ orderData.User = user.objectId;
3647
+
3648
+ $.each(this.Cart.cartData, function (key, value) {
3649
+ ids = ids + value.P + ",";
3650
+ });
3651
+
3652
+ this.Products.get(
3653
+ {
3654
+ fields: "Name,Price,Quantity",
3655
+ media: "images",
3656
+ crops: "ax200,ax600,ax700,200x200,ax300",
3657
+ },
3658
+ { ids: ids },
3659
+ true
3660
+ ).then((res) => {
3661
+ let productsInfo = res.results;
3662
+ var productsDB = Object.assign(
3663
+ {},
3664
+ ...productsInfo.map((x) => ({ [x.objectId]: x }))
3665
+ );
3666
+
3667
+ $.each(this.Cart.cartData, function (key, value) {
3668
+ orderData.productItems.push({
3669
+ Qty: value.Q,
3670
+ Product: value.P,
3671
+ productData: JSON.stringify(productsDB[value.P]),
3672
+ Price: productsDB[value.P].Price,
3673
+ });
3674
+ orderData.Amount += value.Q * productsDB[value.P].Price;
3675
+ });
3676
+
3677
+ this.request(
3678
+ "/Order",
3679
+ { User: orderData.User, Amount: orderData.Amount },
3680
+ true,
3681
+ "POST"
3682
+ ).then((res) => {
3683
+ let orderId = res.results;
3684
+ for (var i = 0; i < orderData.productItems.length; i++) {
3685
+ orderData.productItems[i]["Order"] = orderId[0].objectId;
3686
+ this.request("/orderItems ", orderData.productItems[i], true, "POST");
3687
+ }
3688
+ prom.resolve(orderId);
3689
+ });
3690
+ });
3691
+ return prom;
3692
+ }
3693
+
3694
+ sendEmail(data) {
3695
+ let prom = defer();
3696
+ this.request("/_Emails/send", data, true, "POST").then((res) => {
3697
+ prom.resolve(r);
3698
+ });
3699
+ }
3700
+
3701
+ batch(data) {
3702
+ return this.request("/batch", data, true, "POST");
3703
+ }
3704
+
3705
+ query(className, data) {
3706
+ return this.request(className, data, true, "GET");
3707
+ }
3708
+
3709
+ get(className, data, options = true) {
3710
+ return this.request(className, data, options, "GET");
3711
+ }
3712
+
3713
+ post(className, data, options = true) {
3714
+ return this.request(className, data, options, "POST");
3715
+ }
3716
+
3717
+ put(className, data, options = true) {
3718
+ return this.request(className, data, options, "PUT");
3719
+ }
3720
+
3721
+ delete(className, options = true) {
3722
+ return this.request(className, "", options, "DELETE");
3723
+ }
3724
+ }
3725
+ //end SDK//
3726
+
3727
+ //class pay//
3728
+ class Pay {
3729
+ tsdk = null;
3730
+ object = {};
3731
+ constructor(tsdk) {
3732
+ this.tsdk = tsdk;
3733
+ let self = this;
3734
+ $(window)
3735
+ .unbind("message")
3736
+ .on("message", function (e) {
3737
+ let dd = $("#gosell-gateway")[0].contentWindow;
3738
+ if (e.originalEvent.source === dd && e.originalEvent.data == "close") {
3739
+ $(".gosell-gateway").remove();
3740
+ self.onClose();
3741
+ }
3742
+ });
3743
+ }
3744
+
3745
+ create(data) {
3746
+ let prom = defer();
3747
+ API.post("https://pay.bea.com.lb/create", data, {}, 666)
3748
+ .then((d) => {
3749
+ this.object = d;
3750
+ cl(d);
3751
+ this.process(
3752
+ this.object.transaction.url.replace("mode=page", "mode=popup")
3753
+ );
3754
+ prom.resolve(this.object.id);
3755
+ })
3756
+ .catch((err) => {
3757
+ cl(err);
3758
+ });
3759
+ return prom;
3760
+ }
3761
+
3762
+ process(link) {
3763
+ var d = `
3764
+ <div class="gosell-gateway" reactive>
3765
+ <div style="position: fixed;left: 0;right: 0;top: 0;bottom: 0;z-index: 9999;background-color: rgb(0,0,0,0.2);">
3766
+ <iframe id="gosell-gateway"
3767
+ src="${link}" width="100%"
3768
+ height="100%"
3769
+ style="display: block; position: absolute; inset: 0px; margin: auto; border: 0px; z-index: 2147483647;"></iframe>
3770
+ </div>
3771
+ </div>
3772
+ `;
3773
+ $("body").append(d);
3774
+ }
3775
+
3776
+ retrieve(id) {
3777
+ let prom = defer();
3778
+ this.tsdk
3779
+ .request("https://pay.bea.com.lb/?tap_id=" + id, {}, true, "GET")
3780
+ .then((d) => {
3781
+ prom.resolve(d);
3782
+ })
3783
+ .catch((err) => {
3784
+ cl(err);
3785
+ });
3786
+
3787
+ return prom;
3788
+ }
3789
+
3790
+ onClose() { }
3791
+ }
3792
+ //end pay//
3793
+
3794
+ //class section//
3795
+ class Section {
3796
+ tsdk = null;
3797
+ _prom = defer();
3798
+ constructor(tsdk) {
3799
+ this.tsdk = tsdk;
3800
+ }
3801
+
3802
+ get() {
3803
+ var d = {
3804
+ fields: this.tsdk.fields.Section,
3805
+ limit: -1,
3806
+ locale: this.tsdk.l,
3807
+ media: "images",
3808
+ crops: "ax200,ax600,ax700,200x200,ax300",
3809
+ };
3810
+ this.tsdk.request("/Sections", d, true, "GET").then((r) => {
3811
+ cl("HEiii", r);
3812
+ if (r.results) {
3813
+ globals["sections"] = Object.assign(
3814
+ {},
3815
+ ...r.results.map((x) => ({ [x?.Section]: x }))
3816
+ );
3817
+ } else cl("Sections", r);
3818
+ this._prom.resolve(r);
3819
+ });
3820
+ return globals["sections"];
3821
+ }
3822
+ }
3823
+ //end section//
3824
+
3825
+ //class locale//
3826
+ class Locale {
3827
+ tsdk = null;
3828
+ _prom = defer();
3829
+ constructor(tsdk) {
3830
+ this.tsdk = tsdk;
3831
+ }
3832
+
3833
+ get() {
3834
+ var d = { fields: "Key," + this.tsdk.l, limit: -1 };
3835
+ this.tsdk.request("/_Locale", d, true, "GET").then((r) => {
3836
+ if (r.results) {
3837
+ globals["locale"] = Object.assign(
3838
+ {},
3839
+ ...r.results.map((x) => ({ [x?.Key]: x }))
3840
+ );
3841
+ } else cl("_Locale", r);
3842
+ this._prom.resolve(r);
3843
+ });
3844
+ return globals["locale"];
3845
+ }
3846
+ }
3847
+ //end locale//
3848
+
3849
+ //class products//
3850
+ class Products {
3851
+ tsdk = null;
3852
+ constructor(tsdk) {
3853
+ this.tsdk = tsdk;
3854
+ }
3855
+ get(data, options, async = true) {
3856
+ var d = data;
3857
+ if (options.hasOwnProperty("limit")) {
3858
+ d["limit"] = options.limit;
3859
+ }
3860
+
3861
+ if (options.hasOwnProperty("key")) {
3862
+ if (!d.hasOwnProperty("where")) d["where"] = {};
3863
+ d.where["Name"] = { startswith: options.key };
3864
+ }
3865
+
3866
+ if (options.hasOwnProperty("ids")) {
3867
+ if (!d.hasOwnProperty("where")) d["where"] = {};
3868
+ d.where["objectId"] = {
3869
+ in: [...new Set(options.ids.split(","))],
3870
+ };
3871
+ }
3872
+
3873
+ if (options.hasOwnProperty("page")) {
3874
+ d["limit"] = options.limits ?? "15";
3875
+ d["offset"] = (options.page - 1) * d["limit"];
3876
+ }
3877
+ return this.tsdk.request("/Products", d, async, "GET");
3878
+ }
3879
+ }
3880
+ //end products//
3881
+
3882
+ //class cart//
3883
+ class Cart {
3884
+ tsdk = null;
3885
+ cartData = {};
3886
+ constructor(tsdk) {
3887
+ this.tsdk = tsdk;
3888
+ try {
3889
+ if (getCookie("_cd") != undefined) {
3890
+ try {
3891
+ this.cartData = JSON.parse(getCookie("_cd"));
3892
+ } catch (e) {
3893
+
3894
+ }
3895
+ }
3896
+ } catch (e) {
3897
+ this.cartData = JSON.parse("{}");
3898
+ }
3899
+ }
3900
+ add(id, v, q) {
3901
+ var key = btoa(id + "::" + v);
3902
+ if (this.cartData.hasOwnProperty(key)) {
3903
+ this.cartData[key].Q += q;
3904
+ } else {
3905
+ this.cartData[key] = {
3906
+ P: id,
3907
+ Q: q,
3908
+ V: v,
3909
+ };
3910
+ }
3911
+ setCookie("_cd", JSON.stringify(this.cartData));
3912
+ }
3913
+ set(id, v, q) {
3914
+ var key = btoa(id + "::" + v);
3915
+ if (this.cartData.hasOwnProperty(key)) {
3916
+ this.cartData[key].Q = q;
3917
+ } else {
3918
+ this.cartData[key] = {
3919
+ P: id,
3920
+ Q: q,
3921
+ V: v,
3922
+ };
3923
+ }
3924
+ setCookie("_cd", JSON.stringify(this.cartData));
3925
+ }
3926
+ remove(id) {
3927
+ delete this.cartData[id];
3928
+ setCookie("_cd", JSON.stringify(this.cartData));
3929
+ }
3930
+ empty() {
3931
+ this.cartData = {};
3932
+ setCookie("_cd", JSON.stringify(this.cartData));
3933
+ }
3934
+ getCart() {
3935
+ return this.cartData;
3936
+ }
3937
+
3938
+ getProductCart(d) {
3939
+ var ids = "";
3940
+ $.each(this.cartData, function (key, value) {
3941
+ ids = ids + value.P + ",";
3942
+ });
3943
+ var req = this.tsdk.Products.get(d, { ids: ids });
3944
+ return req;
3945
+ }
3946
+ }
3947
+ //end cart//
3948
+
3949
+ //class auth//
3950
+ class Authorize {
3951
+ tsdk = null;
3952
+ constructor(tsdk) {
3953
+ this.tsdk = tsdk;
3954
+ }
3955
+
3956
+ login(data, options = true) {
3957
+ var prom = defer();
3958
+ this.tsdk.request("/Users", data, options, "GET").then((res) => {
3959
+ let req = res.results;
3960
+
3961
+ // if (!options) {
3962
+ globals["UserInfo"] = req[0];
3963
+ let x = window.btoa(JSON.stringify(globals.UserInfo));
3964
+ setCookie("U_USER", x);
3965
+ // } else {
3966
+ // req.then((r) => {
3967
+ // globals['UserInfo'] = r.results[0];
3968
+ // let x = window.btoa(JSON.stringify(globals.UserInfo))
3969
+ // setCookie("U_USER", x)
3970
+ // })
3971
+ // .catch((err) => {
3972
+ // cl(err)
3973
+ // })
3974
+ // }
3975
+ prom.resolve(res);
3976
+ });
3977
+ return prom;
3978
+ }
3979
+
3980
+ register(data, options = true) {
3981
+ var prom = defer();
3982
+ this.tsdk.request("/Users", data, options, "POST").then((res) => {
3983
+ let req = res.results;
3984
+ // if (!options) {
3985
+ data["objectId"] = req[0].objectId;
3986
+ globals["UserInfo"] = data;
3987
+ let x = window.btoa(JSON.stringify(globals.UserInfo));
3988
+ setCookie("U_USER", x);
3989
+ // } else {
3990
+ // req.then((r) => {
3991
+ // data['objectId'] = r.results[0].objectId
3992
+ // globals['UserInfo'] = data;
3993
+ // let x = window.btoa(JSON.stringify(globals.UserInfo))
3994
+ // setCookie("U_USER", x)
3995
+ // })
3996
+ // .catch((err) => {
3997
+ // cl(err)
3998
+ // })
3999
+ // }
4000
+ prom.resolve(res);
4001
+ });
4002
+ return prom;
4003
+ }
4004
+
4005
+ me() {
4006
+ var cookie = undefined;
4007
+ try {
4008
+ var cookie = JSON.parse(window.atob(getCookie("U_USER")));
4009
+ } catch (e) {
4010
+
4011
+ }
4012
+ return cookie;
4013
+ }
4014
+
4015
+ isLoggedIn() {
4016
+ var result = false;
4017
+ if (getCookie("U_USER") != undefined) result = true;
4018
+ return result;
4019
+ }
4020
+ }
4021
+ //end auth//
4022
+
4023
+ function generate() {
4024
+ let length = 10;
4025
+ const characters = "abcdefghijklmnopqrstuvwxyz1234567890";
4026
+ let result = "";
4027
+ const charactersLength = characters.length;
4028
+ for (let i = 0; i < length; i++) {
4029
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
4030
+ }
4031
+ return result;
4032
+ }
4033
+
4034
+ function getScrollBarWidth() {
4035
+ var $outer = $("<div>")
4036
+ .css({ visibility: "hidden", width: 100, overflow: "scroll" })
4037
+ .appendTo("body"),
4038
+ widthWithScroll = $("<div>")
4039
+ .css({ width: "100%" })
4040
+ .appendTo($outer)
4041
+ .outerWidth();
4042
+ $outer.remove();
4043
+ return (100 - widthWithScroll) * 2;
4044
+ }
4045
+ _scW = getScrollBarWidth();
4046
+
4047
+ function daysBetween(date_1, date_2) {
4048
+ let difference = date_1.getTime() - date_2.getTime();
4049
+ let TotalDays = Math.ceil(difference / (1000 * 3600 * 24));
4050
+ return TotalDays < 0 ? TotalDays * -1 : TotalDays;
4051
+ }
4052
+
4053
+ function notify(ti, tx, i, ty, al, rtl) {
4054
+ var notify =
4055
+ `<div class="notify {{Type}} nw sh20 h ` +
4056
+ (rtl ? "rtl" : "") +
4057
+ `">
4058
+ <div class="ov10 ra dash round3x bgb20 p2"></div>
4059
+ <div class="ov ra icon"><span class="cc mdi fs24 mdi-{{Icon}}"></span></div>
4060
+ <div class="ov la pointer" close-notify><span class="cc mdi fs18 mdi-close"></span></div>
4061
+ {{Title}}
4062
+ {{Text}}
4063
+ </div>`;
4064
+ if (!al) al = "topCenter";
4065
+ if (!ty) ty = "";
4066
+ if (!$("[notify]").length)
4067
+ $("body").append("<div notify class='" + al + "'></div>");
4068
+ else $("[notify]").attr("class", "").addClass(al);
4069
+ $("[notify]").prepend(
4070
+ notify
4071
+ .split("{{Title}}")
4072
+ .join(ti != "" ? "<h5>" + ti + "</h5>" : "")
4073
+ .split("{{Icon}}")
4074
+ .join(i)
4075
+ .split("{{Text}}")
4076
+ .join(tx)
4077
+ .split("{{Type}}")
4078
+ .join(ty)
4079
+ .split("{{Type}}")
4080
+ .join(ti)
4081
+ .split("{{Type}}")
4082
+ .join(ti)
4083
+ );
4084
+ $(".notify").fadeIn();
4085
+ setTimeout(function () {
4086
+ $("[close-notify]:last").click();
4087
+ }, 5000);
4088
+ }
4089
+
4090
+ function _isScrollable(el) {
4091
+ let o1 =
4092
+ el.css("overflow-y") == "scroll" ||
4093
+ (el.css("overflow-y") == "auto" && el[0].scrollHeight > el.height() + 15);
4094
+ let o2 =
4095
+ el.css("overflow-x") == "scroll" ||
4096
+ (el.css("overflow-x") == "auto" && el[0].scrollWidth > el.width() + 15);
4097
+ return o1 || o2;
4098
+ }
4099
+
4100
+ function _setPos(self, p, el) {
4101
+ var left = self.offset().left;
4102
+ var top = self.offset().top;
4103
+ if (p == "" || p == "bottom") {
4104
+ left += self.innerWidth() / 2;
4105
+ top += self.innerHeight();
4106
+ } else if (p == "left") {
4107
+ top += self.innerHeight() / 2;
4108
+ } else if (p == "top") {
4109
+ left += self.innerWidth() / 2;
4110
+ } else {
4111
+ left += self.innerWidth();
4112
+ top += self.innerHeight() / 2;
4113
+ }
4114
+ $("tip").css({ left: left, top: top, right: "unset", bottom: "unset" });
4115
+ if (
4116
+ top + 15 < el.offset().top ||
4117
+ top > el.offset().top + el.height() + 10 ||
4118
+ left + 15 < el.offset().left ||
4119
+ left > el.offset().left + el.width() + 10
4120
+ )
4121
+ $("tip").hide();
4122
+ else $("tip").show();
4123
+ }
4124
+
4125
+ String.prototype.rtrim = function (s) {
4126
+ if (s == undefined) s = "\\s";
4127
+ try {
4128
+ return this.replace(new RegExp("[" + s + "]+$"), "");
4129
+ } catch {
4130
+ return this.replace(new RegExp("[" + "\\" + s + "]+$"), "");
4131
+ }
4132
+ };
4133
+
4134
+ String.prototype.ltrim = function (s) {
4135
+ if (s == undefined) s = "\\s";
4136
+ try {
4137
+ return this.replace(new RegExp("^[" + s + "]+"), "");
4138
+ } catch {
4139
+ return this.replace(new RegExp("^[" + "\\" + s + "]+"), "");
4140
+ }
4141
+ };
4142
+
4143
+