zet-lib 1.0.0
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/LICENSE +21 -0
- package/README.md +4 -0
- package/lib/Form.js +717 -0
- package/lib/Mail.js +70 -0
- package/lib/Modal.js +95 -0
- package/lib/UI.js +15 -0
- package/lib/Util.js +1242 -0
- package/lib/access.js +6 -0
- package/lib/cache.js +4 -0
- package/lib/connection.js +304 -0
- package/lib/debug.js +22 -0
- package/lib/index.js +29 -0
- package/lib/io.js +45 -0
- package/lib/languages/lang_en.js +115 -0
- package/lib/languages/lang_fr.js +114 -0
- package/lib/languages/lang_id.js +116 -0
- package/lib/languages/lang_jp.js +114 -0
- package/lib/menuGenerator.js +236 -0
- package/lib/moduleLib.js +427 -0
- package/lib/tableForm.js +10 -0
- package/lib/zCache.js +326 -0
- package/lib/zComponent.js +27 -0
- package/lib/zFn.js +59 -0
- package/lib/zFunction.js +20 -0
- package/lib/zMenuCollections.js +62 -0
- package/lib/zReport.js +930 -0
- package/lib/zRole.js +140 -0
- package/lib/zRoute.js +3226 -0
- package/lib/zTester.js +93 -0
- package/lib/zapp.js +79 -0
- package/lib/zdataTable.js +130 -0
- package/package.json +50 -0
package/lib/moduleLib.js
ADDED
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
const Util = require('./Util');
|
|
2
|
+
const newLine = Util.newLine;
|
|
3
|
+
|
|
4
|
+
const m = {};
|
|
5
|
+
|
|
6
|
+
//module for ide code editor
|
|
7
|
+
m.ideCDN = function (req,res) {
|
|
8
|
+
let script = '';
|
|
9
|
+
let head = ``;
|
|
10
|
+
let end = ``;
|
|
11
|
+
end += `<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.15.0/ace.js"></script>${Util.newLine}`;
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
head : head,
|
|
15
|
+
end : end,
|
|
16
|
+
script: script
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
m.ide = function (req,res,elem) {
|
|
21
|
+
let script = '';
|
|
22
|
+
let head = ``;
|
|
23
|
+
let end = ``;
|
|
24
|
+
elem = elem || "#ide_editor";
|
|
25
|
+
end += `<script> var editor_${elem} = ace.edit("${elem}");
|
|
26
|
+
editor_${elem}.getSession().setMode("ace/mode/ejs");
|
|
27
|
+
</script> ${Util.newLine}`;
|
|
28
|
+
return {
|
|
29
|
+
head : head,
|
|
30
|
+
end : end,
|
|
31
|
+
script: script
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
m.tags = function(req,res,elem) {
|
|
36
|
+
let script = '';
|
|
37
|
+
let head = ``;
|
|
38
|
+
let end = ``;
|
|
39
|
+
elem = elem || ".tags";
|
|
40
|
+
end += `<script type="module">import Tags from "https://cdn.jsdelivr.net/gh/lekoala/bootstrap5-tags@master/tags.js";Tags.init("${elem}");</script>`;
|
|
41
|
+
return {
|
|
42
|
+
head : head,
|
|
43
|
+
end : end,
|
|
44
|
+
script: script
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
//module for datepicker
|
|
48
|
+
m.datepicker = function (req, res, elem) {
|
|
49
|
+
let script = '';
|
|
50
|
+
let head = ``;
|
|
51
|
+
let end = ``;
|
|
52
|
+
elem = elem || ".datepicker";
|
|
53
|
+
/* head += '<link href="/css/bootstrap-datepicker.css" rel="stylesheet">';
|
|
54
|
+
end += '<script src="/js/bootstrap-datepicker.min.js"></script>';*/
|
|
55
|
+
head += '<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" rel="stylesheet">';
|
|
56
|
+
end += '<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>';
|
|
57
|
+
script = `$.fn.datepicker.defaults.format = "yyyy-mm-dd";$.fn.datepicker.defaults.todayHighlight = true;$("body").on("click", "${elem}", function(){$(this).datepicker();$(this).datepicker("show");});`;
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
head : head,
|
|
61
|
+
end : end,
|
|
62
|
+
script: script
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
//module for datepicker
|
|
67
|
+
m.datetimepicker = function (req, res, elem) {
|
|
68
|
+
let script = '';
|
|
69
|
+
let head = ``;
|
|
70
|
+
let end = ``;
|
|
71
|
+
elem = elem || ".datetimepicker";
|
|
72
|
+
head += '<link href="/css/bootstrap-datetimepicker.min.css" rel="stylesheet" />';
|
|
73
|
+
end += '<script type="text/javascript" src="/js/moment-with-locales.min.js" ></script>';
|
|
74
|
+
end += '<script type="text/javascript" src="/js/bootstrap-datetimepicker.min.js" ></script>';
|
|
75
|
+
script += `$(function () { $("${elem}").datetimepicker({format:'YYYY-MM-DD hh:mm:ss'}); });`;
|
|
76
|
+
script += `setTimeout(function () { $("body").click();},1000);`;
|
|
77
|
+
script += `$("body").on("click", function(){$("${elem}").datetimepicker({format:'YYYY-MM-DD hh:mm:ss'});});`;
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
head : head,
|
|
82
|
+
end : end,
|
|
83
|
+
script: script
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
//using ckeditor
|
|
89
|
+
m.ckeditor = function (req, res, elem) {
|
|
90
|
+
let script = '';
|
|
91
|
+
let head = ``;
|
|
92
|
+
let end = ``;
|
|
93
|
+
elem = elem || ".editor";
|
|
94
|
+
end += '<script src="/modules/ckeditor5-build-classic/ckeditor.js"></script>' + newLine;
|
|
95
|
+
end += '<script>';
|
|
96
|
+
end += 'ClassicEditor.create( document.querySelector( "' + elem + '" ) ).catch( error => {console.error( error );} );' + newLine;
|
|
97
|
+
end += '</script>';
|
|
98
|
+
return {
|
|
99
|
+
head : head,
|
|
100
|
+
end : end,
|
|
101
|
+
script: script
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
//using tinymce
|
|
107
|
+
m.tinymce = function (req, res, elem) {
|
|
108
|
+
let script = '';
|
|
109
|
+
let head = ``;
|
|
110
|
+
let end = ``;
|
|
111
|
+
elem = elem || ".tinymce";
|
|
112
|
+
end += '<script src="https://cdn.tiny.cloud/1/b7054u42l8lw67ch5oh9qutnvbyu8exzryg4edy0gg2snhtr/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>' + newLine;
|
|
113
|
+
script += ` tinymce.init({
|
|
114
|
+
selector: '${elem}',
|
|
115
|
+
plugins: 'anchor autolink charmap codesample emoticons image link lists media searchreplace table visualblocks wordcount',
|
|
116
|
+
toolbar: 'undo redo | blocks fontfamily fontsize | bold italic underline strikethrough | link image media table | align lineheight | numlist bullist indent outdent | emoticons charmap | removeformat',
|
|
117
|
+
});`;
|
|
118
|
+
return {
|
|
119
|
+
head : head,
|
|
120
|
+
end : end,
|
|
121
|
+
script: script
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
//using froala
|
|
126
|
+
m.froala = function (req, res, elem) {
|
|
127
|
+
let script = '';
|
|
128
|
+
let head = ``;
|
|
129
|
+
let end = ``;
|
|
130
|
+
elem = elem || ".editor";
|
|
131
|
+
|
|
132
|
+
head += '<link href="https://cdn.jsdelivr.net/npm/froala-editor@2.9.0/css/froala_editor.pkgd.min.css" rel="stylesheet" type="text/css" />';
|
|
133
|
+
head += '<link href="https://cdn.jsdelivr.net/npm/froala-editor@2.9.0/css/froala_style.min.css" rel="stylesheet" type="text/css" />';
|
|
134
|
+
end += '<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/froala-editor@2.9.0/js/froala_editor.pkgd.min.js"></script>';
|
|
135
|
+
script += `$(function() {$("${elem}").froalaEditor({height: 200})});`;
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
head : head,
|
|
139
|
+
end : end,
|
|
140
|
+
script: script
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
m.lexical = function(req,res,elem) {
|
|
145
|
+
let script = '';
|
|
146
|
+
let head = ``;
|
|
147
|
+
let end = ``;
|
|
148
|
+
elem = elem || ".editor";
|
|
149
|
+
head += `<link rel="stylesheet" href="/assets/main.143ecbc6.css">`;
|
|
150
|
+
head += `<script type="module" crossorigin src="/assets/main.3be493b7.js"></script>`;
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
head : head,
|
|
154
|
+
end : end,
|
|
155
|
+
script: script
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
//Default editor is froala
|
|
162
|
+
m.editor = (req, res, elem = "") => {
|
|
163
|
+
elem = elem || ".editor";
|
|
164
|
+
//Default editor is froala
|
|
165
|
+
//return m.froala(req, res, elem);
|
|
166
|
+
//return m.tinymce(req, res, elem);
|
|
167
|
+
//return m.ckeditor(req, res, elem);
|
|
168
|
+
//return m.lexical(req,res,elem);
|
|
169
|
+
|
|
170
|
+
let script = '';
|
|
171
|
+
let head = ``;
|
|
172
|
+
let end = ``;
|
|
173
|
+
|
|
174
|
+
head += '<link href="https://cdn.jsdelivr.net/npm/froala-editor@2.9.0/css/froala_editor.pkgd.min.css" rel="stylesheet" type="text/css" />';
|
|
175
|
+
head += '<link href="https://cdn.jsdelivr.net/npm/froala-editor@2.9.0/css/froala_style.min.css" rel="stylesheet" type="text/css" />';
|
|
176
|
+
end += '<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/froala-editor@2.9.0/js/froala_editor.pkgd.min.js"></script>';
|
|
177
|
+
script += `$(function() {$("${elem}").froalaEditor({height: 200})});`;
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
head : head,
|
|
181
|
+
end : end,
|
|
182
|
+
script: script
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
m.switch = function (req, res, elem, array) {
|
|
187
|
+
elem = elem || ".switch";
|
|
188
|
+
let script = '';
|
|
189
|
+
let head = ``;
|
|
190
|
+
let end = ``;
|
|
191
|
+
|
|
192
|
+
head += '<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.4/css/bootstrap3/bootstrap-switch.css" rel="stylesheet" type="text/css" />' + newLine;
|
|
193
|
+
end += '<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.4/js/bootstrap-switch.js"></script>' + newLine;
|
|
194
|
+
|
|
195
|
+
let labels = '';
|
|
196
|
+
if (Array.isArray(array)) {
|
|
197
|
+
labels = '{offText:"' + array[0] + '", onText:"' + array[1] + '"}';
|
|
198
|
+
}
|
|
199
|
+
script += '$("' + elem + '").bootstrapSwitch(' + labels + ');' + newLine;
|
|
200
|
+
return {
|
|
201
|
+
head : head,
|
|
202
|
+
end:end,
|
|
203
|
+
script:script
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
m.switchOld = function (req, res, elem, array) {
|
|
209
|
+
let script = '';
|
|
210
|
+
let head = ``;
|
|
211
|
+
let end = ``;
|
|
212
|
+
elem = elem || ".switch";
|
|
213
|
+
head += '<link href="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/css/bootstrap4-toggle.min.css" rel="stylesheet">' + newLine;
|
|
214
|
+
end += '<script src="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/js/bootstrap4-toggle.min.js"></script>' + newLine;
|
|
215
|
+
|
|
216
|
+
let labels = '';
|
|
217
|
+
if (Array.isArray(array)) {
|
|
218
|
+
labels = '{off:"' + array[0] + '", on:"' + array[1] + '"}';
|
|
219
|
+
}
|
|
220
|
+
script += `$(function(){$('${elem}').bootstrapToggle(${labels});});${Util.newLine}`;
|
|
221
|
+
|
|
222
|
+
return {
|
|
223
|
+
head : head,
|
|
224
|
+
end:end,
|
|
225
|
+
script:script
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
m.clockpicker = function (req, res, elem) {
|
|
230
|
+
let script = '';
|
|
231
|
+
let head = ``;
|
|
232
|
+
let end = ``;
|
|
233
|
+
elem = elem || ".clockpicker";
|
|
234
|
+
head += '<link href="https://cdn.jsdelivr.net/npm/clockpicker@0.0.7/dist/jquery-clockpicker.min.css" rel="stylesheet" type="text/css" />' + newLine;
|
|
235
|
+
end += '<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/clockpicker@0.0.7/dist/bootstrap-clockpicker.min.js"></script>' + newLine;
|
|
236
|
+
script += `$("body").on("click", "${elem}", function(){$(this).clockpicker({donetext: "Done"});});`;
|
|
237
|
+
//end += '$("' + elem + '").clockpicker({donetext: "Done"});' + newLine;
|
|
238
|
+
return {
|
|
239
|
+
head : head,
|
|
240
|
+
end : end,
|
|
241
|
+
script: script
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
m.number = (req, res, elem) => {
|
|
246
|
+
let script = '';
|
|
247
|
+
let head = ``;
|
|
248
|
+
let end = ``;
|
|
249
|
+
elem = elem || ".number";
|
|
250
|
+
|
|
251
|
+
end += '<script type="text/javascript" src="/js/jquery-currency.js"></script>';
|
|
252
|
+
script += `$(function () { $(".number").formatCurrencyLive({symbol:"",roundToDecimalPlace :0,digitGroupSymbol :"."}); });`;
|
|
253
|
+
script += `setTimeout(function () { $("body").click();},1000);`;
|
|
254
|
+
script += `$("body").on("click", function(){$(".number").formatCurrencyLive({symbol:"",roundToDecimalPlace :0,digitGroupSymbol :"."});});`;
|
|
255
|
+
|
|
256
|
+
return {
|
|
257
|
+
head : head,
|
|
258
|
+
end : end,
|
|
259
|
+
script: script
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
m.typeahead = (req, res, elem, data) => {
|
|
264
|
+
let script = '';
|
|
265
|
+
let head = ``;
|
|
266
|
+
let end = ``;
|
|
267
|
+
data = data || [];
|
|
268
|
+
elem = elem || ".typeahead";
|
|
269
|
+
end += '<script type="text/javascript" src="/modules/typeahead/typeahead.js"></script>' + newLine;
|
|
270
|
+
|
|
271
|
+
let elemData = elem.replace(".", "");
|
|
272
|
+
elemData = elemData.replace("#", "");
|
|
273
|
+
let element = elem.replace("Typeahead", "");
|
|
274
|
+
|
|
275
|
+
script += 'const ' + elemData + 'Data = ' + JSON.stringify(data.filter(function (value, index, arr) {
|
|
276
|
+
return index > 0;
|
|
277
|
+
})) + ';' + newLine;
|
|
278
|
+
script += `$("body").on("change", "${elem}", function(){
|
|
279
|
+
var current = $("${elem}").typeahead("getActive");
|
|
280
|
+
if(current){
|
|
281
|
+
$("${element}").val(current.id);
|
|
282
|
+
$("${element}").change();
|
|
283
|
+
}
|
|
284
|
+
});${Util.newLine}`;
|
|
285
|
+
script += `$("body").on("click", "${element}Clear", function(){
|
|
286
|
+
$("${elem}").val("");
|
|
287
|
+
$("${element}").val("");
|
|
288
|
+
$("${elem}").change();
|
|
289
|
+
});${Util.newLine}`;
|
|
290
|
+
script += '$("' + elem + '").typeahead({source: ' + elemData + 'Data ,items: 50, displayText: function(item){ return item.zname.toString();}});' + newLine;
|
|
291
|
+
|
|
292
|
+
return {
|
|
293
|
+
head : head,
|
|
294
|
+
end : end,
|
|
295
|
+
script: script
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
m.custom = (req, res, script, css, src)=> {
|
|
300
|
+
src = src || "";
|
|
301
|
+
css = css || "";
|
|
302
|
+
let head = res.locals.moduleHead;
|
|
303
|
+
let end = res.locals.moduleEnd;
|
|
304
|
+
if (script) {
|
|
305
|
+
end += '<script>' + newLine;
|
|
306
|
+
end += script + newLine;
|
|
307
|
+
end += '</script>' + newLine;;
|
|
308
|
+
}
|
|
309
|
+
if (css) {
|
|
310
|
+
head += css;
|
|
311
|
+
}
|
|
312
|
+
if (src) {
|
|
313
|
+
end += `<script src="${src}"> ${newLine}`;
|
|
314
|
+
}
|
|
315
|
+
res.locals.moduleHead = head;
|
|
316
|
+
res.locals.moduleEnd = end;
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
m.script = (req, res, table) => {
|
|
320
|
+
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
/*
|
|
325
|
+
add scrip code in the body html
|
|
326
|
+
end in the bottom html body (javascript) default
|
|
327
|
+
top in the top html body (css)
|
|
328
|
+
|
|
329
|
+
type : script / css
|
|
330
|
+
*/
|
|
331
|
+
m.addScript = (req, res, contentScript, at = "end", type = "script") => {
|
|
332
|
+
if (contentScript) {
|
|
333
|
+
let generateId = "app_"+ Util.generate(6);
|
|
334
|
+
let tagOpen = type == "script" ? `<script id="${generateId}">` : '<style type="text/css">';
|
|
335
|
+
let tagClose = type == "script" ? '</script>' : '</style>';
|
|
336
|
+
let content = at == "end" ? res.locals.moduleEnd : res.locals.moduleHead;
|
|
337
|
+
content += tagOpen + newLine;
|
|
338
|
+
content += contentScript + newLine;
|
|
339
|
+
content += tagClose + newLine;
|
|
340
|
+
|
|
341
|
+
if(at == "end"){
|
|
342
|
+
res.locals.moduleEnd = content;
|
|
343
|
+
} else res.locals.moduleHead = content;
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
m.addModule = (req,res, content, isModuleHead = false) => {
|
|
348
|
+
let moduleContent = isModuleHead ? res.locals.moduleHead : res.locals.moduleEnd;
|
|
349
|
+
moduleContent += content;
|
|
350
|
+
if(isModuleHead) {
|
|
351
|
+
res.locals.moduleHead = moduleContent;
|
|
352
|
+
} else {
|
|
353
|
+
res.locals.moduleEnd = moduleContent;
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
m.highchart = async(req, res, obj) => {
|
|
358
|
+
obj = obj || {};
|
|
359
|
+
let head = res.locals.moduleHead;
|
|
360
|
+
let end = res.locals.moduleEnd;
|
|
361
|
+
if (end.indexOf("highcharts") < 0) {
|
|
362
|
+
end += '<script src="https://code.highcharts.com/highcharts.js"></script>' + newLine;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if (!Util.isEmptyObject(obj)) {
|
|
366
|
+
const highcharts = require('./highcharts');
|
|
367
|
+
end += '<script>' + newLine;
|
|
368
|
+
end += await highcharts.build(obj);
|
|
369
|
+
end += '</script>' + newLine;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
res.locals.moduleHead = head;
|
|
373
|
+
res.locals.moduleEnd = end;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
m.tableForm = (req, res, name, table) => {
|
|
377
|
+
let head = res.locals.moduleHead;
|
|
378
|
+
let end = res.locals.moduleEnd;
|
|
379
|
+
res.locals.moduleHead = head;
|
|
380
|
+
res.locals.moduleEnd = end;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
m.selectYear = (req, res, elem, val, startYear, endYear) => {
|
|
384
|
+
let dt = new Date();
|
|
385
|
+
endYear = endYear || dt.getFullYear();
|
|
386
|
+
val = val || "";
|
|
387
|
+
var options = "";
|
|
388
|
+
for (var i = endYear; i >= startYear; i--) {
|
|
389
|
+
var selected = i == val ? " selected " : "";
|
|
390
|
+
options += `<option value="${i}" ${selected}>${i}</option>`
|
|
391
|
+
}
|
|
392
|
+
let end = res.locals.moduleEnd;
|
|
393
|
+
end += '<script>' + newLine;
|
|
394
|
+
end += `$("${elem}").html('${options}')`;
|
|
395
|
+
end += '</script>' + newLine;
|
|
396
|
+
res.locals.moduleEnd = end;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
//https://highlightjs.org/usage/
|
|
400
|
+
m.highlight = (req, res, elem) => {
|
|
401
|
+
elem = elem || ".codes";
|
|
402
|
+
let head = res.locals.moduleHead;
|
|
403
|
+
let end = res.locals.moduleEnd;
|
|
404
|
+
if (head.indexOf("highlight") < 0) {
|
|
405
|
+
head += '<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.4.1/styles/default.min.css"> ' + newLine;
|
|
406
|
+
end += '<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.4.1/highlight.min.js"></script>' + newLine;
|
|
407
|
+
}
|
|
408
|
+
end += '<script>$(function(){ document.querySelectorAll("' + elem + '").forEach((block) => {hljs.highlightBlock(block);}); })</script>' + newLine;
|
|
409
|
+
res.locals.moduleHead = head;
|
|
410
|
+
res.locals.moduleEnd = end;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
//https://developer.snapappointments.com/bootstrap-select/
|
|
414
|
+
m.selectpicker = function (req, res, elem) {
|
|
415
|
+
elem = elem || ".selectpicker";
|
|
416
|
+
let head = res.locals.moduleHead;
|
|
417
|
+
let end = res.locals.moduleEnd;
|
|
418
|
+
if (head.indexOf("bootstrap-select") < 0) {
|
|
419
|
+
head += '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/css/bootstrap-select.min.css">' + newLine;
|
|
420
|
+
end += '<script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/js/bootstrap-select.min.js"></script>' + newLine;
|
|
421
|
+
end += `<script>$(function () {$('${elem}').selectpicker();});</script>${newLine}`;
|
|
422
|
+
}
|
|
423
|
+
res.locals.moduleHead = head;
|
|
424
|
+
res.locals.moduleEnd = end;
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
module.exports = m;
|