prototype.exe 0.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.
package/package.js ADDED
File without changes
package/package.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "prototype.exe",
3
+ "description": "JScript",
4
+ "version": "0.0.1",
5
+ "main": "src/prototype.js",
6
+ "files": [
7
+ "src/",
8
+ "package.js"
9
+ ]
10
+ }
@@ -0,0 +1,1339 @@
1
+ /**
2
+ * xxx
3
+ *
4
+ * title
5
+ * description
6
+ * sub description
7
+ *
8
+ * xxx://xxx.xxx.xxx/xxx
9
+ */
10
+
11
+ function Define ($, key, value, option = {}) {
12
+ if (key) Object.defineProperty ($, key, {enumerable: option.enumerable || false, configurable: option.configurable || false, writable: option.writable || false, value});
13
+ else return new Define.properties ($);
14
+ }
15
+
16
+ Define.properties = class {
17
+ constructor (property) {
18
+ this.property = property;
19
+ }
20
+ export (data) {
21
+ return this.property.exports = data;
22
+ }
23
+ }
24
+
25
+ /**
26
+ * object
27
+ *
28
+ * title
29
+ * description
30
+ * sub description
31
+ *
32
+ * xxx://xxx.xxx.xxx/xxx
33
+ */
34
+
35
+ Define (Object, "define", Define);
36
+
37
+ Define (Object, "type", function (input) { return typeof input; });
38
+ Define (Object.type, "array", function (input) { if (arguments.length) return input instanceof Array || typeof input === "array"; else return Array; });
39
+ Define (Object.type, "boolean", function (input) { if (arguments.length) return input instanceof Boolean || typeof input === "boolean"; else return Boolean; });
40
+ Define (Object.type, "buffer", function (input) { if (arguments.length) return input instanceof Buffer || typeof input === "buffer"; else return Boolean; });
41
+ Define (Object.type, "date", function (input) { if (arguments.length) return input instanceof Date || typeof input === "date"; else return Date; });
42
+ Define (Object.type, "error", function (input) { if (arguments.length) return input instanceof Error || typeof input === "error"; else return Error; });
43
+ Define (Object.type, "function", function (input) { if (arguments.length) return input instanceof Function || typeof input === "function"; else return Function; });
44
+ Define (Object.type, "number", function (input) { if (arguments.length) return input instanceof Number || typeof input === "number"; else return Number; });
45
+ Define (Object.type, "object", function (input) { if (arguments.length) return input instanceof Object || typeof input === "object"; else return Object; });
46
+ Define (Object.type, "promise", function (input) { if (arguments.length) return input instanceof Promise || typeof input === "promise"; else return Promise; });
47
+ Define (Object.type, "regex", function (input) { if (arguments.length) return input instanceof RegExp || typeof input === "regex"; else return RegExp; });
48
+ Define (Object.type, "string", function (input) { if (arguments.length) return input instanceof String || typeof input === "string"; else return String; });
49
+
50
+ Define (Object, "type_of", function (input) { return Object.prototype.toString.call (input); });
51
+ Define (Object.type_of, "array", function (input) { if (arguments.length) return Object.type_of (input) === "[object Array]"; else return "[object Array]"; });
52
+ Define (Object.type_of, "boolean", function (input) { if (arguments.length) return Object.type_of (input) === "[object Boolean]"; else return "[object Boolean]"; });
53
+ Define (Object.type_of, "buffer", function (input) { if (arguments.length) return Object.type_of (input) === "[object Buffer]"; else return "[object Buffer]"; });
54
+ Define (Object.type_of, "date", function (input) { if (arguments.length) return Object.type_of (input) === "[object Date]"; else return "[object Date]"; });
55
+ Define (Object.type_of, "function", function (input) { if (arguments.length) return Object.type_of (input) === "[object Function]"; else return "[object Function]"; });
56
+ Define (Object.type_of, "null", function (input) { if (arguments.length) return Object.type_of (input) === "[object Null]"; else return "[object Null]"; });
57
+ Define (Object.type_of, "number", function (input) { if (arguments.length) return Object.type_of (input) === "[object Number]"; else return "[object Number]"; });
58
+ Define (Object.type_of, "object", function (input) { if (arguments.length) return Object.type_of (input) === "[object Object]"; else return "[object Object]"; });
59
+ Define (Object.type_of, "promise", function (input) { if (arguments.length) return Object.type_of (input) === "[object Promise]"; else return "[object Promise]"; });
60
+ Define (Object.type_of, "regex", function (input) { if (arguments.length) return Object.type_of (input) === "[object RegExp]"; else return "[object RegExp]"; });
61
+ Define (Object.type_of, "string", function (input) { if (arguments.length) return Object.type_of (input) === "[object String]"; else return "[object String]"; });
62
+
63
+ Define (Object, "is", function () {});
64
+ Define (Object.is, "url", function (url) {
65
+ if (typeof url === "string") return url.startsWith ("http://") || url.startsWith ("https://") || url.startsWith ("//");
66
+ else return false;
67
+ });
68
+ Define (Object.is, "ip", function (input) {
69
+ var part = input.split (".");
70
+ if (part.length === 4) {
71
+ for (var i in part) {
72
+ var partial = parseInt (part [i]);
73
+ if (partial >= 0 && partial <= 255) {}
74
+ else return false;
75
+ }
76
+ return true;
77
+ }
78
+ return false;
79
+ });
80
+
81
+ Define (Object, "length", function (object) { return Object.keys (object).length; });
82
+ Define (Object, "clone", function (object) { return JSON.parse (JSON.stringify (object)); });
83
+
84
+ Define (Object, "un_define", function (input) { if (arguments.length) return input === undefined; else return undefined; });
85
+ Define (Object, "un_set", function (input) { return input === undefined || input === null; });
86
+ Define (Object.is, "set", function (input) { return ! Object.un_set (input); });
87
+
88
+ /**
89
+ * array
90
+ *
91
+ * title
92
+ * description
93
+ * sub description
94
+ *
95
+ * xxx://xxx.xxx.xxx/xxx
96
+ */
97
+
98
+ Define (Array.prototype, "json", function () { return JSON.pretty (this); });
99
+ Define (Array.prototype, "clone", function () { return JSON.parse (JSON.stringify (this)); });
100
+ Define (Array.prototype, "exist", function (value, offset) { if (Array.isArray (value)) { for (var i in value) if (this.includes (value [i])) return true; return false; } else return this.includes (value, offset); });
101
+ Define (Array.prototype, "include", function (value, offset) { return this.includes (value, offset); });
102
+ Define (Array.prototype, "first", function () { for (var i in this) return this [i]; return undefined; }); Define (Array.prototype, "one", function () { return this.first (); });
103
+ Define (Array.prototype, "last", function () { var value; for (var i in this) value = this [i]; return value; });
104
+ Define (Array.prototype, "max", function () { return Math.max (... this); });
105
+ Define (Array.prototype, "min", function () { return Math.min (... this); });
106
+ Define (Array.prototype, "shuffle", function () { var array = this.clone (); var current = array.length, random; while (current !== 0) { random = Math.floor (Math.random () * current); current --; [array [current], array [random]] = [array [random], array [current]]; } return array; });
107
+ Define (Array.prototype, "limit", function (limit) { return this.clone ().slice (0, limit); });
108
+ Define (Array.prototype, "page", function (page, limit) { return this.clone ().slice (((page - 1) * (limit || Array.config.page.limit)), (page * (limit || Array.config.page.limit))); });
109
+ Define (Array.prototype, "distinct", function (key = "id", distinct = []) { return this.filter (function (array) { if (distinct.includes (array [key])) return false; else { distinct.push (array [key]); return true; } }); });
110
+ Define (Array.prototype, "implode", function (data) { var array = this.clone (); array.push (... data); return array; });
111
+
112
+ Define (Array.prototype, "select", function (filter) {
113
+ return this.filter (function (array, index) {
114
+ var error = 0;
115
+ for (var i in filter) {
116
+ if (typeof filter [i] === "object") {
117
+ if (filter [i].key === "!") {
118
+ if (filter [i].value !== array [i]) continue;
119
+ else error ++;
120
+ }
121
+ }
122
+ else if (Array.isArray (filter [i])) if (filter [i].includes (array [i])) continue; else error ++;
123
+ else if (Array.isArray (array [i])) if (array [i].includes (filter [i])) continue; else error ++;
124
+ else if (filter [i] === array [i]) continue;
125
+ else error ++;
126
+ }
127
+ if (error) return false;
128
+ else return true;
129
+ });
130
+ });
131
+
132
+ Define (Array.prototype, "order", function (sort) {
133
+ var array = this.clone (), type = "string";
134
+ var object = sort.split (".");
135
+ if (object.length > 2) {
136
+ if (this.length) if (typeof this [0][object [0]][object [1]][object [2]] === "number") type = "number";
137
+ if (type === "string") array.sort (function (a, b) { return a [object [0]][object [1]][object [2]].localeCompare (b [object [0]][object [1]][object [2]]); });
138
+ if (type === "number") array.sort (function (a, b) { return a [object [0]][object [1]][object [2]] - b [object [0]][object [1]][object [2]]; });
139
+ }
140
+ else if (object.length > 1) {
141
+ if (this.length) if (typeof this [0][object [0]][object [1]] === "number") type = "number";
142
+ if (type === "string") array.sort (function (a, b) { return a [object [0]][object [1]].localeCompare (b [object [0]][object [1]]); });
143
+ if (type === "number") array.sort (function (a, b) { return a [object [0]][object [1]] - b [object [0]][object [1]]; });
144
+ }
145
+ else {
146
+ if (this.length) if (typeof this [0][sort] === "number") type = "number";
147
+ if (type === "string") array.sort (function (a, b) { return a [sort].localeCompare (b [sort]); });
148
+ if (type === "number") array.sort (function (a, b) { return a [sort] - b [sort]; });
149
+ }
150
+ return array;
151
+ });
152
+
153
+ Define (Array, "config", function (array = {}) {
154
+ if ("page" in array) if ("limit" in array.page) Array.config.page.limit = array.page.limit;
155
+ });
156
+ Define (Array.config, "page", {limit: 20}, {writable: true});
157
+
158
+ /**
159
+ * string
160
+ *
161
+ * title
162
+ * description
163
+ * sub description
164
+ *
165
+ * xxx://xxx.xxx.xxx/xxx
166
+ */
167
+
168
+ Define (String.prototype, "number", function () { return Number (this); });
169
+ Define (String.prototype, "integer", function () { return parseInt (this); });
170
+ Define (String.prototype, "float", function () { return parseFloat (this); });
171
+ Define (String.prototype, "json", function (type = "object") { try { return JSON.parse (this); } catch (e) { return type === "object" ? {} : []; } });
172
+ Define (String.prototype, "clone", function () { return this.trim (); });
173
+ Define (String.prototype, "format", function (format) { var string = this.trim (); for (var i in format) { if (typeof format [i] === "object") for (var x in format [i]) string = string.split (`{{ ${i}:${x} }}`).join (format [i][x]); else string = string.split (`{{ ${i} }}`).join (format [i]); } return string; });
174
+ Define (String.prototype, "param", function (param) { var string = this.trim (); for (var i in param) string = string.split (`:${i}`).join (param [i]); return string; });
175
+ Define (String.prototype, "small", function () { return this.toLowerCase (); });
176
+ Define (String.prototype, "big", function () { return this.toUpperCase (); });
177
+ Define (String.prototype, "first", function (input = 1) { if (typeof input === "number") return this.substr (0, input); else return this.startsWith (input); }); Define (String.prototype, "begin", function (input = 1) { return this.first (input); });
178
+ Define (String.prototype, "last", function (input = 1) { if (typeof input === "number") return this.substr (- input); else return this.endsWith (input); }); Define (String.prototype, "end", function (input = 1) { return this.last (input); });
179
+ Define (String.prototype, "after", function (input, offset) { if ((offset = this.indexOf (input, offset)) >= 0) return this.substr (offset + input.length); else return ""; });
180
+ Define (String.prototype, "before", function (input, offset) { if ((offset = this.indexOf (input, offset)) >= 0) return this.substr (0, offset); else return ""; });
181
+ Define (String.prototype, "pop", function (length = 1) { return this.substr (0, (this.length - length)); });
182
+ Define (String.prototype, "exist", function (input, offset) { return this.includes (input, offset); });
183
+ Define (String.prototype, "reverse", function () { return this.split ("").reverse ().join (""); });
184
+ Define (String.prototype, "join", function (string) { return this + string; });
185
+ Define (String.prototype, "shuffle", function () { return this.split ("").shuffle ().join (""); });
186
+
187
+ Define (String, "char", function () {});
188
+ Define (String.char, "small", "abcdefghijklmnopqrstuvwxyz");
189
+ Define (String.char, "big", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
190
+ Define (String.char, "alpha", {numeric: "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789"});
191
+ Define (String.char, "space", " ");
192
+ Define (String.char, "underscore", "_");
193
+
194
+ /**
195
+ * number
196
+ *
197
+ * title
198
+ * description
199
+ * sub description
200
+ *
201
+ * xxx://xxx.xxx.xxx/xxx
202
+ */
203
+
204
+ Define (Number.prototype, "number", function () { return this; });
205
+ Define (Number.prototype, "integer", function () { return parseInt (this); });
206
+ Define (Number.prototype, "string", function () { return this.toString (); });
207
+ Define (Number.prototype, "shuffle", function (number) { return Math.floor (Math.random () * (number - this + 1)) + this; });
208
+
209
+ Define (Number, "format", function (input, separator = ",") {
210
+ var number = input.toString ().split (""), n = [], x = 0;
211
+ number.reverse ();
212
+ for (var i in number) {
213
+ if (x > 2) if ((x = 0) === 0) n.push (separator);
214
+ x ++;
215
+ n.push (number [i]);
216
+ }
217
+ n.reverse ();
218
+ return n.join ("");
219
+ })
220
+
221
+ /**
222
+ * date
223
+ *
224
+ * title
225
+ * description
226
+ * sub description
227
+ *
228
+ * xxx://xxx.xxx.xxx/xxx
229
+ */
230
+
231
+ Define (Date, "io", class {
232
+ constructor (date) {
233
+ if (date instanceof Date) this.date = date;
234
+ else if (date) this.date = new Date (date);
235
+ else this.date = new Date ();
236
+ }
237
+ iso () { return this.format ("iso"); }
238
+ format (format = "default") {
239
+ var date = {
240
+ "Y": this.year (),
241
+ "M": this.month (), "m": Date.month.name [this.month ()],
242
+ "D": this.day (), "d": Date.day.name [this.week ()], "W": this.week (),
243
+ "H": this.hour (), "h": this.hour ("meredian"),
244
+ "I": this.minute (),
245
+ "S": this.second (),
246
+ "A": this.meredian (),
247
+ }
248
+ format = Date.format [format] || format;
249
+ var formated = format.split ("");
250
+ var result = [];
251
+ for (var i in formated) {
252
+ result.push (date [formated [i]] || formated [i]);
253
+ }
254
+ // for (var i in date) format = format.split (i).join (date [i]);
255
+ return result.join ("");
256
+ }
257
+ year () { return this.date.getFullYear (); }
258
+ month () { return (this.date.getMonth () + 1).toString ().padStart (2, "0"); }
259
+ day () { return this.date.getDate ().toString ().padStart (2, "0"); }
260
+ week () { return (this.date.getDay () || 7).toString ().padStart (2, "0"); }
261
+ hour (meredian) { if (meredian) { var hour = this.date.getHours (); if (this.meredian () === "PM") if (hour === 12) return hour.toString (); else return (hour - 12).toString ().padStart (2, "0"); else return hour.toString ().padStart (2, "0"); } else return this.date.getHours ().toString ().padStart (2, "0"); }
262
+ minute () { return this.date.getMinutes ().toString ().padStart (2, "0"); }
263
+ second () { return this.date.getSeconds ().toString ().padStart (2, "0"); }
264
+ mili () { return this.date.getMilliseconds ().toString ().padStart (3, "0"); }
265
+ meredian () { if (this.date.getHours () > 11) return "PM"; else return "AM"; }
266
+ time () { return this.date.getTime (); }
267
+ stamp () { return this.date; }
268
+ });
269
+
270
+ Define (Date, "format", function (format, date) { return new Date.io (date).format (format); });
271
+ Define (Date.format, "iso", "Y-M-D");
272
+ Define (Date.format, "number", "YMD");
273
+ Define (Date.format, "default", "m D, Y");
274
+ Define (Date.format, "full", "d, m D, Y - h:I:S A");
275
+ Define (Date.format, "monthly", "Y-M");
276
+
277
+ Define (Date, "month", {
278
+ name: {
279
+ 1: "January", "01": "January",
280
+ 2: "February", "02": "February",
281
+ 3: "March", "03": "March",
282
+ 4: "April", "04": "April",
283
+ 5: "May", "05": "May",
284
+ 6: "June", "06": "June",
285
+ 7: "July", "07": "July",
286
+ 8: "August", "08": "August",
287
+ 9: "September", "09": "September",
288
+ 10: "October",
289
+ 11: "November",
290
+ 12: "December",
291
+ },
292
+ });
293
+
294
+ Define (Date, "day", {
295
+ name: {
296
+ 1: "Monday", "01": "Monday",
297
+ 2: "Tuesday", "02": "Tuesday",
298
+ 3: "Wednesday", "03": "Wednesday",
299
+ 4: "Thursday", "04": "Thursday",
300
+ 5: "Friday", "05": "Friday",
301
+ 6: "Saturday", "06": "Saturday",
302
+ 7: "Sunday", "07": "Sunday",
303
+ },
304
+ });
305
+
306
+ Define (Date, "time", function () { return Date.now (); });
307
+ Define (Date.time, "interval", function (context, second = 1) { return setInterval (context, (second * 1000)); });
308
+ Define (Date.time.interval, "clear", function (context) { return clearInterval (context); });
309
+ Define (Date, "timeout", function (context, second = 1) { return setTimeout (context, (second * 1000)); });
310
+ Define (Date.timeout, "clear", function (context) { return clearTimeout (context); });
311
+
312
+ Define (Date, "embed", function () {});
313
+ Define (Date.embed, "format", function (input) { if ((input = parseInt (input)) > 3600) return Date.embed.hour (input); else return Date.embed.minute (input); });
314
+ Define (Date.embed, "hour", function (input) { var hour = Math.floor (input / 3600); var minute = Math.floor ((input % 3600) / 60); var second = input % 60; return `${hour}:${String (minute).padStart(2, "0")}:${String (second).padStart(2, "0")}`; });
315
+ Define (Date.embed, "minute", function (input) { var minute = Math.floor (input / 60); var second = input % 60; return `${String (minute).padStart(2, "0")}:${String (second).padStart(2, "0")}`; });
316
+
317
+ Define (Date, "cookie", function () {
318
+ var date = new Date ();
319
+ return [date.getFullYear (), date.getMonth (), date.getDate (), "--", date.getHours ()].join ("-");
320
+ });
321
+
322
+ /**
323
+ * event
324
+ *
325
+ * title
326
+ * description
327
+ * sub description
328
+ *
329
+ * xxx://xxx.xxx.xxx/xxx
330
+ */
331
+
332
+ Define (Event, "io", class {
333
+ constructor () {
334
+ this.data = Object.create (null);
335
+ }
336
+ on (key, value) {
337
+ if (this.data [key]) this.data [key].push (value);
338
+ else this.data [key] = [value];
339
+ }
340
+ emit (key, ... value) {
341
+ var e;
342
+ for (var i in this.data [key]) {
343
+ e = this.data [key][i] (... value);
344
+ }
345
+ return e;
346
+ }
347
+ });
348
+
349
+ Define (Event, "proto", function (proto) {
350
+ if (proto) {}
351
+ else proto = Object.create (null);
352
+ proto.event = proto.event || Object.create (null);
353
+ proto.on = function (key, value) {
354
+ if (proto.event [key]) proto.event [key].push (value);
355
+ else proto.event [key] = [value];
356
+ }
357
+ proto.emit = function (key, ... value) {
358
+ var e;
359
+ for (var i in proto.event [key]) {
360
+ e = proto.event [key][i] (... value);
361
+ }
362
+ return e;
363
+ }
364
+ });
365
+
366
+ Event.proto (Event);
367
+
368
+ /**
369
+ * promise
370
+ *
371
+ * title
372
+ * description
373
+ * sub description
374
+ *
375
+ * xxx://xxx.xxx.xxx/xxx
376
+ */
377
+
378
+ Define (Promise, "io", function (context) {
379
+ return new Promise (function (resolve, reject) {
380
+ context (function (value = true) { resolve (value); }, function (error = "") { reject (error); });
381
+ });
382
+ });
383
+
384
+ /**
385
+ * url
386
+ *
387
+ * title
388
+ * description
389
+ * sub description
390
+ *
391
+ * xxx://xxx.xxx.xxx/xxx
392
+ */
393
+
394
+ Define (URL, "parse", function (url) {
395
+ var parse_url, result = {
396
+ host: {address: "", name: ""},
397
+ domain: {name: "", base: {name: ""}, sub: "www", extension: ""},
398
+ protocol: "http", port: "", user: "", password: "",
399
+ uri: "", path: "", tag: "",
400
+ queries: {},
401
+ }
402
+ try {
403
+ parse_url = new URL (url);
404
+ var cookie = parse_url.hostname;
405
+ if (cookie === "localhost") {}
406
+ else if (Object.is.ip (cookie)) {}
407
+ else cookie = "." + cookie;
408
+ result.host = {address: parse_url.host, name: parse_url.hostname, cookie}
409
+ result.domain = {name: "", base: {name: ""}, sub: "www", extension: ""}
410
+ result.protocol = parse_url.protocol.pop ();
411
+ result.host.port = parse_url.port ? parse_url.port.integer () : "";
412
+ result.host.user = parse_url.username;
413
+ result.host.password = parse_url.password;
414
+ // result.port = parse_url.port ? parse_url.port.integer () : "";
415
+ // result.user = parse_url.username;
416
+ // result.password = parse_url.password;
417
+ result.uri = parse_url.pathname + parse_url.search;
418
+ result.path = parse_url.pathname;
419
+ result.tag = parse_url.hash;
420
+ result.query = function (key) { return result.queries [key] || ""; }
421
+ result.queries = {}
422
+ var queries = parse_url.search.after ("?").split ("&");
423
+ for (var i in queries) {
424
+ if (queries [i]) {
425
+ var key = queries [i].before ("=");
426
+ var value = queries [i].after ("=");
427
+ if (key) if (value) result.queries [key] = value;
428
+ }
429
+ }
430
+ return result;
431
+ }
432
+ catch (e) {
433
+ return result;
434
+ }
435
+ });
436
+
437
+ Define (URL, "header", function () {});
438
+ Define (URL.header, "status", {
439
+ OK: 200, success: 200,
440
+ error: {request: 400, forbidden: 403, exist: 404, timeout: 408, legal: 451, s: 500},
441
+ code: {
442
+ 100: "Continue", 101: "Switching Protocols", 102: "Processing",
443
+ 200: "OK", 201: "Created", 202: "Accepted", 203: "Non-authoritative Information", 204: "No Content", 205: "Reset Content", 206: "Partial Content", 207: "Multi-Status", 208: "Already Reported", 226: "IM Used",
444
+ 300: "Multiple Choices", 301: "Moved Permanently", 302: "Found", 303: "See Other", 304: "Not Modified", 305: "Use Proxy", 307: "Temporary Redirect", 308: "Permanent Redirect",
445
+ 400: "Bad Request", 401: "Unauthorized", 402: "Payment Required", 403: "Forbidden", 404: "Not Found", 405: "Method Not Allowed", 406: "Not Acceptable", 407: "Proxy Authentication Required", 408: "Request Timeout", 409: "Conflict", 410: "Gone", 411: "Length Required", 412: "Precondition Failed", 413: "Payload Too Large", 414: "Request-URI Too Long", 415: "Unsupported Media Type", 416: "Requested Range Not Satisfiable", 417: "Expectation Failed", 418: "I'm a teapot", 421: "Misdirected Request", 422: "Unprocessable Entity", 423: "Locked", 424: "Failed Dependency", 426: "Upgrade Required", 428: "Precondition Required", 429: "Too Many Requests", 431: "Request Header Fields Too Large", 444: "Connection Closed Without Response", 451: "Unavailable For Legal Reasons", 499: "Client Closed Request",
446
+ 500: "Internal Server Error", 501: "Not Implemented", 502: "Bad Gateway", 503: "Service Unavailable", 504: "Gateway Timeout", 505: "HTTP Version Not Supported", 506: "Variant Also Negotiates", 507: "Insufficient Storage", 508: "Loop Detected", 510: "Not Extended", 511: "Network Authentication Required", 599: "Network Connect Timeout Error",
447
+ 1404: "Host Not Found",
448
+ },
449
+ });
450
+
451
+ Define (URL, "init", function () {
452
+ URL.__ = URL.parse (window.location.href.toString ());
453
+ });
454
+
455
+ Define (URL, "prop", function (key) {
456
+ if (key) return URL.__ [key];
457
+ else return URL.__;
458
+ });
459
+
460
+ Define (URL, "host", {
461
+ name: function () { return URL.prop ("host").name; },
462
+ address: function () { return URL.prop ("host").address; },
463
+ });
464
+
465
+ Define (URL, "referer", function (url) {
466
+ if (url) {
467
+ if (url.startsWith ("//")) URL.referer.data = URL.__.protocol + ":" + url;
468
+ else if (url.startsWith ("/")) URL.referer.data = URL.__.protocol + "://" + URL.__.host.address + url;
469
+ else URL.referer.data = url;
470
+ }
471
+ return URL.referer.data;
472
+ });
473
+
474
+ Define (URL, "query", function (key) {
475
+ return URL.__.query (key);
476
+ });
477
+
478
+ Define (URL.query, "build", function (query) {
479
+ var q = {}, queries = [];
480
+ for (var i in URL.__.queries) q [i] = URL.__.queries [i];
481
+ for (var i in query) q [i] = query [i];
482
+ for (var i in q) queries.push (`${i}=${q [i]}`);
483
+ if (queries.length) return URL.__.path + "?" + queries.join ("&");
484
+ else return URL.__.path;
485
+ });
486
+
487
+ /**
488
+ * json
489
+ *
490
+ * title
491
+ * description
492
+ * sub description
493
+ *
494
+ * xxx://xxx.xxx.xxx/xxx
495
+ */
496
+
497
+ Define (JSON, "pretty", function (json) { return JSON.stringify (json, null, "\t"); });
498
+
499
+ Define (JSON, "token", function () {});
500
+ Define (JSON.token, "parse", function (token) {
501
+ try {
502
+ if ((token = token.split (".")).length !== 3) throw new Error ("Invalid JWT Structure");
503
+ return JSON.parse (decodeURIComponent (atob (token [1].replace (/-/g, "+").replace (/_/g, "/")).split ("").map (function (c) { return "%" + ("00" + c.charCodeAt (0).toString (16)).slice (-2); }).join ("")));
504
+ }
505
+ catch (e) {
506
+ return {}
507
+ }
508
+ });
509
+
510
+ Define (JSON, "db", class {
511
+ constructor (config) {
512
+ this.dir = config.dir;
513
+ this.collection = config.collection || {}
514
+ }
515
+ select (collection) { return new JSON.db.select (this, collection); }
516
+ });
517
+
518
+ Define (JSON.db, "select", class {
519
+ constructor (db, collection) {
520
+ this.db = db;
521
+ this.collection = {name: collection, file: JSON.db.file (collection)}
522
+ if (this.db.collection [this.collection.name]) this.collection.data = this.db.collection [this.collection.name];
523
+ else this.collection.data = JSON.parse (Function.file.read (Function.path.join (this.db.dir, `${this.collection.file}.json`)) || "[]");
524
+ }
525
+ find (filter = {}) {
526
+ var __ = function (db) {
527
+ return new Promise (function (resolve, reject) {
528
+ resolve ({collection: db.collection.name, data: db.collection.data.select (filter)});
529
+ });
530
+ }
531
+ return __ (this);
532
+ }
533
+ });
534
+
535
+ Define (JSON.db, "file", function (key, value) { if (value) return JSON.db.file.object [key] = value; else return JSON.db.file.object [key] || key; });
536
+ Define (JSON.db.file, "object", {});
537
+
538
+ /**
539
+ * function
540
+ *
541
+ * title
542
+ * description
543
+ * sub description
544
+ *
545
+ * xxx://xxx.xxx.xxx/xxx
546
+ */
547
+
548
+ Define (Function, "require", function (... path) { return require (Function.path.join (Function.base_dir (), ... path)); });
549
+ Define (Function, "base_dir", function (base_dir) { if (base_dir) return Function.base_dir.value = base_dir; else return Function.base_dir.value; });
550
+
551
+ Define (Function, "log", function (... log) { if (Function.log.debug) console.log (... log); });
552
+ Define (Function.log, "set", function (value) { return Function.log.debug = value; });
553
+
554
+ /**
555
+ * db
556
+ *
557
+ * title
558
+ * description
559
+ * sub description
560
+ *
561
+ * xxx://xxx.xxx.xxx/xxx
562
+ */
563
+
564
+ Define (Function, "db", function () {});
565
+ Define (Function, "database", function () {});
566
+
567
+ /**
568
+ * cookie
569
+ *
570
+ * title
571
+ * description
572
+ * sub description
573
+ *
574
+ * xxx://xxx.xxx.xxx/xxx
575
+ */
576
+
577
+ Define (Function, "cookie", function () {
578
+ var cookie = document.cookie.split (";").map (function (data) { return data.trim ().split ("="); });
579
+ for (var i in cookie) {
580
+ var key = cookie [i][0], value;
581
+ if (key) {
582
+ value = cookie [i][1].trim ();
583
+ Function.cookie.data [key.trim ()] = value;
584
+ }
585
+ }
586
+ });
587
+
588
+ Define (Function.cookie, "start", function (cookie, option) {
589
+ if (cookie) {
590
+ option = option || {}
591
+ Function.cookie.identity = cookie;
592
+ if (option.host) Function.cookie.host = option.host;
593
+ }
594
+ if (Function.cookie.id ()) {}
595
+ else Function.cookie.set (Function.cookie.identity, Function.unique.id ());
596
+ Event.emit ("cookie:start", Function.cookie.data);
597
+ });
598
+
599
+ Define (Function.cookie, "id", function () {
600
+ return Function.cookie.get (Function.cookie.identity);
601
+ });
602
+
603
+ Define (Function.cookie, "get", function (key) {
604
+ if (key) return Function.cookie.data [key];
605
+ else return Function.cookie.data;
606
+ });
607
+
608
+ Define (Function.cookie, "set", function (key, value, option) {
609
+ option = option || {}
610
+ var content = "";
611
+ if (value === undefined || value === null) {}
612
+ else content = value;
613
+ var cookie = [`${key}=${value}`];
614
+ var expire; if ("expire" in option) cookie.push (expire = `expires=${option.expire}`); // var expire = new Date (); expire.setTime (expire.getTime () + (key ["expire:day"] * 24 * 60 * 60 * 1000)); Function.cookie._expire = expire.toUTCString ();
615
+ var host; if ("host" in option) cookie.push (host = `domain=${option.host}`); else if (Function.cookie.host) cookie.push (host = `domain=${Function.cookie.host}`);
616
+ var path; cookie.push (path = `path=${option.path || '/'}`);
617
+ cookie.push (`samesite=lax`);
618
+ document.cookie = cookie.join (";");
619
+ Function.cookie.data [key] = value;
620
+ return Function.cookie;
621
+ });
622
+
623
+ Define (Function.cookie, "delete", function (key) {
624
+ return Function.cookie.set (key);
625
+ });
626
+
627
+ Function.cookie.identity = "cookie";
628
+ Function.cookie.data = {}
629
+
630
+ /**
631
+ * path
632
+ *
633
+ * title
634
+ * description
635
+ * sub description
636
+ *
637
+ * xxx://xxx.xxx.xxx/xxx
638
+ */
639
+
640
+ Define (Function, "path", function () {});
641
+ Define (Function.path, "require", function () { return Function.path.api = require ("node:path"); });
642
+ Define (Function.path, "join", function (... path) { return Function.path.api.join (... path); });
643
+ Define (Function.path, "exist", function (... path) { return Function.file.api.existsSync (Function.path.api.join (... path)); });
644
+ Define (Function.path, "current", function (path) { return "./" + path; });
645
+
646
+ /**
647
+ * file
648
+ *
649
+ * title
650
+ * description
651
+ * sub description
652
+ *
653
+ * xxx://xxx.xxx.xxx/xxx
654
+ */
655
+
656
+ Define (Function, "file", function () {});
657
+ Define (Function.file, "require", function () { return Function.file.api = require ("node:fs"); });
658
+ Define (Function.file, "write", function (file, data, context) { if (context) return Function.file.api.writeFile (file, data, context); else return Function.file.api.writeFileSync (file, data); });
659
+ Define (Function.file, "read", function (file, context) { if (context) return Function.file.api.readFile (file, context); else return Function.file.api.readFileSync (file); });
660
+ Define (Function.file, "exist", function (file) { return Function.file.api.lstatSync (file).isFile (); });
661
+ Define (Function.file, "extension", {text: ".txt", json: ".json"});
662
+
663
+ Define (Function, "dir", function () {});
664
+ Define (Function.dir, "exist", function (dir) { return Function.file.api.lstatSync (dir).isDirectory (); });
665
+
666
+ /**
667
+ * hash
668
+ *
669
+ * title
670
+ * description
671
+ * sub description
672
+ *
673
+ * xxx://xxx.xxx.xxx/xxx
674
+ */
675
+
676
+ Define (Function, "hash", function () {});
677
+ Define (Function.hash, "require", function () { Function.hash.crypto.api = require ("node:crypto"); });
678
+ Define (Function.hash, "crypto", function () {});
679
+ Define (Function.hash, "md5", function (input) { return Function.hash.crypto.api.createHash ("md5").update (input).digest ("hex"); });
680
+ Define (Function.hash, "sha1", function (input) { return Function.hash.crypto.api.createHash ("sha1").update (input).digest ("hex"); });
681
+ Define (Function.hash, "sha256", function (input) { return Function.hash.crypto.api.createHash ("sha256").update (input).digest ("hex"); });
682
+
683
+ Define (Function, "unique", function () {});
684
+ Define (Function.unique, "shuffle", function (length = 64) { return String.char.alpha.numeric.repeat (16).shuffle ().substr (0, length); });
685
+ Define (Function.unique, "identity", function () { return Function.unique.id ().split ("-") [0]; });
686
+ Define (Function.unique, "id", function () {
687
+ return ("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx").replace (/[xy]/g, function (c) {
688
+ const r = (Math.random () * 16) | 0;
689
+ const v = c === "x" ? r : (r & 0x3) | 0x8;
690
+ return v.toString (16);
691
+ });
692
+ });
693
+
694
+ /**
695
+ * http
696
+ *
697
+ * title
698
+ * description
699
+ * sub description
700
+ *
701
+ * xxx://xxx.xxx.xxx/xxx
702
+ */
703
+
704
+ Define (Function, "http", function () {});
705
+ Define (Function.http, "require", function () { return Function.http.api = require ("node:http"); });
706
+
707
+ /**
708
+ * socket.io
709
+ *
710
+ * title
711
+ * description
712
+ * sub description
713
+ *
714
+ * xxx://xxx.xxx.xxx/xxx
715
+ */
716
+
717
+ Define (Function, "socket", function () {});
718
+ Define (Function.socket, "require", function () { return Function.socket.api = require ("socket.io"); });
719
+ Define (Function.socket, "io", class {});
720
+ Define (Function.socket, "server", function (app, option = {}) {
721
+ var server = Function.http.api.createServer (app);
722
+ option.cors = {
723
+ origin: "*",
724
+ methods: ["GET", "POST"],
725
+ optionsSuccessStatus: 200,
726
+ }
727
+ return {
728
+ instance: server,
729
+ io: new Function.socket.api.Server (server, option),
730
+ }
731
+ });
732
+
733
+ /**
734
+ * asset
735
+ *
736
+ * title
737
+ * description
738
+ * sub description
739
+ *
740
+ * xxx://xxx.xxx.xxx/xxx
741
+ */
742
+
743
+ Define (Function, "asset", function () {});
744
+ Define (Function.asset, "extension", [".ico", ".gif", ".png", ".jpg", ".jpeg"]);
745
+
746
+ /**
747
+ * template
748
+ *
749
+ * title
750
+ * description
751
+ * sub description
752
+ *
753
+ * xxx://xxx.xxx.xxx/xxx
754
+ */
755
+
756
+ Define (Function, "template", function () {});
757
+
758
+ /**
759
+ * theme
760
+ *
761
+ * title
762
+ * description
763
+ * sub description
764
+ *
765
+ * xxx://xxx.xxx.xxx/xxx
766
+ */
767
+
768
+ Define (Function, "theme", function () {});
769
+ Define (Function.theme, "is_light", function () { return ! Function.theme.night (); });
770
+ Define (Function.theme, "is_night", function () { return window.matchMedia && window.matchMedia ("(prefers-color-scheme: dark)").matches; });
771
+
772
+ Define (Function, "html", class {
773
+ constructor () {
774
+ this.markup = new Function.html.markup ("html");
775
+ this.var = {
776
+ title: "Untitled",
777
+ viewport: "width=device-width, initial-scale=1.0, maximum-scale=3.0, user-scalable=1",
778
+ robot: ["index", "follow"],
779
+ rating: "general",
780
+ "google-bot:article": ["index", "follow"],
781
+ google: {font: []},
782
+ link: {style: []},
783
+ error: {},
784
+ }
785
+ }
786
+ title (title) { if (Object.is.set (title)) this.var.title = title; return this.var.title; }
787
+ description (description) { if (Object.is.set (description)) this.var.description = description; return this.var.description; }
788
+ error (error) { if (error) this.var.error = error; return this.var.error; }
789
+ get (key) { return this.var [key]; }
790
+ set (key, value) {
791
+ if (typeof key === "object") for (var i in key) if (key [i] === undefined) {}
792
+ else if (key [i] === null) {}
793
+ else this.var [i] = key [i];
794
+ else if (value === undefined) {}
795
+ else if (value === null) {}
796
+ else this.var [key] = value;
797
+ return this;
798
+ }
799
+ delete (key) {
800
+ delete this.var [key];
801
+ return this;
802
+ }
803
+ render (input = {}) {
804
+ this.set (input);
805
+ this.markup.push (0, "html", {lang: this.var.lang, translate: "no", prefix: "og: http://ogp.me/ns#"});
806
+ this.markup.push (1, "head", {profile: "#"});
807
+ this.markup.push (2, `<title>${this.var.title}</title>`);
808
+ this.markup.push (2, "meta", {"http-equiv": "X-UA-Compatible", content: "IE=edge"});
809
+ this.markup.push (2, "meta", {"http-equiv": "X-Cross-Origin", content: "*"});
810
+ this.markup.push (2, "meta", {charset: "UTF-8"});
811
+ this.markup.push (2, "meta", {name: "author", content: this.var.author});
812
+ this.markup.push (2, "meta", {name: "description", content: this.var.description});
813
+ if (this.var.generator) this.markup.push (2, "meta", {name: "generator", content: this.var.generator});
814
+ this.markup.push (2, "meta", {name: "viewport", content: this.var.viewport});
815
+ this.markup.push (2, "meta", {name: "keywords", content: this.var.keyword});
816
+ this.markup.push (2, "meta", {name: "robots", content: [Function.html.attribute.content (this.var.robot), "max-snippet:-1, max-video-preview:-1, max-image-preview:large"]});
817
+ this.markup.push (2, "meta", {name: "rating", content: this.var.rating});
818
+ this.markup.push (2, "meta", {name: "google", content: "notranslate"});
819
+ this.markup.push (2, "meta", {name: "googlebot", content: "notranslate"});
820
+ this.markup.push (2, "meta", {name: "googlebot-news", content: this.var ["google-bot:article"]});
821
+ if (this.var ["google-site-verification"]) this.markup.push (2, "meta", {name: "google-site-verification", content: this.var ["google-site-verification"]});
822
+ if (this.var ["yandex-verification"]) this.markup.push (2, "meta", {name: "yandex-verification", content: this.var ["yandex-verification"]});
823
+ this.markup.push (2, "meta", {name: "twitter:card", content: "summary_large_image"});
824
+ this.markup.push (2, "meta", {name: "twitter:title", content: this.var.title});
825
+ this.markup.push (2, "meta", {name: "twitter:description", content: this.var.description});
826
+ this.markup.push (2, "meta", {name: "twitter:image", content: this.var ["content:poster"]});
827
+ this.markup.push (2, "meta", {property: "og:site_name", content: this.var.site.name});
828
+ this.markup.push (2, "meta", {property: "og:title", content: this.var.title});
829
+ this.markup.push (2, "meta", {property: "og:description", content: this.var.description});
830
+ this.markup.push (2, "meta", {property: "og:url", content: this.var.canonical});
831
+ if (this.var ["og:image"] || this.var ["content:poster"]) this.markup.push (2, "meta", {property: "og:image", content: this.var ["content:poster"]});
832
+ this.markup.push (2, "meta", {property: "og:type", content: this.var ["og:type"]});
833
+ this.markup.push (2, "meta", {property: "og:locale", content: this.var ["og:locale"]});
834
+ for (var i in this.var.meta) this.markup.push (2, "meta", this.var.meta [i]);
835
+ this.markup.push (2, "link", {rel: "icon", href: this.var ["favorite.ico"]});
836
+ this.markup.push (2, "link", {rel: "canonical", href: this.var.canonical});
837
+ if (this.var ["manifest.json"]) this.markup.push (2, "link", {rel: "manifest", href: this.var ["manifest.json"]});
838
+ if (this.var ["feed.xml"]) this.markup.push (2, "link", {rel: "alternate", href: this.var ["feed.xml"], type: "application/rss+xml", title: `${this.var.site.name} &raquo; Feed`});
839
+ if (this.var ["feed.xml:atom"]) this.markup.push (2, "link", {rel: "alternate", href: this.var ["feed.xml:atom"], type: "application/rss+xml", title: `${this.var.site.name} &raquo; Feed (Atom)`});
840
+ this.markup.push (2, "link", {rel: "dns-prefetch", href: "https://www.google-analytics.com"});
841
+ this.markup.push (2, "link", {rel: "dns-prefetch", href: "https://www.googletagmanager.com"});
842
+ this.markup.push (2, "link", {rel: "preconnect", href: "https://fonts.gstatic.com", crossorigin: "crossorigin"});
843
+ this.markup.push (2, "link", {rel: "preconnect", href: "https://fonts.googleapis.com", crossorigin: "crossorigin"});
844
+ this.markup.push (2, "link", {rel: "stylesheet", href: "https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200"});
845
+ this.markup.push (2, "link", {rel: "stylesheet", href: "https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200"});
846
+ this.markup.push (2, "link", {rel: "stylesheet", href: "https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200"});
847
+ this.markup.push (2, "link", {rel: "stylesheet", href: "https://fonts.googleapis.com/css2?family=Google+Sans+Flex:opsz,slnt,wdth,wght,GRAD,ROND@6..144,-10..0,25..151,1..1000,0..100,0..100&display=swap"});
848
+ this.markup.push (2, "link", {rel: "stylesheet", href: "https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"});
849
+ this.markup.push (2, "link", {rel: "stylesheet", href: "https://fonts.googleapis.com/css2?family=Josefin+Sans:ital,wght@0,100..700;1,100..700&display=swap"});
850
+ for (var i in this.var.google.font) this.markup.push (2, "link", {rel: "stylesheet", href: this.var.google.font [i]});
851
+ for (var i in this.var.link.style) this.markup.push (2, "link", {rel: "stylesheet", href: this.var.link.style [i]});
852
+ this.markup.push (2, "link", {rel: "stylesheet", href: "https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css"});
853
+ this.markup.push (2, "link", {rel: "stylesheet", href: "https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.min.css"});
854
+ if (this.var ["theme:style.css"]) this.markup.push (2, "link", {rel: "stylesheet", href: this.var ["theme:style.css"]});
855
+ this.markup.push (2, "link", {rel: "stylesheet", href: this.var ["vue.css:bundle"]});
856
+ if (this.var ["gtag:id"]) this.markup.push (2, `<script src="https://www.googletagmanager.com/gtag/js?id=${this.var ['gtag:id']}" async></script>`);
857
+ if (false) if (this.var ["google:auth"]) this.markup.push (2, `<script src="https://accounts.google.com/gsi/client" async></script>`);
858
+ this.markup.script (2, {src: "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"});
859
+ this.markup.script (2, {src: "https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"});
860
+ if (this.var ["prototype.js"]) this.markup.script (2, {src: this.var ["prototype.js"]});
861
+ this.markup.push (2, `<script type="module" src="${this.var ['vue.js:bundle']}" crossorigin></script>`);
862
+ this.markup.push (2, `<script type="application/ld+json">{"@context": "https://schema.org", "@type": "WebPage", "name": "${this.var.site.name}", "alternateName": "${this.var ['site:alternate-name']}", "url": "${this.var ['canonical']}", "description": "${this.var ['description']}"}</script>`);
863
+ this.markup.push (2, `<script type="application/ld+json">{"@context": "https://schema.org", "@graph": [{"@type": "website", "@id": "${this.var ['canonical']}", "name": "${this.var.site.name}", "url": "${this.var ['canonical']}", "description": "${this.var ['description']}"}]}</script>`);
864
+ this.markup.push (2, `<script>$.app = function () {}</script>`);
865
+ this.markup.push (2, `<script>$.app.id = "{{ $.app.id }}"</script>`);
866
+ this.markup.push (2, `<script>$.app.var = {{ $.app.var }}</script>`);
867
+ this.markup.push (2, `<script>$.app.document = {{ $.app.document }}</script>`);
868
+ this.markup.push (2, `<script>$.app.theme = {{ $.app.theme }}</script>`);
869
+ this.markup.push (2, `<script>$.app.router = {{ $.app.router }}</script>`);
870
+ this.markup.push (2, `<script>$.app.visitor = {{ $.app.visitor }}</script>`);
871
+ this.markup.push (2, `<script>$.app.cookie = {name: "${this.var.cookie.name}", host: "${this.var.cookie.host}"}</script>`);
872
+ this.markup.push (2, `<script>$.app.error = {{ $.app.error }}</script>`);
873
+ this.markup.push (2, `<script>window.onload = function () {}</script>`);
874
+ if (this.var ["gtag:id"]) this.markup.push (2, `<script>window.dataLayer = window.dataLayer || []; function gtag () { dataLayer.push (arguments); gtag ("js", new Date ()); gtag ("config", "${this.var ['gtag:id']}"); }</script>`);
875
+ this.markup.push (2, `<style>img:is([sizes="auto" i], [sizes^="auto," i]) { contain-intrinsic-size: 3000px 1500px }</style>`);
876
+ this.markup.push (2, `<style>[application] { opacity: 0; }</style>`);
877
+ this.markup.push (1, `</head>`);
878
+ this.markup.push (1, `<body>`);
879
+ this.markup.push (2, `<div id="app">`);
880
+ this.markup.push (3, `<div application>`);
881
+ for (var i in this.heading) {
882
+ var h = parseInt (i) + 1;
883
+ this.markup.push (4, `<h${h}>${this.heading [i]}</h${h}>`);
884
+ }
885
+ this.markup.push (4, `<date>{{ content:date }}</date>`);
886
+ this.markup.push (4, `<p>${this.var ["content:title"] || this.var ["content:paragraph"] || ""}</p>`);
887
+ this.markup.push (4, `<article>${this.var ["content:article"] || this.var.content || this.var ["content:description"] || this.var.description || ""}</article>`);
888
+ if (this.var.anchor) for (var i in this.var.anchor) this.markup.push (4, `<a href="${this.var.anchor [i].url}" title="${this.var.anchor [i].info}">${this.var.anchor [i].name}</a>`);
889
+ this.markup.push (3, `</div>`);
890
+ this.markup.push (2, `</div>`);
891
+ this.markup.push (1, `</body>`);
892
+ this.markup.push (0, `</html>`);
893
+ return this.markup.render ().format (this.var);
894
+ }
895
+ });
896
+
897
+ Define (Function.html, "prop", function (prop) {
898
+ var attribute = "";
899
+ if (typeof prop === "string") attribute = " " + prop.trim ();
900
+ else attribute = " " + prop.join (" ");
901
+ return attribute;
902
+ });
903
+
904
+ Define (Function.html, "attribute", function (attribute) {
905
+ var a = [];
906
+ for (var i in attribute) {
907
+ if (attribute [i] === i) a.push (i);
908
+ else a.push (`${i}="${Function.html.attribute.content (attribute [i])}"`);
909
+ }
910
+ return a.join (" ");
911
+ });
912
+
913
+ Define (Function.html.attribute, "content", function (input) {
914
+ if (Array.isArray (input)) return input.filter (function (input) { if (input) return true; else return false; }).join (", ");
915
+ else if (typeof input === "number") return input;
916
+ else return input || "";
917
+ });
918
+
919
+ Define (Function.html, "markup", class {
920
+ constructor (doc, markup) {
921
+ if (Array.isArray (markup)) this.markup = [... markup];
922
+ else if (doc) if (markup) this.markup = [`<!DOCTYPE ${doc}>`, markup];
923
+ else this.markup = [`<!DOCTYPE ${doc}>`];
924
+ else if (markup) this.markup = [markup];
925
+ else this.markup = [];
926
+ }
927
+ push (tab, tag, attribute, content) {
928
+ if (typeof tab === "string") this.markup.push (tab);
929
+ else {
930
+ if (tag.startsWith ("<")) this.markup.push (("\t").repeat (tab) + tag);
931
+ else {
932
+ var a = Function.html.attribute (attribute);
933
+ if (a) a = " " + a;
934
+ if (content) {
935
+ if (tab) this.markup.push (("\t").repeat (tab) + `<${tag}${a}>${content}</${tag}>`);
936
+ else this.markup.push (`<${tag}${a}>${content}</${tag}>`);
937
+ }
938
+ else {
939
+ if (tab) this.markup.push (("\t").repeat (tab) + `<${tag}${a}>`);
940
+ else this.markup.push (`<${tag}${a}>`);
941
+ }
942
+ }
943
+ }
944
+ return this;
945
+ }
946
+ script (tab, attribute) {
947
+ var a = Function.html.attribute (attribute);
948
+ if (a) a = " " + a;
949
+ if (tab) this.markup.push (("\t").repeat (tab) + `<script${a}></script>`);
950
+ else this.markup.push (`<script${a}></script>`);
951
+ return this;
952
+ }
953
+ render () {
954
+ return this.markup.join ("\n");
955
+ }
956
+ });
957
+
958
+ /**
959
+ * 3rd party
960
+ *
961
+ * title
962
+ * description
963
+ * sub description
964
+ *
965
+ * xxx://xxx.xxx.xxx/xxx
966
+ */
967
+
968
+ /**
969
+ * miscellaneous
970
+ *
971
+ * title
972
+ * description
973
+ * sub description
974
+ *
975
+ * xxx://xxx.xxx.xxx/xxx
976
+ */
977
+
978
+ Define (Function, "help", function () {});
979
+
980
+ Define (Function.help, "argument", function () {
981
+ var result = {string: "", number: 0}
982
+ for (var i in arguments) {
983
+ if (typeof arguments [i] === "string") result.string = arguments [i];
984
+ else if (typeof arguments [i] === "number") result.number = arguments [i];
985
+ }
986
+ return result;
987
+ });
988
+
989
+ Function.ajax = function () {}
990
+
991
+ Function.ajax.config = function (key, value) {
992
+ return Function.ajax.config [key] = value;
993
+ }
994
+
995
+ Function.ajax.url = function (url) {
996
+ if (Function.ajax) {
997
+ if (url.startsWith ("/") === false) url = "/" + url;
998
+ if (Function.ajax.config.host) return Function.ajax.config.host + url;
999
+ else return url;
1000
+ }
1001
+ else {
1002
+ if (typeof url === "string") {}
1003
+ else {
1004
+ if (url.host) if (Function.ajax.config.host) url = Function.ajax.config.host + url.path;
1005
+ else url = url.url || url.path;
1006
+ else url = url.url || url.path;
1007
+ }
1008
+ return url;
1009
+ }
1010
+ }
1011
+
1012
+ Function.ajax.get = function (url, context) {
1013
+ url = Function.ajax.url (url);
1014
+ return $.ajax ({
1015
+ url,
1016
+ headers: {ajax: Function.ajax.id (), reference: URL.referer ()},
1017
+ success (ajax) {
1018
+ if (typeof ajax === "object") {}
1019
+ else ajax = {}
1020
+ if (context.success) context.success ({}, ajax);
1021
+ URL.referer (url);
1022
+ },
1023
+ error (error) {
1024
+ if (context.error) context.error (error.responseJSON || {});
1025
+ },
1026
+ });
1027
+ }
1028
+
1029
+ Function.ajax.post = function (url, data, context) {
1030
+ url = Function.ajax.url (url);
1031
+ return $.ajax ({
1032
+ url,
1033
+ headers: {ajax: Function.ajax.id (), reference: URL.referer ()},
1034
+ data: JSON.stringify (data),
1035
+ type: "POST",
1036
+ dataType: "json",
1037
+ success (ajax) {
1038
+ if (typeof ajax === "object") {}
1039
+ else ajax = {}
1040
+ if (context.success) context.success ({}, ajax);
1041
+ URL.referer (url);
1042
+ },
1043
+ error (error) {
1044
+ if (context.error) context.error (error.responseJSON || {});
1045
+ },
1046
+ });
1047
+ }
1048
+
1049
+ Function.ajax.id = function () {
1050
+ return Function.unique.id () || Function.cookie.get ("ajax");
1051
+ }
1052
+
1053
+ Define (Function, "google", function () {});
1054
+ Define (Function.google, "account", function (id) { google.accounts.id.initialize ({client_id: id, callback: Function.google.account.context}); });
1055
+ Define (Function.google.account, "gateway", function (url) { if (url) return Function.google.account.gateway.url = url; else return Function.google.account.gateway.url; }); Function.google.account.gateway ("/cgi-bin/3rd-party/google-auth");
1056
+ Define (Function.google.account, "redirect", function (url) { if (url) return Function.google.account.redirect.url = url; else return Function.google.account.redirect.url; }); Function.google.account.redirect ("/");
1057
+ Define (Function.google.account, "button", function (element, context) { google.accounts.id.renderButton (document.getElementById (element), {theme: "filled_blue", size: "medium", shape: "circle", text: "continue_with", click_listener: context || function () {}}); });
1058
+ Define (Function.google.account.button, "icon", function (element) { google.accounts.id.renderButton (document.getElementById (element), {type: "icon", theme: "outline", size: "large"}); });
1059
+ Define (Function.google.account, "sign", function () {});
1060
+ Define (Function.google.account.sign, "out", function () { google.accounts.id.disableAutoSelect (); });
1061
+ Define (Function.google.account, "context", function (token) {
1062
+ Function.ajax.post (Function.google.account.gateway.url, {credential: JSON.token.parse (token.credential)}, {
1063
+ success (ajax) {
1064
+ if (ajax.success) if (Function.google.account.redirect.url) location.href = Function.google.account.redirect.url + "?sign_in";
1065
+ else location.reload ();
1066
+ },
1067
+ error (error) {},
1068
+ });
1069
+ });
1070
+ Define (Function.google, "icon", function (icon) { if (Function.google.icon.src [icon]) return "&#x" + Function.google.icon.src [icon] + ";"; else return "XXXXXXXXXXXX"; });
1071
+ Define (Function.google.icon, "src", {
1072
+ home: "e88a", home_app: "e295", home_storage: "f86c", home_lot_device: "e283",
1073
+ archive: "e149", article: "ef42",
1074
+ folder: "e2c7", folder_off: "eb83",
1075
+ bookmark: "e866", bookmark_star: "f454",
1076
+ notification: "e7f4", notification_unread: "f4fe", notification_audio: "eec1", notification_setting: "f367",
1077
+ chat: "e0b7", chat_unread: "f189", chat_error: "f7ac",
1078
+ check: "e5ca", check_circle: "e86c",
1079
+ lock: "e897", lock_clock: "ef57",
1080
+ visibility: "e8f4", visibility_off: "e8f5", visibility_lock: "f653",
1081
+ thumb_up: "e8dc", thumb_up_double: "eefc", thumb_down: "e8db",
1082
+ shield: "e9e0", shield_lock: "f686", shield_locked: "f592", shield_toggle: "f2ad", shield_watch: "f30f",
1083
+ arrow_circle_down: "f181", arrow_drop_down: "e5c5",
1084
+ menu: "e5d2", more: "e619", more_vertical: "e5d4", more_horizontal: "e5d3",
1085
+ delete: "e872", delete_auto: "ea4c", delete_forever: "e92b",
1086
+ download: "f090", downloading: "f001", cloud_download: "e2c0", cloud_upload: "e2c3",
1087
+ calendar_clock: "f540", calendar_check: "f243", calendar_today: "e935", calendar_lock: "f242",
1088
+ globe: "e64c", globe_asia: "f799",
1089
+ local_activity: "e53f", local_fire_department: "ef55",
1090
+ image: "e3f4", animated_image: "f49a",
1091
+ photo: "e410", photo_camera: "e412",
1092
+ star: "e838", star_s: "f31c",
1093
+ male: "e58e", female: "e590", transgender: "e58d",
1094
+ arrow_left_alt: "ef7d", arrow_right_alt: "e941",
1095
+ light_bulb: "e0f0", light_bulb_x: "f3e3",
1096
+ theater: "e8da", movie: "e02c", play_circle: "e1c4", play_arrow: "e037",
1097
+ tv: "e333", tv_guide: "e1dc", live_tv: "e639",
1098
+ close: "e5cd",
1099
+ cookie: "eaac",
1100
+ file_video: "eb87",
1101
+ mobile_vibrate: "f2cb",
1102
+ admin_panel_setting: "ef3d",
1103
+ cloud_lock: "f386",
1104
+ comedy_mask: "f4d6",
1105
+ encrypted: "e593",
1106
+ fingerprint: "e90d",
1107
+ health_safety: "e1d5",
1108
+ security: "e32a",
1109
+ recpmend: "e9d2",
1110
+ keep: "e6aa",
1111
+ favorite: "e87d",
1112
+ heart_broken: "eac2",
1113
+ password: "f042",
1114
+ person_shield: "e384",
1115
+ verified_user: "e8e8",
1116
+ supervisor_account: "e8d3",
1117
+ visibility: "e8f4",
1118
+ id_card: "e8f4",
1119
+ passkey: "f87f",
1120
+ circle: "ef4a",
1121
+ dns: "e875",
1122
+ eco: "ea35",
1123
+ explore: "e87a",
1124
+ share_location: "f05f",
1125
+ search: "e8b6",
1126
+ sms: "e625",
1127
+ subscription: "e064",
1128
+ editor_choice: "f528",
1129
+ search_activity: "f3e5",
1130
+ timer_play: "f4ba",
1131
+ playlist_play: "e05f",
1132
+ hotel_class: "e743",
1133
+ description: "e873",
1134
+ contact: "e0ba",
1135
+ link: "e157",
1136
+ health_and_safety: "e1d5",
1137
+ setting_accessibility: "f05d",
1138
+ safety_check: "ebef",
1139
+ admin_panel_setting: "ef3d",
1140
+ rss_feed: "e0e5",
1141
+ setting: "e8b8",
1142
+ recycling: "e760",
1143
+ key: "e73c",
1144
+ chart_show: "e6e1",
1145
+ trending_up: "e8e5",
1146
+ auto_read_play: "f216",
1147
+ smart_display: "f06a",
1148
+ crown: "ecb3",
1149
+ trophy: "e71a",
1150
+ review: "f054",
1151
+ workspace_premium: "e7af",
1152
+ card_star: "f375",
1153
+ acute: "e4cb",
1154
+ person: "e7fd",
1155
+ event: "e878",
1156
+ date_range: "e916",
1157
+ chronic: "ebb2",
1158
+ sticker: "e707",
1159
+ flash_on: "e3e7",
1160
+ trail_length_short: "eb6d",
1161
+ slide_show: "e41b",
1162
+ bolt: "ea0b",
1163
+ speed: "e9e4",
1164
+ rocket: "eba5",
1165
+ });
1166
+
1167
+ Function.owl = function () {}
1168
+ Function.owl.carousel = function (element, reference, option) {
1169
+ option = option || {}
1170
+ var padding = option.padding || 0;
1171
+ var setting = {
1172
+ onTranslated: option ["on:translate"] || function () {},
1173
+ gap: (option.gap || 0),
1174
+ loop: (option.loop || false),
1175
+ center: (option.center || false),
1176
+ nav: (option.nav || false), dots: (option ["nav:dot"] || false),
1177
+ autoplay: (option.play === "auto" || option.play || false),
1178
+ margin: (option.margin || 10),
1179
+ autoWidth: (option.width === "auto" || false),
1180
+ stagePadding: (option ["stage:padding"] || 0),
1181
+ autoplayTimeout: (option.timeout || 10000),
1182
+ autoplayHoverPause: true,
1183
+ responsive: option.responsive || Function.owl.carousel ["item:default"],
1184
+ }
1185
+ var el = $ (element).removeClass ("none");
1186
+ if (el) {
1187
+ if (reference) el.width ($ (reference).width () - setting.gap - padding);
1188
+ el.owlCarousel (setting);
1189
+ }
1190
+ }
1191
+
1192
+ Function.owl.carousel ["item:default"] = {
1193
+ 0: {items: 1},
1194
+ 600: {items: 3},
1195
+ 1000: {items: 5},
1196
+ }
1197
+
1198
+ Function.owl.carousel ["item:pop"] = {
1199
+ 0: {items: 2},
1200
+ 600: {items: 4},
1201
+ 1000: {items: 6},
1202
+ }
1203
+
1204
+ Function.owl.carousel ["item:best"] = {
1205
+ 0: {items: 1},
1206
+ 600: {items: 2},
1207
+ 1000: {items: 3},
1208
+ }
1209
+
1210
+ Function.owl.carousel ["item:sky"] = {
1211
+ 0: {items: 1},
1212
+ 600: {items: 3},
1213
+ 1000: {items: 4},
1214
+ }
1215
+
1216
+ Function.owl.carousel ["wide"] = {
1217
+ 0: {items: 1},
1218
+ 600: {items: 3},
1219
+ 1000: {items: 3},
1220
+ }
1221
+
1222
+ Function.owl.carousel ["relation"] = {
1223
+ 0: {items: 2},
1224
+ 600: {items: 3},
1225
+ 1000: {items: 3},
1226
+ }
1227
+
1228
+ Function.owl.carousel ["short"] = {
1229
+ 0: {items: 2},
1230
+ 600: {items: 4},
1231
+ 1000: {items: 6},
1232
+ }
1233
+
1234
+ Function.owl.carousel ["flash"] = {
1235
+ 0: {items: 2},
1236
+ 600: {items: 4},
1237
+ 1000: {items: 6},
1238
+ }
1239
+
1240
+ /**
1241
+ * xxx
1242
+ *
1243
+ * title
1244
+ * description
1245
+ * sub description
1246
+ *
1247
+ * xxx://xxx.xxx.xxx/xxx
1248
+ */
1249
+
1250
+ Function.body = function () { Function.body.width = $ ("body").width (); }
1251
+ Function.body.css = function () {
1252
+ var type = "phone";
1253
+ var type_of = "mobile";
1254
+ var orientation = "portrait";
1255
+ var body = $ ("body").innerWidth ();
1256
+ if (body > 600) { type = "tablet"; type_of = "mobile"; }
1257
+ if (body > 1000) { type = "computer"; type_of = ""; }
1258
+ if ($ ("body").width () > $ ("body").height ()) orientation = "landscape";
1259
+ if (Function.device.type || Function.device.orientation) {
1260
+ if (Function.device.type === type && Function.device.orientation === orientation) {}
1261
+ else Function.body.css.reset (type, type_of, orientation);
1262
+ }
1263
+ else Function.body.css.reset (type, type_of, orientation);
1264
+ }
1265
+ Function.body.css.reset = function (type, type_of, orientation) {
1266
+ $ ("body").removeClass ("computer mobile tablet phone portrait landscape");
1267
+ $ ("body").addClass (Function.device.type = type).addClass (Function.device.orientation = orientation);
1268
+ if (type_of) $ ("body").addClass (Function.device.type_of = type_of);
1269
+ Event.emit ("body:css", type, type_of, orientation);
1270
+ }
1271
+
1272
+ Function.device = function () {}
1273
+
1274
+ /**
1275
+ * jQuery
1276
+ *
1277
+ * title
1278
+ * description
1279
+ * sub description
1280
+ *
1281
+ * xxx://xxx.xxx.xxx/xxx
1282
+ */
1283
+
1284
+ Function.jQuery = function () {
1285
+ $.meta = function () {}
1286
+ $.meta.get = function (meta) {
1287
+ for (var i in meta) {
1288
+ var element = document.querySelector ("meta[" + i + "='" + meta [i] + "']");
1289
+ if (element) return element.content;
1290
+ }
1291
+ }
1292
+ $.element = function () {}
1293
+ $.element.show = function (element) { return Function.element.show (element); }
1294
+ $.element.hide = function (element) { return Function.element.hide (element); }
1295
+ }
1296
+
1297
+ Function.element = function () {}
1298
+ Function.element.show = function (element) { return $ (element).removeClass ("none").addClass ("flex"); }
1299
+ Function.element.hide = function (element) { return $ (element).removeClass ("flex").addClass ("none"); }
1300
+
1301
+ /**
1302
+ * xxx
1303
+ *
1304
+ * title
1305
+ * description
1306
+ * sub description
1307
+ *
1308
+ * xxx://xxx.xxx.xxx/xxx
1309
+ */
1310
+
1311
+ Symbol.export = {
1312
+ define: Object.define, un_define: Object.un_define, un_set: Object.un_set,
1313
+ object: Object, array: Array, string: String, number: Number, function: Function,
1314
+ date: Date, time: Date.time, timeout: Date.timeout, datetime: new Date.io,
1315
+ event: Event, promise: Promise,
1316
+ url: URL, path: Function.path, file: Function.file, dir: Function.dir,
1317
+ db: Function.db, database: Function.database,
1318
+ cookie: Function.cookie, session: Function.session, ls: Function.ls,
1319
+ markup: Function.markup, html: Function.html, css: Function.css, js: Function.js, json: JSON, xml: Function.xml, serialize: Function.serialize,
1320
+ help: Function.help, log: Function.log,
1321
+ hash: Function.hash, unique: Function.unique,
1322
+ socket: Function.socket, ajax: Function.ajax,
1323
+ require: Function.require, base_dir: Function.base_dir,
1324
+ layout: Function.layout, component: Function.component, element: Function.element,
1325
+ google: Function.google,
1326
+ body: Function.body,
1327
+ owl: Function.owl,
1328
+ is: Object.is, parse_url: URL.parse,
1329
+ asset: Function.asset, theme: Function.theme,
1330
+ zero: 0, one: 1,
1331
+ }
1332
+
1333
+ var JScript = Symbol.export;
1334
+
1335
+ /**
1336
+ * the end
1337
+ *
1338
+ * xxx://xxx.xxx.xxx/xxx
1339
+ */