isite 1.14.92 → 2021.11.3-0.1

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.
Files changed (59) hide show
  1. package/README.md +488 -477
  2. package/apps/client-side/app.js +28 -1
  3. package/apps/client-side/site_files/css/btn.css +98 -0
  4. package/apps/client-side/site_files/css/checkbox.css +10 -7
  5. package/apps/client-side/site_files/css/dropdown.css +61 -0
  6. package/apps/client-side/site_files/css/effect.css +283 -280
  7. package/apps/client-side/site_files/css/font-awesome.css +4615 -3
  8. package/apps/client-side/site_files/css/font-awesome.min.css +5 -0
  9. package/apps/client-side/site_files/css/font-cairo.css +14 -0
  10. package/apps/client-side/site_files/css/font-droid.css +19 -0
  11. package/apps/client-side/site_files/css/fonts.css +6 -34
  12. package/apps/client-side/site_files/css/form.css +31 -131
  13. package/apps/client-side/site_files/css/layout.css +27 -13
  14. package/apps/client-side/site_files/css/modal.css +184 -164
  15. package/apps/client-side/site_files/css/tabs.css +3 -3
  16. package/apps/client-side/site_files/css/theme.css +2 -2
  17. package/apps/client-side/site_files/css/theme_dark.css +1 -1
  18. package/apps/client-side/site_files/css/theme_paper.css +175 -151
  19. package/apps/client-side/site_files/html/sub/i-date2.content.html +64 -0
  20. package/apps/client-side/site_files/html/sub/i-list.content.html +31 -0
  21. package/apps/client-side/site_files/html/sub/i-list2.content.html +22 -0
  22. package/apps/client-side/site_files/js/directive.js +1570 -1650
  23. package/apps/client-side/site_files/js/directive.min.js +2 -2
  24. package/apps/client-side/site_files/js/site.js +59 -17
  25. package/apps/client-side/site_files/js/site.min.js +1 -1
  26. package/apps/client-side/site_files/webfonts/fa-brands-400.eot +0 -0
  27. package/apps/client-side/site_files/webfonts/fa-brands-400.svg +3717 -0
  28. package/apps/client-side/site_files/webfonts/fa-brands-400.ttf +0 -0
  29. package/apps/client-side/site_files/webfonts/fa-brands-400.woff +0 -0
  30. package/apps/client-side/site_files/webfonts/fa-brands-400.woff2 +0 -0
  31. package/apps/client-side/site_files/webfonts/fa-regular-400.eot +0 -0
  32. package/apps/client-side/site_files/webfonts/fa-regular-400.svg +801 -0
  33. package/apps/client-side/site_files/webfonts/fa-regular-400.ttf +0 -0
  34. package/apps/client-side/site_files/webfonts/fa-regular-400.woff +0 -0
  35. package/apps/client-side/site_files/webfonts/fa-regular-400.woff2 +0 -0
  36. package/apps/client-side/site_files/webfonts/fa-solid-900.eot +0 -0
  37. package/apps/client-side/site_files/webfonts/fa-solid-900.svg +5034 -0
  38. package/apps/client-side/site_files/webfonts/fa-solid-900.ttf +0 -0
  39. package/apps/client-side/site_files/webfonts/fa-solid-900.woff +0 -0
  40. package/apps/client-side/site_files/webfonts/fa-solid-900.woff2 +0 -0
  41. package/apps/ui-print/site_files/js/index.js +194 -191
  42. package/index.js +2 -2
  43. package/isite_files/html/browser.html +1 -1
  44. package/isite_files/html/installing.html +1 -1
  45. package/lib/collection.js +14 -7
  46. package/lib/fsm.js +389 -346
  47. package/lib/logs.js +1 -1
  48. package/lib/mongodb.js +9 -7
  49. package/lib/parser.js +495 -475
  50. package/lib/routing.js +61 -17
  51. package/lib/security.js +4 -4
  52. package/lib/session.js +8 -22
  53. package/lib/sessions.js +1 -1
  54. package/lib/storage.js +1 -1
  55. package/lib/temp.js +1 -1
  56. package/lib/ws.js +3 -0
  57. package/object-options/index.js +4 -4
  58. package/object-options/lib/fn.js +1 -1
  59. package/package.json +1 -1
package/lib/parser.js CHANGED
@@ -1,555 +1,575 @@
1
1
  module.exports = function init(req, res, ____0, route) {
2
+ req.features = req.features || [];
2
3
 
3
- req.features = req.features || [];
4
-
5
- let parser = {};
4
+ let parser = {};
6
5
 
7
- function renderVar(v) {
8
- if (v && v == '*') {
9
- return JSON.stringify(____0.var);
10
- }
11
- return ____0.var(v);
12
- }
13
-
14
- function renderParam(v) {
15
- if (typeof req.paramsRaw[v] !== undefined) {
16
- if (v && v == '*') {
17
- return JSON.stringify(req.paramsRaw);
18
- }
19
- return req.paramsRaw[v];
6
+ function renderVar(v) {
7
+ if (v && v == '*') {
8
+ return JSON.stringify(____0.var);
9
+ }
10
+ return ____0.var(v);
20
11
  }
21
12
 
22
- return ' ';
23
- }
13
+ function renderParam(v) {
14
+ if (typeof req.paramsRaw[v] !== undefined) {
15
+ if (v && v == '*') {
16
+ return JSON.stringify(req.paramsRaw);
17
+ }
18
+ return req.paramsRaw[v];
19
+ }
24
20
 
25
- function renderQuery(v) {
26
- if (typeof req.queryRaw[v] !== undefined) {
27
- if (v && v == '*') {
28
- return JSON.stringify(req.queryRaw);
29
- }
30
- return req.queryRaw[v];
21
+ return ' ';
31
22
  }
32
- return ' ';
33
- }
34
23
 
35
- function renderData(d) {
36
- let out = null;
24
+ function renderQuery(v) {
25
+ if (typeof req.queryRaw[v] !== undefined) {
26
+ if (v && v == '*') {
27
+ return JSON.stringify(req.queryRaw);
28
+ }
29
+ return req.queryRaw[v];
30
+ }
31
+ return ' ';
32
+ }
37
33
 
38
- if (d && d == '*') {
39
- out = JSON.stringify(req.data);
40
- } else if (d) {
41
- v = d.split('.');
34
+ function renderData(d) {
35
+ let out = null;
42
36
 
43
- if (v.length > 0) {
44
- out = req.data[v[0]];
45
- }
37
+ if (d && d == '*') {
38
+ out = JSON.stringify(req.data);
39
+ } else if (d) {
40
+ v = d.split('.');
46
41
 
47
- if (v.length > 1 && out) {
48
- out = out[v[1]];
49
- }
42
+ if (v.length > 0) {
43
+ out = req.data[v[0]];
44
+ }
50
45
 
51
- if (v.length > 2 && out) {
52
- out = out[v[2]];
53
- }
46
+ if (v.length > 1 && out) {
47
+ out = out[v[1]];
48
+ }
54
49
 
55
- if (v.length > 3 && out) {
56
- out = out[v[3]];
57
- }
50
+ if (v.length > 2 && out) {
51
+ out = out[v[2]];
52
+ }
58
53
 
59
- if (v.length > 4 && out) {
60
- out = out[v[4]];
61
- }
54
+ if (v.length > 3 && out) {
55
+ out = out[v[3]];
56
+ }
62
57
 
63
- if (v.length > 5 && out) {
64
- out = out[v[5]];
65
- }
58
+ if (v.length > 4 && out) {
59
+ out = out[v[4]];
60
+ }
61
+
62
+ if (v.length > 5 && out) {
63
+ out = out[v[5]];
64
+ }
65
+ }
66
+ if (out && typeof out == 'object') {
67
+ out = JSON.stringify(out);
68
+ }
69
+ return out || renderWord(d);
66
70
  }
67
- if (out && typeof out == 'object') {
68
- out = JSON.stringify(out);
71
+
72
+ function renderUser(v) {
73
+ let user = req.session.user;
74
+ if (user) {
75
+ if (v && v == '*') {
76
+ return JSON.stringify(user);
77
+ } else if (v == 'email') {
78
+ return user.email;
79
+ } else if (v == 'name') {
80
+ if (user.profile) {
81
+ return user.profile.name || user.email;
82
+ }
83
+ return user.email;
84
+ } else if (v == 'id') {
85
+ return user.id;
86
+ } else if (v == '_id') {
87
+ return user._id;
88
+ } else {
89
+ let out = '';
90
+ if (v) {
91
+ v = v.split('.');
92
+
93
+ if (v.length > 0) {
94
+ out = user[v[0]];
95
+ }
96
+
97
+ if (v.length > 1 && out) {
98
+ out = out[v[1]];
99
+ }
100
+
101
+ if (v.length > 2 && out) {
102
+ out = out[v[2]];
103
+ }
104
+
105
+ if (v.length > 3 && out) {
106
+ out = out[v[3]];
107
+ }
108
+
109
+ if (v.length > 4 && out) {
110
+ out = out[v[4]];
111
+ }
112
+
113
+ if (v.length > 5 && out) {
114
+ out = out[v[5]];
115
+ }
116
+ }
117
+
118
+ if (typeof out === 'object') {
119
+ out = ____0.toJson(out);
120
+ }
121
+
122
+ return out;
123
+ }
124
+ }
125
+
126
+ return '';
69
127
  }
70
- return out || renderWord(d);
71
- }
72
-
73
- function renderUser(v) {
74
- let user = req.session.user;
75
- if (user) {
76
- if (v && v == '*') {
77
- return JSON.stringify(user);
78
- } else if (v == 'email') {
79
- return user.email;
80
- } else if (v == 'name') {
81
- if (user.profile) {
82
- return user.profile.name || user.email;
128
+
129
+ function render_site(v) {
130
+ if (v && v == '*') {
131
+ return JSON.stringify(____0);
83
132
  }
84
- return user.email;
85
- } else if (v == 'id') {
86
- return user.id;
87
- } else if (v == '_id') {
88
- return user._id;
89
- } else {
90
133
  let out = '';
91
134
  if (v) {
92
- v = v.split('.');
135
+ v = v.split('.');
93
136
 
94
- if (v.length > 0) {
95
- out = user[v[0]];
96
- }
137
+ if (v.length > 0) {
138
+ out = ____0[v[0]];
139
+ }
97
140
 
98
- if (v.length > 1 && out) {
99
- out = out[v[1]];
100
- }
141
+ if (v.length > 1 && out) {
142
+ out = out[v[1]];
143
+ }
101
144
 
102
- if (v.length > 2 && out) {
103
- out = out[v[2]];
104
- }
145
+ if (v.length > 2 && out) {
146
+ out = out[v[2]];
147
+ }
105
148
 
106
- if (v.length > 3 && out) {
107
- out = out[v[3]];
108
- }
149
+ if (v.length > 3 && out) {
150
+ out = out[v[3]];
151
+ }
109
152
 
110
- if (v.length > 4 && out) {
111
- out = out[v[4]];
112
- }
153
+ if (v.length > 4 && out) {
154
+ out = out[v[4]];
155
+ }
113
156
 
114
- if (v.length > 5 && out) {
115
- out = out[v[5]];
116
- }
157
+ if (v.length > 5 && out) {
158
+ out = out[v[5]];
159
+ }
117
160
  }
118
161
 
119
162
  if (typeof out === 'object') {
120
- out = ____0.toJson(out);
163
+ out = ____0.toJson(out);
121
164
  }
122
165
 
123
166
  return out;
124
- }
125
167
  }
126
168
 
127
- return '';
128
- }
169
+ function render_req(v) {
170
+ if (v && v == '*') {
171
+ return JSON.stringify(req);
172
+ }
173
+ let out = '';
174
+ if (v) {
175
+ v = v.split('.');
129
176
 
130
- function render_site(v) {
131
- if (v && v == '*') {
132
- return JSON.stringify(____0);
133
- }
134
- let out = '';
135
- if (v) {
136
- v = v.split('.');
177
+ if (v.length > 0) {
178
+ out = req[v[0]];
179
+ }
137
180
 
138
- if (v.length > 0) {
139
- out = ____0[v[0]];
140
- }
181
+ if (v.length > 1 && out) {
182
+ out = out[v[1]];
183
+ }
141
184
 
142
- if (v.length > 1 && out) {
143
- out = out[v[1]];
144
- }
185
+ if (v.length > 2 && out) {
186
+ out = out[v[2]];
187
+ }
145
188
 
146
- if (v.length > 2 && out) {
147
- out = out[v[2]];
148
- }
189
+ if (v.length > 3 && out) {
190
+ out = out[v[3]];
191
+ }
149
192
 
150
- if (v.length > 3 && out) {
151
- out = out[v[3]];
152
- }
193
+ if (v.length > 4 && out) {
194
+ out = out[v[4]];
195
+ }
153
196
 
154
- if (v.length > 4 && out) {
155
- out = out[v[4]];
156
- }
197
+ if (v.length > 5 && out) {
198
+ out = out[v[5]];
199
+ }
200
+ }
157
201
 
158
- if (v.length > 5 && out) {
159
- out = out[v[5]];
160
- }
202
+ if (typeof out === 'object') {
203
+ out = ____0.toJson(out);
204
+ }
205
+
206
+ return out;
161
207
  }
162
208
 
163
- if (typeof out === 'object') {
164
- out = ____0.toJson(out);
209
+ function renderSession(v) {
210
+ if (v && v == '*') {
211
+ return JSON.stringify({
212
+ accessToken: req.session.accessToken,
213
+ createdTime: req.session.createdTime,
214
+ modifiedTime: req.session.modifiedTime,
215
+ data: req.session.data,
216
+ ip: req.session.ip,
217
+ requestesCount: req.session.requestesCount,
218
+ busy: req.session.$busy,
219
+ ip_info: req.session.ip_info,
220
+ });
221
+ }
222
+ if (v == 'lang') {
223
+ return req.session.lang;
224
+ } else if (v == 'theme') {
225
+ return req.session.theme;
226
+ } else {
227
+ return req.session[v] ?? req.session.get(v);
228
+ }
165
229
  }
166
230
 
167
- return out;
168
- }
231
+ function renderJson(name) {
232
+ return ____0.readFileSync(route.parserDir + '/json/' + name + '.json');
233
+ }
169
234
 
170
- function render_req(v) {
171
- if (v && v == '*') {
172
- return JSON.stringify(req);
235
+ function renderWord(name) {
236
+ let w = ____0.word(name);
237
+ if (w.done) {
238
+ return w[req.session.lang] || name;
239
+ } else {
240
+ return name;
241
+ }
173
242
  }
174
- let out = '';
175
- if (v) {
176
- v = v.split('.');
177
243
 
178
- if (v.length > 0) {
179
- out = req[v[0]];
180
- }
244
+ function renderSetting(v) {
245
+ if (v && v == '*') {
246
+ return JSON.stringify(____0.setting.list);
247
+ }
248
+ return ____0.setting.get(v).value;
249
+ }
181
250
 
182
- if (v.length > 1 && out) {
183
- out = out[v[1]];
184
- }
251
+ function getContent(name) {
252
+ let path = null;
253
+
254
+ if (!path || !____0.isFileExistsSync(path)) {
255
+ let arr = name.split('/');
256
+ if (arr.length === 1) {
257
+ path = ____0.path.join(____0.path.dirname(route.parserDir), 'site_files', ____0.path.extname(arr[0]).replace('.', ''), arr[0]);
258
+ } else if (arr.length === 2) {
259
+ path = ____0.path.join(____0.path.dirname(route.parserDir), 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[0], arr[1]);
260
+ } else if (arr.length === 3) {
261
+ path = ____0.path.join(____0.path.dirname(route.parserDir), 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[0], arr[1], arr[2]);
262
+ }
263
+ }
185
264
 
186
- if (v.length > 2 && out) {
187
- out = out[v[2]];
188
- }
265
+ if (!____0.isFileExistsSync(path)) {
266
+ let arr = name.split('/');
267
+ if (arr.length === 2) {
268
+ path = ____0.path.join(____0.path.dirname(route.parserDir), 'apps', arr[0], 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
269
+ } else if (arr.length === 3) {
270
+ path = ____0.path.join(____0.path.dirname(route.parserDir), 'apps', arr[0], 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[1], arr[2]);
271
+ }
272
+ }
189
273
 
190
- if (v.length > 3 && out) {
191
- out = out[v[3]];
192
- }
274
+ if (!____0.isFileExistsSync(path)) {
275
+ let arr = name.split('/');
276
+ if (arr.length > 1) {
277
+ ____0.apps.forEach((ap) => {
278
+ if (arr.length === 2 && ap.name == arr[0]) {
279
+ path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
280
+ } else if (arr.length === 2 && ap.name2 == arr[0]) {
281
+ path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
282
+ } else if (arr.length === 3 && ap.name == arr[0]) {
283
+ path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[1], arr[2]);
284
+ }
285
+ });
286
+ }
287
+ }
193
288
 
194
- if (v.length > 4 && out) {
195
- out = out[v[4]];
196
- }
289
+ if (!____0.isFileExistsSync(path)) {
290
+ ____0.log(path, 'PATH NOT EXISTS parser.getContent()');
291
+ return '';
292
+ }
197
293
 
198
- if (v.length > 5 && out) {
199
- out = out[v[5]];
200
- }
294
+ if (name.endsWith('.content.html')) {
295
+ let txt = ____0.readFileSync(path);
296
+ return txt;
297
+ } else if (name.endsWith('.html')) {
298
+ let txt = ____0.readFileSync(path);
299
+ let $ = ____0.$.load(txt);
300
+ $ = renderHtml($);
301
+ return $.html();
302
+ } else if (name.endsWith('.js')) {
303
+ let txt = ____0.readFileSync(path);
304
+ txt = parser.js(txt);
305
+ return txt;
306
+ } else if (name.endsWith('.css')) {
307
+ let txt = ____0.readFileSync(path);
308
+ txt = parser.css(txt);
309
+ return txt;
310
+ } else {
311
+ let txt = ____0.readFileSync(path);
312
+ return txt;
313
+ }
201
314
  }
202
315
 
203
- if (typeof out === 'object') {
204
- out = ____0.toJson(out);
205
- }
316
+ function renderHtml($, log) {
317
+ $('[x-setting]').each(function (i, elem) {
318
+ if (!____0.setting.get($(this).attr('x-setting')).value) {
319
+ $(this).remove();
320
+ }
321
+ });
206
322
 
207
- return out;
208
- }
209
-
210
- function renderSession(v) {
211
- if (v && v == '*') {
212
- return JSON.stringify({
213
- accessToken: req.session.accessToken,
214
- createdTime: req.session.createdTime,
215
- modifiedTime: req.session.modifiedTime,
216
- data: req.session.data,
217
- ip: req.session.ip,
218
- requestesCount: req.session.requestesCount,
219
- busy: req.session.$busy,
220
- ip_info: req.session.ip_info,
221
- });
222
- }
223
- if (v == 'lang') {
224
- return req.session.lang;
225
- } else if (v == 'theme') {
226
- return req.session.theme;
227
- } else {
228
- return req.session[v] ?? req.session.get(v);
229
- }
230
- }
231
-
232
- function renderJson(name) {
233
- return ____0.readFileSync(route.parserDir + '/json/' + name + '.json');
234
- }
235
-
236
- function renderWord(name) {
237
- let w = ____0.word(name);
238
- if (w.done) {
239
- return w[req.session.lang] || name;
240
- } else {
241
- return name;
242
- }
243
- }
323
+ $('[x-permission]').each(function (i, elem) {
324
+ if (!____0.security.isUserHasPermission(req, res, $(this).attr('x-permission'))) {
325
+ $(this).remove();
326
+ }
327
+ });
244
328
 
245
- function renderSetting(v) {
246
- if (v && v == '*') {
247
- return JSON.stringify(____0.setting.list);
248
- }
249
- return ____0.setting.get(v).value;
250
- }
251
-
252
- function getContent(name) {
253
- let path = ____0.path.join(route.parserDir, ____0.path.extname(name).replace('.', ''), name);
254
-
255
- if (!____0.isFileExistsSync(path)) {
256
- let arr = name.split('/');
257
- if (arr.length === 2) {
258
- path = ____0.path.join(____0.path.dirname(route.parserDir), 'apps', arr[0], 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
259
- } else if (arr.length === 3) {
260
- path = ____0.path.join(____0.path.dirname(route.parserDir), 'apps', arr[0], 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[1], arr[2]);
261
- }
262
- }
329
+ $('[x-role]').each(function (i, elem) {
330
+ if (!____0.security.isUserHasRole(req, res, $(this).attr('x-role'))) {
331
+ $(this).remove();
332
+ }
333
+ });
263
334
 
264
- if (!____0.isFileExistsSync(path)) {
265
- let arr = name.split('/');
266
- if (arr.length > 1) {
267
- ____0.apps.forEach((ap) => {
268
- if (arr.length === 2 && ap.name == arr[0]) {
269
- path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
270
- } else if (arr.length === 2 && ap.name2 == arr[0]) {
271
- path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
272
- } else if (arr.length === 3 && ap.name == arr[0]) {
273
- path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[1], arr[2]);
274
- }
335
+ $('[x-permissions]').each(function (i, elem) {
336
+ if (!____0.security.isUserHasPermissions(req, res, $(this).attr('x-permissions'))) {
337
+ $(this).remove();
338
+ }
275
339
  });
276
- }
277
- }
278
340
 
279
- if (!____0.isFileExistsSync(path)) {
280
- ____0.log(path, 'PATH NOT EXISTS');
281
- return '';
282
- }
341
+ $('[x-roles]').each(function (i, elem) {
342
+ if (!____0.security.isUserHasRoles(req, res, $(this).attr('x-roles'))) {
343
+ $(this).remove();
344
+ }
345
+ });
283
346
 
284
- if (name.endsWith('.html')) {
285
- let txt = ____0.readFileSync(path);
286
- let $ = ____0.$.load(txt);
287
- $ = renderHtml($);
288
- return $.html();
289
- } else if (name.endsWith('.js')) {
290
- let txt = ____0.readFileSync(path);
291
- txt = parser.js(txt);
292
- return txt;
293
- } else if (name.endsWith('.css')) {
294
- let txt = ____0.readFileSync(path);
295
- txt = parser.css(txt);
296
- return txt;
297
- } else {
298
- let txt = ____0.readFileSync(path);
299
- return txt;
300
- }
301
- }
302
-
303
- function renderHtml($, log) {
304
- $('[x-setting]').each(function (i, elem) {
305
- if (!____0.setting.get($(this).attr('x-setting')).value) {
306
- $(this).remove();
307
- }
308
- });
309
-
310
- $('[x-permission]').each(function (i, elem) {
311
- if (!____0.security.isUserHasPermission(req, res, $(this).attr('x-permission'))) {
312
- $(this).remove();
313
- }
314
- });
315
-
316
- $('[x-role]').each(function (i, elem) {
317
- if (!____0.security.isUserHasRole(req, res, $(this).attr('x-role'))) {
318
- $(this).remove();
319
- }
320
- });
321
-
322
- $('[x-permissions]').each(function (i, elem) {
323
- if (!____0.security.isUserHasPermissions(req, res, $(this).attr('x-permissions'))) {
324
- $(this).remove();
325
- }
326
- });
327
-
328
- $('[x-roles]').each(function (i, elem) {
329
- if (!____0.security.isUserHasRoles(req, res, $(this).attr('x-roles'))) {
330
- $(this).remove();
331
- }
332
- });
333
-
334
- $('[x-lang]').each(function (i, elem) {
335
- if ($(this).attr('x-lang') !== req.session.lang) {
336
- $(this).remove();
337
- }
338
- });
339
-
340
- $('[x-feature]').each(function (i, elem) {
341
- let f = $(this).attr('x-feature');
342
- let not = !1;
343
- if (f.startsWith('!')) {
344
- f = f.replace('!', '');
345
- not = !0;
346
- }
347
- if (!req.features.some((ff) => ff.like(f)) && !not) {
348
- $(this).remove();
349
- }
350
- if (req.features.some((ff) => ff.like(f)) && not) {
351
- $(this).remove();
352
- }
353
- });
354
-
355
- $('[x-features]').each(function (i, elem) {
356
- let fs = $(this).attr('x-features');
357
- if (fs.indexOf('||') > -1) {
358
- let del = !0;
359
- fs.split('||').forEach((f) => {
360
- f = f.trim();
361
- let not = !1;
362
- if (f.startsWith('!')) {
363
- f = f.replace('!', '');
364
- not = !0;
365
- }
366
- if (req.features.some((ff) => ff.like(f)) && !not) {
367
- del = !1;
368
- }
369
- if (!req.features.some((ff) => ff.like(f)) && not) {
370
- del = !1;
371
- }
347
+ $('[x-lang]').each(function (i, elem) {
348
+ if ($(this).attr('x-lang') !== req.session.lang) {
349
+ $(this).remove();
350
+ }
372
351
  });
373
352
 
374
- if (del) {
375
- $(this).remove();
376
- }
377
- } else if (fs.indexOf('&&') > -1) {
378
- let ok_list = [];
379
- fs.split('&&').forEach((f) => {
380
- f = f.trim();
381
- let d = !0;
382
- if (f.startsWith('!')) {
383
- f = f.replace('!', '');
384
- d = !1;
385
- }
386
- if (!req.features.some((ff) => ff.like(f)) && !d) {
387
- ok_list.push({});
388
- }
389
- if (req.features.some((ff) => ff.like(f)) && d) {
390
- ok_list.push({});
391
- }
353
+ $('[x-feature]').each(function (i, elem) {
354
+ let f = $(this).attr('x-feature');
355
+ let not = !1;
356
+ if (f.startsWith('!')) {
357
+ f = f.replace('!', '');
358
+ not = !0;
359
+ }
360
+ if (!req.features.some((ff) => ff.like(f)) && !not) {
361
+ $(this).remove();
362
+ }
363
+ if (req.features.some((ff) => ff.like(f)) && not) {
364
+ $(this).remove();
365
+ }
392
366
  });
393
- if (ok_list.length !== fs.split('&&').length) {
394
- $(this).remove();
395
- }
396
- } else {
397
- f = fs.trim();
398
- let d = !0;
399
- if (f.startsWith('!')) {
400
- f = f.replace('!', '');
401
- d = !1;
402
- }
403
- if (!req.features.some((ff) => ff.like(f)) && d) {
404
- $(this).remove();
367
+
368
+ $('[x-features]').each(function (i, elem) {
369
+ let fs = $(this).attr('x-features');
370
+ if (fs.indexOf('||') > -1) {
371
+ let del = !0;
372
+ fs.split('||').forEach((f) => {
373
+ f = f.trim();
374
+ let not = !1;
375
+ if (f.startsWith('!')) {
376
+ f = f.replace('!', '');
377
+ not = !0;
378
+ }
379
+ if (req.features.some((ff) => ff.like(f)) && !not) {
380
+ del = !1;
381
+ }
382
+ if (!req.features.some((ff) => ff.like(f)) && not) {
383
+ del = !1;
384
+ }
385
+ });
386
+
387
+ if (del) {
388
+ $(this).remove();
389
+ }
390
+ } else if (fs.indexOf('&&') > -1) {
391
+ let ok_list = [];
392
+ fs.split('&&').forEach((f) => {
393
+ f = f.trim();
394
+ let d = !0;
395
+ if (f.startsWith('!')) {
396
+ f = f.replace('!', '');
397
+ d = !1;
398
+ }
399
+ if (!req.features.some((ff) => ff.like(f)) && !d) {
400
+ ok_list.push({});
401
+ }
402
+ if (req.features.some((ff) => ff.like(f)) && d) {
403
+ ok_list.push({});
404
+ }
405
+ });
406
+ if (ok_list.length !== fs.split('&&').length) {
407
+ $(this).remove();
408
+ }
409
+ } else {
410
+ f = fs.trim();
411
+ let d = !0;
412
+ if (f.startsWith('!')) {
413
+ f = f.replace('!', '');
414
+ d = !1;
415
+ }
416
+ if (!req.features.some((ff) => ff.like(f)) && d) {
417
+ $(this).remove();
418
+ }
419
+ if (req.features.some((ff) => ff.like(f)) && !d) {
420
+ $(this).remove();
421
+ }
422
+ }
423
+ });
424
+
425
+ if (route.parser.like('*css*')) {
426
+ $('style').each(function (i, elem) {
427
+ $(this).html(parser.css($(this).html()));
428
+ });
405
429
  }
406
- if (req.features.some((ff) => ff.like(f)) && !d) {
407
- $(this).remove();
430
+
431
+ if (route.parser.like('*js*')) {
432
+ $('script').each(function (i, elem) {
433
+ $(this).html(parser.js($(this).html()));
434
+ });
408
435
  }
409
- }
410
- });
411
436
 
412
- if (route.parser.like('*css*')) {
413
- $('style').each(function (i, elem) {
414
- $(this).html(parser.css($(this).html()));
415
- });
416
- }
437
+ $($('[x-import]').get().reverse()).each(function (i, elem) {
438
+ let file = $(this).attr('x-import');
439
+ $(this).removeAttr('x-import');
440
+ $(this).attr('x-server' , 'x-import');
441
+ if (file.endsWith('.html')) {
442
+ $(this).html(getContent(file) + $(this).html());
443
+ }else if (file.endsWith('.css')) {
444
+ $(this).text(getContent(file) + $(this).html());
445
+ } else {
446
+ $(this).text(getContent(file) + $(this).text());
447
+ }
448
+ });
417
449
 
418
- if (route.parser.like('*js*')) {
419
- $('script').each(function (i, elem) {
420
- $(this).html(parser.js($(this).html()));
421
- });
450
+ $($('[x-append]').get().reverse()).each(function (i, elem) {
451
+ let file = $(this).attr('x-append');
452
+ $(this).removeAttr('x-append');
453
+ $(this).attr('x-server' , 'x-append');
454
+ if (file.endsWith('.html')) {
455
+ $(this).html($(this).html() + getContent(file));
456
+ }else if (file.endsWith('.css')) {
457
+ $(this).text($(this).html() + getContent(file));
458
+ } else {
459
+ $(this).text($(this).text() + getContent(file));
460
+ }
461
+ });
462
+
463
+ $($('[x-replace]').get().reverse()).each(function (i, elem) {
464
+ let file = $(this).attr('x-replace');
465
+ $(this).removeAttr('x-replace');
466
+ $(this).attr('x-server' , 'x-replace');
467
+ if (file.endsWith('.html')) {
468
+ $(this).html(getContent(file));
469
+ }else {
470
+ $(this).text(getContent(file));
471
+ }
472
+ });
473
+
474
+ return $;
422
475
  }
423
476
 
424
- $('[x-import]').each(function (i, elem) {
425
- let file = $(this).attr('x-import');
426
- if (file.endsWith('.html')) {
427
- $(this).html(getContent(file) + $(this).html());
428
- } else {
429
- $(this).text(getContent(file) + $(this).text());
430
- }
431
- });
432
-
433
- $('[x-append]').each(function (i, elem) {
434
- let file = $(this).attr('x-append');
435
- if (file.endsWith('.html')) {
436
- $(this).html($(this).html() + getContent(file));
437
- } else {
438
- $(this).text($(this).text() + getContent(file));
439
- }
440
- });
441
-
442
- $('[x-replace]').each(function (i, elem) {
443
- let file = $(this).attr('x-replace');
444
- if (file.endsWith('.html')) {
445
- $(this).html(getContent(file));
446
- } else {
447
- $(this).text(getContent(file));
448
- }
449
- });
450
-
451
- return $;
452
- }
453
-
454
- parser.html = function (content) {
455
- let $ = ____0.$.load(content);
456
- $ = renderHtml($);
457
- let txt = $.html();
458
-
459
- let matches = $.html().match(/##.*?##/g);
460
- if (matches) {
461
- for (let i = 0; i < matches.length; i++) {
462
- let v = matches[i];
463
-
464
- if (v.startsWith('##var.')) {
465
- v = v.replace('##var.', '').replace('##', '');
466
- txt = txt.replace(matches[i], renderVar(v));
467
- } else if (v.startsWith('##user.')) {
468
- v = v.replace('##user.', '').replace('##', '');
469
- txt = txt.replace(matches[i], renderUser(v));
470
- } else if (v.startsWith('##site.')) {
471
- v = v.replace('##site.', '').replace('##', '');
472
- txt = txt.replace(matches[i], render_site(v));
473
- } else if (v.startsWith('##req.')) {
474
- v = v.replace('##req.', '').replace('##', '');
475
- txt = txt.replace(matches[i], render_req(v));
476
- } else if (v.startsWith('##session.')) {
477
- v = v.replace('##session.', '').replace('##', '');
478
- txt = txt.replace(matches[i], renderSession(v));
479
- } else if (v.startsWith('##json.')) {
480
- v = v.replace('##json.', '').replace('##', '');
481
- txt = txt.replace(matches[i], renderJson(v));
482
- } else if (v.startsWith('##word.')) {
483
- v = v.replace('##word.', '').replace('##', '');
484
- txt = txt.replace(matches[i], renderWord(v));
485
- } else if (v.startsWith('##setting.')) {
486
- v = v.replace('##setting.', '').replace('##', '');
487
- txt = txt.replace(matches[i], renderSetting(v));
488
- } else if (v.startsWith('##params.')) {
489
- v = v.replace('##params.', '').replace('##', '');
490
- txt = txt.replace(matches[i], renderParam(v));
491
- } else if (v.startsWith('##query.')) {
492
- v = v.replace('##query.', '').replace('##', '');
493
- txt = txt.replace(matches[i], renderQuery(v));
494
- } else if (v.startsWith('##data.')) {
495
- v = v.replace('##data.', '').replace('##', '');
496
- txt = txt.replace(matches[i], renderData(v));
497
- } else {
477
+ parser.handleMatches = function (txt) {
478
+ let matches = txt.match(/##.*?##/g);
479
+ if (matches) {
480
+ for (let i = 0; i < matches.length; i++) {
481
+ let v = matches[i];
482
+
483
+ if (v.startsWith('##var.')) {
484
+ v = v.replace('##var.', '').replace('##', '');
485
+ txt = txt.replace(matches[i], renderVar(v));
486
+ } else if (v.startsWith('##user.')) {
487
+ v = v.replace('##user.', '').replace('##', '');
488
+ txt = txt.replace(matches[i], renderUser(v));
489
+ } else if (v.startsWith('##site.')) {
490
+ v = v.replace('##site.', '').replace('##', '');
491
+ txt = txt.replace(matches[i], render_site(v));
492
+ } else if (v.startsWith('##req.')) {
493
+ v = v.replace('##req.', '').replace('##', '');
494
+ txt = txt.replace(matches[i], render_req(v));
495
+ } else if (v.startsWith('##session.')) {
496
+ v = v.replace('##session.', '').replace('##', '');
497
+ txt = txt.replace(matches[i], renderSession(v));
498
+ } else if (v.startsWith('##json.')) {
499
+ v = v.replace('##json.', '').replace('##', '');
500
+ txt = txt.replace(matches[i], renderJson(v));
501
+ } else if (v.startsWith('##word.')) {
502
+ v = v.replace('##word.', '').replace('##', '');
503
+ txt = txt.replace(matches[i], renderWord(v));
504
+ } else if (v.startsWith('##setting.')) {
505
+ v = v.replace('##setting.', '').replace('##', '');
506
+ txt = txt.replace(matches[i], renderSetting(v));
507
+ } else if (v.startsWith('##params.')) {
508
+ v = v.replace('##params.', '').replace('##', '');
509
+ txt = txt.replace(matches[i], renderParam(v));
510
+ } else if (v.startsWith('##query.')) {
511
+ v = v.replace('##query.', '').replace('##', '');
512
+ txt = txt.replace(matches[i], renderQuery(v));
513
+ } else if (v.startsWith('##data.')) {
514
+ v = v.replace('##data.', '').replace('##', '');
515
+ txt = txt.replace(matches[i], renderData(v));
516
+ } else {
517
+ }
518
+ }
498
519
  }
499
- }
500
- }
520
+ return txt;
521
+ };
522
+
523
+ parser.html = function (content) {
524
+ let $ = ____0.$.load(content);
525
+ $ = renderHtml($);
526
+ txt = parser.handleMatches($.html());
527
+ return txt;
528
+ };
529
+
530
+ parser.js = function (content) {
531
+ let matches = content.match(/\/\*##.*?\*\//g);
532
+ if (matches) {
533
+ for (let i = 0; i < matches.length; i++) {
534
+ let v = matches[i];
535
+ v = v.replace('/*##', '').replace('*/', '');
536
+ content = content.replace(matches[i], getContent(v));
537
+ }
538
+ }
539
+ content = parser.handleMatches(content);
540
+ return content;
541
+ };
501
542
 
502
- return txt;
503
- };
543
+ parser.css = function (content) {
544
+ content = parser.handleMatches(content);
504
545
 
505
- parser.css = function (content) {
506
- let matches = content.match(/var\(--.*?\)/g);
507
- if (matches) {
508
- for (let i = 0; i < matches.length; i++) {
509
- let v = matches[i];
546
+ let matches = content.match(/var\(--.*?\)/g);
547
+ if (matches) {
548
+ for (let i = 0; i < matches.length; i++) {
549
+ let v = matches[i];
510
550
 
511
- v = v.replace('var(--', '').replace(')', '');
512
- content = content.replace(matches[i], renderVar(v));
513
- }
514
- }
551
+ v = v.replace('var(--', '').replace(')', '');
552
+ content = content.replace(matches[i], renderVar(v));
553
+ }
554
+ }
515
555
 
516
- let matches2 = content.match(/word\(--.*?\)/g);
517
- if (matches2) {
518
- for (let i = 0; i < matches2.length; i++) {
519
- let v = matches2[i];
556
+ let matches2 = content.match(/word\(--.*?\)/g);
557
+ if (matches2) {
558
+ for (let i = 0; i < matches2.length; i++) {
559
+ let v = matches2[i];
520
560
 
521
- v = v.replace('word(--', '').replace(')', '');
522
- content = content.replace(matches2[i], renderWord(v));
523
- }
524
- }
561
+ v = v.replace('word(--', '').replace(')', '');
562
+ content = content.replace(matches2[i], renderWord(v));
563
+ }
564
+ }
525
565
 
526
- return content;
527
- };
528
-
529
- parser.js = function (content) {
530
- let matches = content.match(/\/\*##.*?\*\//g);
531
- if (matches) {
532
- for (let i = 0; i < matches.length; i++) {
533
- let v = matches[i];
534
- v = v.replace('/*##', '').replace('*/', '');
535
- content = content.replace(matches[i], getContent(v));
536
- }
537
- }
538
- let matches2 = content.match(/\/\*query.*?\*\//g);
539
- if (matches2) {
540
- for (let i = 0; i < matches2.length; i++) {
541
- let v = matches2[i];
542
- v = v.replace('/*query.', '').replace('*/', '');
543
- content = content.replace(matches2[i], renderQuery(v));
544
- }
545
- }
546
- return content;
547
- };
566
+ return content;
567
+ };
548
568
 
549
- parser.json = function (content) {
550
- return content;
551
- };
569
+ parser.json = function (content) {
570
+ return content;
571
+ };
552
572
 
553
- parser.renderHtml = renderHtml;
554
- return parser;
573
+ parser.renderHtml = renderHtml;
574
+ return parser;
555
575
  };