zet-lib 1.4.18 → 1.4.20
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.
- package/lib/Form.js +24 -0
- package/lib/index.js +37 -36
- package/lib/moduleLib.js +403 -299
- package/lib/zAppRouter.js +161 -90
- package/lib/zRoute.js +17 -1
- package/package.json +2 -1
package/lib/moduleLib.js
CHANGED
|
@@ -1,115 +1,118 @@
|
|
|
1
|
-
const Util = require(
|
|
2
|
-
const newLine = Util.newLine
|
|
1
|
+
const Util = require("./Util");
|
|
2
|
+
const newLine = Util.newLine;
|
|
3
3
|
|
|
4
|
-
const m = {}
|
|
4
|
+
const m = {};
|
|
5
5
|
|
|
6
6
|
//module for ide code editor
|
|
7
7
|
m.ideCDN = function (req, res) {
|
|
8
|
-
let script =
|
|
9
|
-
let head =
|
|
10
|
-
let end =
|
|
11
|
-
end += `<script src="/modules/ace.js"></script>${Util.newLine}
|
|
8
|
+
let script = "";
|
|
9
|
+
let head = ``;
|
|
10
|
+
let end = ``;
|
|
11
|
+
end += `<script src="/modules/ace.js"></script>${Util.newLine}`;
|
|
12
12
|
|
|
13
13
|
return {
|
|
14
14
|
head: head,
|
|
15
15
|
end: end,
|
|
16
16
|
script: script,
|
|
17
|
-
}
|
|
18
|
-
}
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
19
|
|
|
20
20
|
m.ide = function (req, res, elem) {
|
|
21
|
-
let script =
|
|
22
|
-
let head =
|
|
23
|
-
let end =
|
|
24
|
-
elem = elem ||
|
|
21
|
+
let script = "";
|
|
22
|
+
let head = ``;
|
|
23
|
+
let end = ``;
|
|
24
|
+
elem = elem || "#ide_editor";
|
|
25
25
|
end += `<script> var editor_${elem} = ace.edit("${elem}");
|
|
26
26
|
editor_${elem}.getSession().setMode("ace/mode/ejs");
|
|
27
|
-
</script> ${Util.newLine}
|
|
27
|
+
</script> ${Util.newLine}`;
|
|
28
28
|
return {
|
|
29
29
|
head: head,
|
|
30
30
|
end: end,
|
|
31
31
|
script: script,
|
|
32
|
-
}
|
|
33
|
-
}
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
34
|
|
|
35
35
|
m.tags = function (req, res, elem) {
|
|
36
|
-
let script =
|
|
37
|
-
let head =
|
|
38
|
-
let end =
|
|
39
|
-
elem = elem ||
|
|
40
|
-
end += `<script type="module">import Tags from "/modules/tags.js";Tags.init("${elem}");</script
|
|
36
|
+
let script = "";
|
|
37
|
+
let head = ``;
|
|
38
|
+
let end = ``;
|
|
39
|
+
elem = elem || ".tags";
|
|
40
|
+
end += `<script type="module">import Tags from "/modules/tags.js";Tags.init("${elem}");</script>`;
|
|
41
41
|
return {
|
|
42
42
|
head: head,
|
|
43
43
|
end: end,
|
|
44
44
|
script: script,
|
|
45
|
-
}
|
|
46
|
-
}
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
47
|
//module for datepicker
|
|
48
48
|
m.datepicker = function (req, res, elem) {
|
|
49
|
-
let script =
|
|
50
|
-
let head =
|
|
51
|
-
let end =
|
|
52
|
-
elem = elem ||
|
|
49
|
+
let script = "";
|
|
50
|
+
let head = ``;
|
|
51
|
+
let end = ``;
|
|
52
|
+
elem = elem || ".datepicker";
|
|
53
53
|
/* head += '<link href="/css/bootstrap-datepicker.css" rel="stylesheet">';
|
|
54
54
|
end += '<script src="/js/bootstrap-datepicker.min.js"></script>';*/
|
|
55
|
-
head +=
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
head +=
|
|
56
|
+
'<link href="/modules/bootstrap-datepicker/bootstrap-datepicker.min.css" rel="stylesheet">';
|
|
57
|
+
end +=
|
|
58
|
+
'<script src="/modules/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>';
|
|
59
|
+
script = `$.fn.datepicker.defaults.format = "yyyy-mm-dd";$.fn.datepicker.defaults.todayHighlight = true;$("body").on("click", "${elem}", function(){$(this).datepicker();$(this).datepicker("show");});`;
|
|
58
60
|
|
|
59
61
|
return {
|
|
60
62
|
head: head,
|
|
61
63
|
end: end,
|
|
62
64
|
script: script,
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
+
};
|
|
66
|
+
};
|
|
65
67
|
|
|
66
68
|
//module for selectize
|
|
67
69
|
//https://selectize.dev
|
|
68
70
|
//https://github.com/selectize/selectize.js
|
|
69
71
|
m.selectize = function (req, res, elem) {
|
|
70
|
-
let script =
|
|
71
|
-
let head =
|
|
72
|
-
let end =
|
|
73
|
-
elem = elem ||
|
|
74
|
-
head +=
|
|
75
|
-
|
|
72
|
+
let script = "";
|
|
73
|
+
let head = ``;
|
|
74
|
+
let end = ``;
|
|
75
|
+
elem = elem || ".selectize";
|
|
76
|
+
head +=
|
|
77
|
+
'<link href="/modules/selectizejs/css/selectize.bootstrap5.css" rel="stylesheet">';
|
|
78
|
+
end += '<script src="/modules/selectizejs/js/selectize.min.js"></script>';
|
|
76
79
|
|
|
77
80
|
script += `$(() => {
|
|
78
81
|
$('${elem}').selectize({
|
|
79
82
|
sortField: 'text'
|
|
80
83
|
});
|
|
81
|
-
})
|
|
84
|
+
});`;
|
|
82
85
|
|
|
83
86
|
return {
|
|
84
87
|
head: head,
|
|
85
88
|
end: end,
|
|
86
89
|
script: script,
|
|
87
|
-
}
|
|
88
|
-
}
|
|
90
|
+
};
|
|
91
|
+
};
|
|
89
92
|
|
|
90
93
|
//module for dropzone
|
|
91
94
|
m.dropzone = function (req, res, elem) {
|
|
92
|
-
let script =
|
|
93
|
-
let head =
|
|
94
|
-
let end =
|
|
95
|
-
elem = elem ||
|
|
96
|
-
head += '<link href="/modules/dropzone/dropzone.css" rel="stylesheet">'
|
|
97
|
-
end += '<script src="/modules/dropzone/dropzone.min.js"></script>'
|
|
95
|
+
let script = "";
|
|
96
|
+
let head = ``;
|
|
97
|
+
let end = ``;
|
|
98
|
+
elem = elem || ".dropzone";
|
|
99
|
+
head += '<link href="/modules/dropzone/dropzone.css" rel="stylesheet">';
|
|
100
|
+
end += '<script src="/modules/dropzone/dropzone.min.js"></script>';
|
|
98
101
|
|
|
99
102
|
return {
|
|
100
103
|
head: head,
|
|
101
104
|
end: end,
|
|
102
105
|
script: script,
|
|
103
|
-
}
|
|
104
|
-
}
|
|
106
|
+
};
|
|
107
|
+
};
|
|
105
108
|
|
|
106
109
|
//module for dragdrop
|
|
107
110
|
m.dragdrop = function (req, res, elem) {
|
|
108
|
-
let script =
|
|
109
|
-
let head =
|
|
110
|
-
let end =
|
|
111
|
-
head += '<link href="/modules/drag/drag.css" rel="stylesheet">'
|
|
112
|
-
end += '<script src="/modules/drag/jquery-sortable.js"></script>'
|
|
111
|
+
let script = "";
|
|
112
|
+
let head = ``;
|
|
113
|
+
let end = ``;
|
|
114
|
+
head += '<link href="/modules/drag/drag.css" rel="stylesheet">';
|
|
115
|
+
end += '<script src="/modules/drag/jquery-sortable.js"></script>';
|
|
113
116
|
script += `$(function () {
|
|
114
117
|
$("ol.mydragable${elem}").sortable({
|
|
115
118
|
group: 'mydragable${elem}',
|
|
@@ -131,20 +134,20 @@ m.dragdrop = function (req, res, elem) {
|
|
|
131
134
|
});
|
|
132
135
|
});
|
|
133
136
|
|
|
134
|
-
|
|
137
|
+
`;
|
|
135
138
|
return {
|
|
136
139
|
head: head,
|
|
137
140
|
end: end,
|
|
138
141
|
script: script,
|
|
139
|
-
}
|
|
140
|
-
}
|
|
142
|
+
};
|
|
143
|
+
};
|
|
141
144
|
|
|
142
145
|
//module for google map
|
|
143
146
|
m.location = function (req, res, key) {
|
|
144
|
-
let script =
|
|
145
|
-
let head =
|
|
146
|
-
let end =
|
|
147
|
-
end += `<script src="https://maps.googleapis.com/maps/api/js?key=${process.env.GOOGLE_KEY}&callback=initAutocompleteZmap&libraries=places&language=ID" defer></script
|
|
147
|
+
let script = ``;
|
|
148
|
+
let head = ``;
|
|
149
|
+
let end = ``;
|
|
150
|
+
end += `<script src="https://maps.googleapis.com/maps/api/js?key=${process.env.GOOGLE_KEY}&callback=initAutocompleteZmap&libraries=places&language=ID" defer></script>`;
|
|
148
151
|
script += `let searchAddressMap;
|
|
149
152
|
let autocompleteMap;
|
|
150
153
|
function initAutocompleteZmap() {
|
|
@@ -229,221 +232,254 @@ m.location = function (req, res, key) {
|
|
|
229
232
|
}
|
|
230
233
|
);
|
|
231
234
|
}
|
|
232
|
-
}
|
|
235
|
+
}`;
|
|
233
236
|
return {
|
|
234
237
|
head: head,
|
|
235
238
|
end: end,
|
|
236
239
|
script: script,
|
|
237
|
-
}
|
|
238
|
-
}
|
|
240
|
+
};
|
|
241
|
+
};
|
|
239
242
|
|
|
240
243
|
//module for datepicker
|
|
241
244
|
m.datetimepicker = function (req, res, elem) {
|
|
242
|
-
let script =
|
|
243
|
-
let head =
|
|
244
|
-
let end =
|
|
245
|
-
elem = elem ||
|
|
246
|
-
head +=
|
|
247
|
-
|
|
248
|
-
end +=
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
245
|
+
let script = "";
|
|
246
|
+
let head = ``;
|
|
247
|
+
let end = ``;
|
|
248
|
+
elem = elem || ".datetimepicker";
|
|
249
|
+
head +=
|
|
250
|
+
'<link href="/css/bootstrap-datetimepicker.min.css" rel="stylesheet" />';
|
|
251
|
+
end +=
|
|
252
|
+
'<script type="text/javascript" src="/js/moment-with-locales.min.js" ></script>';
|
|
253
|
+
end +=
|
|
254
|
+
'<script type="text/javascript" src="/js/bootstrap-datetimepicker.min.js" ></script>';
|
|
255
|
+
script += `$(function () { $("${elem}").datetimepicker({format:'YYYY-MM-DD hh:mm:ss'}); });`;
|
|
256
|
+
script += `setTimeout(function () { $("body").click();},1000);`;
|
|
257
|
+
script += `$("body").on("click", function(){$("${elem}").datetimepicker({format:'YYYY-MM-DD hh:mm:ss'});});`;
|
|
252
258
|
|
|
253
259
|
return {
|
|
254
260
|
head: head,
|
|
255
261
|
end: end,
|
|
256
262
|
script: script,
|
|
257
|
-
}
|
|
258
|
-
}
|
|
263
|
+
};
|
|
264
|
+
};
|
|
259
265
|
|
|
260
266
|
//using ckeditor
|
|
261
267
|
m.ckeditor = function (req, res, elem) {
|
|
262
|
-
let script =
|
|
263
|
-
let head =
|
|
264
|
-
let end =
|
|
265
|
-
elem = elem ||
|
|
266
|
-
end +=
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
end +=
|
|
268
|
+
let script = "";
|
|
269
|
+
let head = ``;
|
|
270
|
+
let end = ``;
|
|
271
|
+
elem = elem || ".editor";
|
|
272
|
+
end +=
|
|
273
|
+
'<script src="/modules/ckeditor5-build-classic/ckeditor.js"></script>' +
|
|
274
|
+
newLine;
|
|
275
|
+
end += "<script>";
|
|
276
|
+
end +=
|
|
277
|
+
'ClassicEditor.create( document.querySelector( "' +
|
|
278
|
+
elem +
|
|
279
|
+
'" ) ).catch( error => {console.error( error );} );' +
|
|
280
|
+
newLine;
|
|
281
|
+
end += "</script>";
|
|
270
282
|
return {
|
|
271
283
|
head: head,
|
|
272
284
|
end: end,
|
|
273
285
|
script: script,
|
|
274
|
-
}
|
|
275
|
-
}
|
|
286
|
+
};
|
|
287
|
+
};
|
|
276
288
|
|
|
277
289
|
//using tinymce
|
|
278
290
|
m.tinymce = function (req, res, elem) {
|
|
279
|
-
let script =
|
|
280
|
-
let head =
|
|
281
|
-
let end =
|
|
282
|
-
elem = elem ||
|
|
283
|
-
end +=
|
|
291
|
+
let script = "";
|
|
292
|
+
let head = ``;
|
|
293
|
+
let end = ``;
|
|
294
|
+
elem = elem || ".tinymce";
|
|
295
|
+
end +=
|
|
296
|
+
'<script src="https://cdn.tiny.cloud/1/b7054u42l8lw67ch5oh9qutnvbyu8exzryg4edy0gg2snhtr/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>' +
|
|
297
|
+
newLine;
|
|
284
298
|
script += ` tinymce.init({
|
|
285
299
|
selector: '${elem}',
|
|
286
300
|
plugins: 'anchor autolink charmap codesample emoticons image link lists media searchreplace table visualblocks wordcount',
|
|
287
301
|
toolbar: 'undo redo | blocks fontfamily fontsize | bold italic underline strikethrough | link image media table | align lineheight | numlist bullist indent outdent | emoticons charmap | removeformat',
|
|
288
|
-
})
|
|
302
|
+
});`;
|
|
289
303
|
return {
|
|
290
304
|
head: head,
|
|
291
305
|
end: end,
|
|
292
306
|
script: script,
|
|
293
|
-
}
|
|
294
|
-
}
|
|
307
|
+
};
|
|
308
|
+
};
|
|
295
309
|
|
|
296
310
|
//using froala
|
|
297
311
|
m.froala = function (req, res, elem) {
|
|
298
|
-
let script =
|
|
299
|
-
let head =
|
|
300
|
-
let end =
|
|
301
|
-
elem = elem ||
|
|
302
|
-
|
|
303
|
-
head +=
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
312
|
+
let script = "";
|
|
313
|
+
let head = ``;
|
|
314
|
+
let end = ``;
|
|
315
|
+
elem = elem || ".editor";
|
|
316
|
+
|
|
317
|
+
head +=
|
|
318
|
+
'<link href="https://cdn.jsdelivr.net/npm/froala-editor@2.9.0/css/froala_editor.pkgd.min.css" rel="stylesheet" type="text/css" />';
|
|
319
|
+
head +=
|
|
320
|
+
'<link href="https://cdn.jsdelivr.net/npm/froala-editor@2.9.0/css/froala_style.min.css" rel="stylesheet" type="text/css" />';
|
|
321
|
+
end +=
|
|
322
|
+
'<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/froala-editor@2.9.0/js/froala_editor.pkgd.min.js"></script>';
|
|
323
|
+
script += `$(function() {$("${elem}").froalaEditor({height: 200})});`;
|
|
307
324
|
|
|
308
325
|
return {
|
|
309
326
|
head: head,
|
|
310
327
|
end: end,
|
|
311
328
|
script: script,
|
|
312
|
-
}
|
|
313
|
-
}
|
|
329
|
+
};
|
|
330
|
+
};
|
|
314
331
|
|
|
315
332
|
m.lexical = function (req, res, elem) {
|
|
316
|
-
let script =
|
|
317
|
-
let head =
|
|
318
|
-
let end =
|
|
319
|
-
elem = elem ||
|
|
320
|
-
head += `<link rel="stylesheet" href="/assets/main.143ecbc6.css"
|
|
321
|
-
end += `<script type="module" crossorigin src="/assets/main.3be493b7.js"></script
|
|
333
|
+
let script = "";
|
|
334
|
+
let head = ``;
|
|
335
|
+
let end = ``;
|
|
336
|
+
elem = elem || ".editor";
|
|
337
|
+
head += `<link rel="stylesheet" href="/assets/main.143ecbc6.css">`;
|
|
338
|
+
end += `<script type="module" crossorigin src="/assets/main.3be493b7.js"></script>`;
|
|
322
339
|
return {
|
|
323
340
|
head: head,
|
|
324
341
|
end: end,
|
|
325
342
|
script: script,
|
|
326
|
-
}
|
|
327
|
-
}
|
|
343
|
+
};
|
|
344
|
+
};
|
|
328
345
|
|
|
329
346
|
//Default editor is froala
|
|
330
|
-
m.editor = (req, res, elem =
|
|
331
|
-
elem = elem ||
|
|
347
|
+
m.editor = (req, res, elem = "") => {
|
|
348
|
+
elem = elem || ".editor";
|
|
332
349
|
//Default editor is froala
|
|
333
350
|
//return m.froala(req, res, elem);
|
|
334
351
|
//return m.tinymce(req, res, elem);
|
|
335
352
|
//return m.ckeditor(req, res, elem);
|
|
336
353
|
//return m.lexical(req,res,elem);
|
|
337
354
|
|
|
338
|
-
let script =
|
|
339
|
-
let head =
|
|
340
|
-
let end =
|
|
355
|
+
let script = "";
|
|
356
|
+
let head = ``;
|
|
357
|
+
let end = ``;
|
|
341
358
|
|
|
342
|
-
head +=
|
|
343
|
-
|
|
344
|
-
head +=
|
|
345
|
-
|
|
346
|
-
|
|
359
|
+
head +=
|
|
360
|
+
'<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.4.2/css/all.min.css" integrity="sha512-NicFTMUg/LwBeG8C7VG+gC4YiiRtQACl98QdkmfsLy37RzXdkaUAuPyVMND0olPP4Jn8M/ctesGSB2pgUBDRIw==" crossorigin="anonymous" referrerpolicy="no-referrer" />';
|
|
361
|
+
head +=
|
|
362
|
+
'<link href="https://cdn.jsdelivr.net/npm/froala-editor@2.9.0/css/froala_editor.pkgd.min.css" rel="stylesheet" type="text/css" />';
|
|
363
|
+
head +=
|
|
364
|
+
'<link href="https://cdn.jsdelivr.net/npm/froala-editor@2.9.0/css/froala_style.min.css" rel="stylesheet" type="text/css" />';
|
|
365
|
+
end +=
|
|
366
|
+
'<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/froala-editor@2.9.0/js/froala_editor.pkgd.min.js"></script>';
|
|
367
|
+
script += `$(function() {$("${elem}").froalaEditor({height: 200})});`;
|
|
347
368
|
|
|
348
369
|
return {
|
|
349
370
|
head: head,
|
|
350
371
|
end: end,
|
|
351
372
|
script: script,
|
|
352
|
-
}
|
|
353
|
-
}
|
|
373
|
+
};
|
|
374
|
+
};
|
|
354
375
|
|
|
355
376
|
m.switch = function (req, res, elem, array) {
|
|
356
|
-
elem = elem ||
|
|
357
|
-
let script =
|
|
358
|
-
let head =
|
|
359
|
-
let end =
|
|
360
|
-
|
|
361
|
-
head +=
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
377
|
+
elem = elem || ".switch";
|
|
378
|
+
let script = "";
|
|
379
|
+
let head = ``;
|
|
380
|
+
let end = ``;
|
|
381
|
+
|
|
382
|
+
head +=
|
|
383
|
+
'<link href="/modules/bootstrap-switch/bootstrap-switch.css" rel="stylesheet" type="text/css" />' +
|
|
384
|
+
newLine;
|
|
385
|
+
end +=
|
|
386
|
+
'<script type="text/javascript" src="/modules/bootstrap-switch/bootstrap-switch.js"></script>' +
|
|
387
|
+
newLine;
|
|
388
|
+
|
|
389
|
+
let labels = "";
|
|
365
390
|
if (Array.isArray(array)) {
|
|
366
|
-
labels = '{offText:"' + array[0] + '", onText:"' + array[1] + '"}'
|
|
391
|
+
labels = '{offText:"' + array[0] + '", onText:"' + array[1] + '"}';
|
|
367
392
|
}
|
|
368
|
-
script += '$("' + elem + '").bootstrapSwitch(' + labels +
|
|
393
|
+
script += '$("' + elem + '").bootstrapSwitch(' + labels + ");" + newLine;
|
|
369
394
|
return {
|
|
370
395
|
head: head,
|
|
371
396
|
end: end,
|
|
372
397
|
script: script,
|
|
373
|
-
}
|
|
374
|
-
}
|
|
398
|
+
};
|
|
399
|
+
};
|
|
375
400
|
|
|
376
401
|
m.switchOld = function (req, res, elem, array) {
|
|
377
|
-
let script =
|
|
378
|
-
let head =
|
|
379
|
-
let end =
|
|
380
|
-
elem = elem ||
|
|
381
|
-
head +=
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
402
|
+
let script = "";
|
|
403
|
+
let head = ``;
|
|
404
|
+
let end = ``;
|
|
405
|
+
elem = elem || ".switch";
|
|
406
|
+
head +=
|
|
407
|
+
'<link href="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/css/bootstrap4-toggle.min.css" rel="stylesheet">' +
|
|
408
|
+
newLine;
|
|
409
|
+
end +=
|
|
410
|
+
'<script src="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/js/bootstrap4-toggle.min.js"></script>' +
|
|
411
|
+
newLine;
|
|
412
|
+
|
|
413
|
+
let labels = "";
|
|
385
414
|
if (Array.isArray(array)) {
|
|
386
|
-
labels = '{off:"' + array[0] + '", on:"' + array[1] + '"}'
|
|
415
|
+
labels = '{off:"' + array[0] + '", on:"' + array[1] + '"}';
|
|
387
416
|
}
|
|
388
|
-
script += `$(function(){$('${elem}').bootstrapToggle(${labels});});${Util.newLine}
|
|
417
|
+
script += `$(function(){$('${elem}').bootstrapToggle(${labels});});${Util.newLine}`;
|
|
389
418
|
|
|
390
419
|
return {
|
|
391
420
|
head: head,
|
|
392
421
|
end: end,
|
|
393
422
|
script: script,
|
|
394
|
-
}
|
|
395
|
-
}
|
|
423
|
+
};
|
|
424
|
+
};
|
|
396
425
|
|
|
397
426
|
m.clockpicker = function (req, res, elem) {
|
|
398
|
-
let script =
|
|
399
|
-
let head =
|
|
400
|
-
let end =
|
|
401
|
-
elem = elem ||
|
|
402
|
-
head +=
|
|
403
|
-
|
|
404
|
-
|
|
427
|
+
let script = "";
|
|
428
|
+
let head = ``;
|
|
429
|
+
let end = ``;
|
|
430
|
+
elem = elem || ".clockpicker";
|
|
431
|
+
head +=
|
|
432
|
+
'<link href="/modules/jquery-clockpicker.min.css" rel="stylesheet" type="text/css" />' +
|
|
433
|
+
newLine;
|
|
434
|
+
end +=
|
|
435
|
+
'<script type="text/javascript" src="/modules/bootstrap-clockpicker.min.js"></script>' +
|
|
436
|
+
newLine;
|
|
437
|
+
script += `$("body").on("click", "${elem}", function(){$(this).clockpicker({donetext: "Done"});});`;
|
|
405
438
|
//end += '$("' + elem + '").clockpicker({donetext: "Done"});' + newLine;
|
|
406
439
|
return {
|
|
407
440
|
head: head,
|
|
408
441
|
end: end,
|
|
409
442
|
script: script,
|
|
410
|
-
}
|
|
411
|
-
}
|
|
443
|
+
};
|
|
444
|
+
};
|
|
412
445
|
|
|
413
446
|
m.number = (req, res, elem) => {
|
|
414
|
-
let script =
|
|
415
|
-
let head =
|
|
416
|
-
let end =
|
|
417
|
-
elem = elem ||
|
|
447
|
+
let script = "";
|
|
448
|
+
let head = ``;
|
|
449
|
+
let end = ``;
|
|
450
|
+
elem = elem || ".number";
|
|
418
451
|
|
|
419
|
-
end +=
|
|
420
|
-
|
|
421
|
-
script +=
|
|
422
|
-
script +=
|
|
452
|
+
end +=
|
|
453
|
+
'<script type="text/javascript" src="/js/jquery-currency.js"></script>';
|
|
454
|
+
script += `$(function () { $(".number").formatCurrencyLive({symbol:"",roundToDecimalPlace :0,digitGroupSymbol :"."}); });`;
|
|
455
|
+
script += `setTimeout(function () { $("body").click();},1000);`;
|
|
456
|
+
script += `$("body").on("click", function(){$(".number").formatCurrencyLive({symbol:"",roundToDecimalPlace :0,digitGroupSymbol :"."});});`;
|
|
423
457
|
|
|
424
458
|
return {
|
|
425
459
|
head: head,
|
|
426
460
|
end: end,
|
|
427
461
|
script: script,
|
|
428
|
-
}
|
|
429
|
-
}
|
|
462
|
+
};
|
|
463
|
+
};
|
|
430
464
|
|
|
431
465
|
m.typeahead = (req, res, table, elem) => {
|
|
432
|
-
let script =
|
|
433
|
-
let head =
|
|
434
|
-
let end =
|
|
435
|
-
elem = elem ||
|
|
436
|
-
end +=
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
let
|
|
466
|
+
let script = "";
|
|
467
|
+
let head = ``;
|
|
468
|
+
let end = ``;
|
|
469
|
+
elem = elem || ".typeahead";
|
|
470
|
+
end +=
|
|
471
|
+
'<script type="text/javascript" src="/modules/typeahead/typeahead.js"></script>' +
|
|
472
|
+
newLine;
|
|
473
|
+
|
|
474
|
+
let elemData = elem.replace(".", "").replace("#", "");
|
|
475
|
+
let element = elem.replace("Typeahead", "");
|
|
476
|
+
let key = element.replace("#", "").replace(".", "");
|
|
441
477
|
// var script using existing cache
|
|
442
478
|
script += `$("body").on("click", "${element}Clear", function(){
|
|
443
479
|
$("${elem}").val("");
|
|
444
480
|
$("${element}").val("");
|
|
445
481
|
$("${element}").change();
|
|
446
|
-
});${Util.newLine}
|
|
482
|
+
});${Util.newLine}`;
|
|
447
483
|
script += `$("${elem}").typeahead({highlight:true,minLength:2,source: function (query, asyncprocess) {
|
|
448
484
|
jQuery.ajax({
|
|
449
485
|
url : "/ztypeahead/${table}/${key}",
|
|
@@ -464,31 +500,33 @@ m.typeahead = (req, res, table, elem) => {
|
|
|
464
500
|
$("${element}").change();
|
|
465
501
|
return item;
|
|
466
502
|
}
|
|
467
|
-
}); ${Util.newLine}
|
|
503
|
+
}); ${Util.newLine}`;
|
|
468
504
|
return {
|
|
469
505
|
head: head,
|
|
470
506
|
end: end,
|
|
471
507
|
script: script,
|
|
472
|
-
}
|
|
473
|
-
}
|
|
508
|
+
};
|
|
509
|
+
};
|
|
474
510
|
|
|
475
511
|
m.typeaheadFile = (req, res, elem, data) => {
|
|
476
|
-
let script =
|
|
477
|
-
let head =
|
|
478
|
-
let end =
|
|
479
|
-
data = data || []
|
|
480
|
-
elem = elem ||
|
|
481
|
-
end +=
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
let
|
|
512
|
+
let script = "";
|
|
513
|
+
let head = ``;
|
|
514
|
+
let end = ``;
|
|
515
|
+
data = data || [];
|
|
516
|
+
elem = elem || ".typeahead";
|
|
517
|
+
end +=
|
|
518
|
+
'<script type="text/javascript" src="/modules/typeahead/typeahead.js"></script>' +
|
|
519
|
+
newLine;
|
|
520
|
+
|
|
521
|
+
let elemData = elem.replace(".", "");
|
|
522
|
+
elemData = elemData.replace("#", "");
|
|
523
|
+
let element = elem.replace("Typeahead", "");
|
|
486
524
|
// var script using existing cache
|
|
487
525
|
script += `$("body").on("click", "${element}Clear", function(){
|
|
488
526
|
$("${elem}").val("");
|
|
489
527
|
$("${element}").val("");
|
|
490
528
|
$("${element}").change();
|
|
491
|
-
});${Util.newLine}
|
|
529
|
+
});${Util.newLine}`;
|
|
492
530
|
script += `$("${elem}").typeahead({highlight: true,minLength:2,source:${elemData}Data, items: 50, displayText: function (item) {
|
|
493
531
|
return item.zname.toString();
|
|
494
532
|
},
|
|
@@ -497,35 +535,83 @@ m.typeaheadFile = (req, res, elem, data) => {
|
|
|
497
535
|
$("${element}").change();
|
|
498
536
|
return item;
|
|
499
537
|
}
|
|
500
|
-
}); ${Util.newLine}
|
|
538
|
+
}); ${Util.newLine}`;
|
|
501
539
|
return {
|
|
502
540
|
head: head,
|
|
503
541
|
end: end,
|
|
504
542
|
script: script,
|
|
505
|
-
}
|
|
506
|
-
}
|
|
543
|
+
};
|
|
544
|
+
};
|
|
507
545
|
|
|
508
546
|
m.custom = (req, res, script, css, src) => {
|
|
509
|
-
src = src ||
|
|
510
|
-
css = css ||
|
|
511
|
-
let head = res.locals.moduleHead
|
|
512
|
-
let end = res.locals.moduleEnd
|
|
547
|
+
src = src || "";
|
|
548
|
+
css = css || "";
|
|
549
|
+
let head = res.locals.moduleHead;
|
|
550
|
+
let end = res.locals.moduleEnd;
|
|
513
551
|
if (script) {
|
|
514
|
-
end +=
|
|
515
|
-
end += script + newLine
|
|
516
|
-
end +=
|
|
552
|
+
end += "<script>" + newLine;
|
|
553
|
+
end += script + newLine;
|
|
554
|
+
end += "</script>" + newLine;
|
|
517
555
|
}
|
|
518
556
|
if (css) {
|
|
519
|
-
head += css
|
|
557
|
+
head += css;
|
|
520
558
|
}
|
|
521
559
|
if (src) {
|
|
522
|
-
end += `<script src="${src}"> ${newLine}
|
|
523
|
-
}
|
|
524
|
-
res.locals.moduleHead = head
|
|
525
|
-
res.locals.moduleEnd = end
|
|
526
|
-
}
|
|
560
|
+
end += `<script src="${src}"> ${newLine}`;
|
|
561
|
+
}
|
|
562
|
+
res.locals.moduleHead = head;
|
|
563
|
+
res.locals.moduleEnd = end;
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
//dropbox view
|
|
567
|
+
m.dropboxview = (req, res) => {
|
|
568
|
+
let script = ``;
|
|
569
|
+
let head = ``;
|
|
570
|
+
let end = ``;
|
|
571
|
+
script +=
|
|
572
|
+
`$(()=>{
|
|
573
|
+
$(".zdropbox-view").each(function (index, item) {
|
|
574
|
+
let dropboxLength = $(".zdropbox-view").length || 0;
|
|
575
|
+
ajaxPost('/zdropbox-file/' + index, {
|
|
576
|
+
fileName: $(this).attr('data-name'),
|
|
577
|
+
table: $(this).attr('data-table'),
|
|
578
|
+
field: $(this).attr('data-field'),
|
|
579
|
+
}, function (result) {
|
|
580
|
+
$(item).attr("src", result.link)
|
|
581
|
+
$(item).attr('data-link', result.link);
|
|
582
|
+
if (+result.index == (+dropboxLength - 1)) {
|
|
583
|
+
setTimeout(() => modaldropbox(),1000);
|
|
584
|
+
}
|
|
585
|
+
})
|
|
586
|
+
})
|
|
587
|
+
})
|
|
588
|
+
|
|
589
|
+
function modaldropbox() {
|
|
590
|
+
$(".zdropbox-view").each(function () {
|
|
591
|
+
let ext = $(this).attr('data-ext');
|
|
592
|
+
if (ext == "gif" || ext == "png" || ext == "jpeg" || ext == "jpg" || ext == "bmp" || ext == "webp" || ext == "jiff" || ext == "svg" || ext == "avif") {
|
|
593
|
+
$(this).on("click", function () {
|
|
594
|
+
$(".zimage-modal").attr('src', $(this).attr('data-link')).attr('data-name', $(this).attr('data-name'));
|
|
595
|
+
$("#zmodal-image").modal("show");
|
|
596
|
+
})
|
|
597
|
+
} else {
|
|
598
|
+
let file = nonImagesTypeObject[ext] || 'file.png';
|
|
599
|
+
$(this).attr("src", "/img/" + file);
|
|
600
|
+
$(this).on("click", function () {
|
|
601
|
+
window.open($(this).attr('data-link'), '_blank');
|
|
602
|
+
})
|
|
603
|
+
}
|
|
604
|
+
})
|
|
605
|
+
}` + newLine;
|
|
527
606
|
|
|
528
|
-
|
|
607
|
+
return {
|
|
608
|
+
head: head,
|
|
609
|
+
end: end,
|
|
610
|
+
script: script,
|
|
611
|
+
};
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
m.script = (req, res, table) => {};
|
|
529
615
|
|
|
530
616
|
/*
|
|
531
617
|
add scrip code in the body html
|
|
@@ -534,128 +620,146 @@ m.script = (req, res, table) => {}
|
|
|
534
620
|
|
|
535
621
|
type : script / css
|
|
536
622
|
*/
|
|
537
|
-
m.addScript = (req, res, contentScript, at =
|
|
623
|
+
m.addScript = (req, res, contentScript, at = "end", type = "script") => {
|
|
538
624
|
if (contentScript) {
|
|
539
|
-
let generateId =
|
|
540
|
-
let tagOpen =
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
content
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
625
|
+
let generateId = "app_" + Util.generate(6);
|
|
626
|
+
let tagOpen =
|
|
627
|
+
type == "script"
|
|
628
|
+
? `<script id="${generateId}">`
|
|
629
|
+
: '<style type="text/css">';
|
|
630
|
+
let tagClose = type == "script" ? "</script>" : "</style>";
|
|
631
|
+
let content = at == "end" ? res.locals.moduleEnd : res.locals.moduleHead;
|
|
632
|
+
content += tagOpen + newLine;
|
|
633
|
+
content += contentScript + newLine;
|
|
634
|
+
content += tagClose + newLine;
|
|
635
|
+
|
|
636
|
+
if (at == "end") {
|
|
637
|
+
res.locals.moduleEnd = content;
|
|
638
|
+
} else res.locals.moduleHead = content;
|
|
639
|
+
}
|
|
640
|
+
};
|
|
552
641
|
|
|
553
642
|
m.addModule = (req, res, content, isModuleHead = false) => {
|
|
554
|
-
let moduleContent = isModuleHead
|
|
555
|
-
|
|
643
|
+
let moduleContent = isModuleHead
|
|
644
|
+
? res.locals.moduleHead
|
|
645
|
+
: res.locals.moduleEnd;
|
|
646
|
+
moduleContent += content;
|
|
556
647
|
if (isModuleHead) {
|
|
557
|
-
res.locals.moduleHead = moduleContent
|
|
648
|
+
res.locals.moduleHead = moduleContent;
|
|
558
649
|
} else {
|
|
559
|
-
res.locals.moduleEnd = moduleContent
|
|
650
|
+
res.locals.moduleEnd = moduleContent;
|
|
560
651
|
}
|
|
561
|
-
}
|
|
652
|
+
};
|
|
562
653
|
|
|
563
654
|
m.highchart = async (req, res, obj) => {
|
|
564
|
-
obj = obj || {}
|
|
565
|
-
let head = res.locals.moduleHead
|
|
566
|
-
let end = res.locals.moduleEnd
|
|
567
|
-
if (end.indexOf(
|
|
568
|
-
end +=
|
|
655
|
+
obj = obj || {};
|
|
656
|
+
let head = res.locals.moduleHead;
|
|
657
|
+
let end = res.locals.moduleEnd;
|
|
658
|
+
if (end.indexOf("highcharts") < 0) {
|
|
659
|
+
end +=
|
|
660
|
+
'<script src="https://code.highcharts.com/highcharts.js"></script>' +
|
|
661
|
+
newLine;
|
|
569
662
|
}
|
|
570
663
|
|
|
571
664
|
if (!Util.isEmptyObject(obj)) {
|
|
572
|
-
const highcharts = require(
|
|
573
|
-
end +=
|
|
574
|
-
end += await highcharts.build(obj)
|
|
575
|
-
end +=
|
|
665
|
+
const highcharts = require("./highcharts");
|
|
666
|
+
end += "<script>" + newLine;
|
|
667
|
+
end += await highcharts.build(obj);
|
|
668
|
+
end += "</script>" + newLine;
|
|
576
669
|
}
|
|
577
670
|
|
|
578
|
-
res.locals.moduleHead = head
|
|
579
|
-
res.locals.moduleEnd = end
|
|
580
|
-
}
|
|
671
|
+
res.locals.moduleHead = head;
|
|
672
|
+
res.locals.moduleEnd = end;
|
|
673
|
+
};
|
|
581
674
|
|
|
582
675
|
//build auto js and css based on function type
|
|
583
676
|
m.build = (req, res, objData) => {
|
|
584
|
-
let head = res.locals.moduleHead
|
|
585
|
-
let end = res.locals.moduleEnd
|
|
677
|
+
let head = res.locals.moduleHead;
|
|
678
|
+
let end = res.locals.moduleEnd;
|
|
586
679
|
|
|
587
|
-
head += objData.head
|
|
588
|
-
end += objData.end
|
|
680
|
+
head += objData.head;
|
|
681
|
+
end += objData.end;
|
|
589
682
|
if (objData.script) {
|
|
590
|
-
end += `<script>${objData.script}</script
|
|
683
|
+
end += `<script>${objData.script}</script>`;
|
|
591
684
|
}
|
|
592
|
-
res.locals.moduleHead = head
|
|
593
|
-
res.locals.moduleEnd = end
|
|
594
|
-
}
|
|
685
|
+
res.locals.moduleHead = head;
|
|
686
|
+
res.locals.moduleEnd = end;
|
|
687
|
+
};
|
|
595
688
|
|
|
596
689
|
m.tableForm = (req, res, name, table) => {
|
|
597
|
-
let head = res.locals.moduleHead
|
|
598
|
-
let end = res.locals.moduleEnd
|
|
599
|
-
res.locals.moduleHead = head
|
|
600
|
-
res.locals.moduleEnd = end
|
|
601
|
-
}
|
|
690
|
+
let head = res.locals.moduleHead;
|
|
691
|
+
let end = res.locals.moduleEnd;
|
|
692
|
+
res.locals.moduleHead = head;
|
|
693
|
+
res.locals.moduleEnd = end;
|
|
694
|
+
};
|
|
602
695
|
|
|
603
696
|
m.selectYear = (req, res, elem, val, startYear, endYear) => {
|
|
604
|
-
let dt = new Date()
|
|
605
|
-
endYear = endYear || dt.getFullYear()
|
|
606
|
-
val = val ||
|
|
607
|
-
var options =
|
|
697
|
+
let dt = new Date();
|
|
698
|
+
endYear = endYear || dt.getFullYear();
|
|
699
|
+
val = val || "";
|
|
700
|
+
var options = "";
|
|
608
701
|
for (var i = endYear; i >= startYear; i--) {
|
|
609
|
-
var selected = i == val ?
|
|
610
|
-
options += `<option value="${i}" ${selected}>${i}</option
|
|
702
|
+
var selected = i == val ? " selected " : "";
|
|
703
|
+
options += `<option value="${i}" ${selected}>${i}</option>`;
|
|
611
704
|
}
|
|
612
|
-
let end = res.locals.moduleEnd
|
|
613
|
-
end +=
|
|
614
|
-
end += `$("${elem}").html('${options}')
|
|
615
|
-
end +=
|
|
616
|
-
res.locals.moduleEnd = end
|
|
617
|
-
}
|
|
705
|
+
let end = res.locals.moduleEnd;
|
|
706
|
+
end += "<script>" + newLine;
|
|
707
|
+
end += `$("${elem}").html('${options}')`;
|
|
708
|
+
end += "</script>" + newLine;
|
|
709
|
+
res.locals.moduleEnd = end;
|
|
710
|
+
};
|
|
618
711
|
|
|
619
712
|
//https://highlightjs.org/usage/
|
|
620
713
|
m.highlight = (req, res, elem) => {
|
|
621
|
-
elem = elem ||
|
|
622
|
-
let head = res.locals.moduleHead
|
|
623
|
-
let end = res.locals.moduleEnd
|
|
624
|
-
if (head.indexOf(
|
|
625
|
-
head +=
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
714
|
+
elem = elem || ".codes";
|
|
715
|
+
let head = res.locals.moduleHead;
|
|
716
|
+
let end = res.locals.moduleEnd;
|
|
717
|
+
if (head.indexOf("highlight") < 0) {
|
|
718
|
+
head +=
|
|
719
|
+
'<link rel="stylesheet" href="/modules/highlight/default.min.css"> ' +
|
|
720
|
+
newLine;
|
|
721
|
+
end +=
|
|
722
|
+
'<script src="/modules/highlight/highlight.min.js"></script>' + newLine;
|
|
723
|
+
}
|
|
724
|
+
end +=
|
|
725
|
+
'<script>$(function(){ document.querySelectorAll("' +
|
|
726
|
+
elem +
|
|
727
|
+
'").forEach((block) => {hljs.highlightBlock(block);}); })</script>' +
|
|
728
|
+
newLine;
|
|
729
|
+
res.locals.moduleHead = head;
|
|
730
|
+
res.locals.moduleEnd = end;
|
|
731
|
+
};
|
|
632
732
|
|
|
633
733
|
//https://developer.snapappointments.com/bootstrap-select/
|
|
634
734
|
m.selectpicker = function (req, res, elem) {
|
|
635
|
-
elem = elem ||
|
|
636
|
-
let head = res.locals.moduleHead
|
|
637
|
-
let end = res.locals.moduleEnd
|
|
638
|
-
if (head.indexOf(
|
|
639
|
-
head +=
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
|
|
735
|
+
elem = elem || ".selectpicker";
|
|
736
|
+
let head = res.locals.moduleHead;
|
|
737
|
+
let end = res.locals.moduleEnd;
|
|
738
|
+
if (head.indexOf("bootstrap-select") < 0) {
|
|
739
|
+
head +=
|
|
740
|
+
'<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/css/bootstrap-select.min.css">' +
|
|
741
|
+
newLine;
|
|
742
|
+
end +=
|
|
743
|
+
'<script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/js/bootstrap-select.min.js"></script>' +
|
|
744
|
+
newLine;
|
|
745
|
+
end += `<script>$(function () {$('${elem}').selectpicker();});</script>${newLine}`;
|
|
746
|
+
}
|
|
747
|
+
res.locals.moduleHead = head;
|
|
748
|
+
res.locals.moduleEnd = end;
|
|
749
|
+
};
|
|
750
|
+
|
|
751
|
+
m.slugHTML = (req, res, content, at = "end") => {
|
|
648
752
|
if (content) {
|
|
649
|
-
let head = res.locals.moduleHead
|
|
650
|
-
let end = res.locals.moduleEnd
|
|
651
|
-
if (at ==
|
|
652
|
-
end += content
|
|
653
|
-
res.locals.moduleEnd = end
|
|
753
|
+
let head = res.locals.moduleHead;
|
|
754
|
+
let end = res.locals.moduleEnd;
|
|
755
|
+
if (at == "end") {
|
|
756
|
+
end += content;
|
|
757
|
+
res.locals.moduleEnd = end;
|
|
654
758
|
} else {
|
|
655
|
-
head += content
|
|
656
|
-
res.locals.moduleHead = head
|
|
759
|
+
head += content;
|
|
760
|
+
res.locals.moduleHead = head;
|
|
657
761
|
}
|
|
658
762
|
}
|
|
659
|
-
}
|
|
763
|
+
};
|
|
660
764
|
|
|
661
|
-
module.exports = m
|
|
765
|
+
module.exports = m;
|