script.io.js 2026.123.955 → 2026.124.357
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/node_packages/script.js +499 -82
- package/package.json +1 -1
package/node_packages/script.js
CHANGED
|
@@ -59,6 +59,8 @@ Define (Object.type_of, "promise", function (input) { if (arguments.length) retu
|
|
|
59
59
|
Define (Object.type_of, "regex", function (input) { if (arguments.length) return Object.type_of (input) === "[object RegExp]"; else return "[object RegExp]"; });
|
|
60
60
|
Define (Object.type_of, "string", function (input) { if (arguments.length) return Object.type_of (input) === "[object String]"; else return "[object String]"; });
|
|
61
61
|
|
|
62
|
+
Define (Object, "length", function (object) { return Object.keys (object).length; });
|
|
63
|
+
|
|
62
64
|
/**
|
|
63
65
|
* array
|
|
64
66
|
*
|
|
@@ -71,14 +73,16 @@ Define (Object.type_of, "string", function (input) { if (arguments.length) retur
|
|
|
71
73
|
|
|
72
74
|
Define (Array.prototype, "json", function () { return JSON.pretty (this); });
|
|
73
75
|
Define (Array.prototype, "clone", function () { return JSON.parse (JSON.stringify (this)); });
|
|
74
|
-
Define (Array.prototype, "exist", function (
|
|
76
|
+
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); });
|
|
75
77
|
Define (Array.prototype, "first", function () { for (var i in this) return this [i]; return undefined; }); Define (Array.prototype, "one", function () { return this.first (); });
|
|
76
78
|
Define (Array.prototype, "last", function () { var value; for (var i in this) value = this [i]; return value; });
|
|
79
|
+
Define (Array.prototype, "max", function () { return Math.max (... this); });
|
|
80
|
+
Define (Array.prototype, "min", function () { return Math.min (... this); });
|
|
77
81
|
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; });
|
|
78
82
|
Define (Array.prototype, "limit", function (limit) { return this.clone ().slice (0, limit); });
|
|
79
83
|
Define (Array.prototype, "page", function (page, limit) { return this.clone ().slice (((page - 1) * (limit || Array.config.page.limit)), (page * (limit || Array.config.page.limit))); });
|
|
80
84
|
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; } }); });
|
|
81
|
-
Define (Array.prototype, "implode", function (
|
|
85
|
+
Define (Array.prototype, "implode", function (data) { var array = this.clone (); array.push (... data); return array; });
|
|
82
86
|
|
|
83
87
|
Define (Array.prototype, "select", function (filter) {
|
|
84
88
|
return this.filter (function (array, index) {
|
|
@@ -150,6 +154,14 @@ Define (String.prototype, "pop", function (length = 1) { return this.substr (0,
|
|
|
150
154
|
Define (String.prototype, "exist", function (input, offset) { return this.includes (input, offset); });
|
|
151
155
|
Define (String.prototype, "reverse", function () { return this.split ("").reverse ().join (""); });
|
|
152
156
|
Define (String.prototype, "join", function (string) { return this + string; });
|
|
157
|
+
Define (String.prototype, "shuffle", function () { return this.split ("").shuffle ().join (""); });
|
|
158
|
+
|
|
159
|
+
Define (String, "char", function () {});
|
|
160
|
+
Define (String.char, "small", "abcdefghijklmnopqrstuvwxyz");
|
|
161
|
+
Define (String.char, "big", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
|
162
|
+
Define (String.char, "alpha", {numeric: "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789"});
|
|
163
|
+
Define (String.char, "space", " ");
|
|
164
|
+
Define (String.char, "underscore", "_");
|
|
153
165
|
|
|
154
166
|
/**
|
|
155
167
|
* number
|
|
@@ -161,6 +173,23 @@ Define (String.prototype, "join", function (string) { return this + string; });
|
|
|
161
173
|
* xxx://xxx.xxx.xxx/xxx
|
|
162
174
|
*/
|
|
163
175
|
|
|
176
|
+
Define (Number.prototype, "number", function () { return this; });
|
|
177
|
+
Define (Number.prototype, "integer", function () { return parseInt (this); });
|
|
178
|
+
Define (Number.prototype, "string", function () { return this.toString (); });
|
|
179
|
+
Define (Number.prototype, "shuffle", function (number) { return Math.floor (Math.random () * (number - this + 1)) + this; });
|
|
180
|
+
|
|
181
|
+
Define (Number, "format", function (input, separator = ",") {
|
|
182
|
+
var number = input.toString ().split (""), n = [], x = 0;
|
|
183
|
+
number.reverse ();
|
|
184
|
+
for (var i in number) {
|
|
185
|
+
if (x > 2) if ((x = 0) === 0) n.push (separator);
|
|
186
|
+
x ++;
|
|
187
|
+
n.push (number [i]);
|
|
188
|
+
}
|
|
189
|
+
n.reverse ();
|
|
190
|
+
return n.join ("");
|
|
191
|
+
})
|
|
192
|
+
|
|
164
193
|
/**
|
|
165
194
|
* date
|
|
166
195
|
*
|
|
@@ -171,10 +200,83 @@ Define (String.prototype, "join", function (string) { return this + string; });
|
|
|
171
200
|
* xxx://xxx.xxx.xxx/xxx
|
|
172
201
|
*/
|
|
173
202
|
|
|
203
|
+
Define (Date, "io", class {
|
|
204
|
+
constructor (date) {
|
|
205
|
+
if (date instanceof Date) this.date = date;
|
|
206
|
+
else if (date) this.date = new Date (date);
|
|
207
|
+
else this.date = new Date ();
|
|
208
|
+
}
|
|
209
|
+
string () { return this.format ("string"); }
|
|
210
|
+
format (format = "default") {
|
|
211
|
+
var date = {
|
|
212
|
+
"Y": this.year (),
|
|
213
|
+
"M": this.month (), "m": Date.month.name [this.month ()],
|
|
214
|
+
"D": this.day (), "d": Date.month.name [this.week ()], "W": this.week (),
|
|
215
|
+
"H": this.hour (), "h": this.hour ("meredian"),
|
|
216
|
+
"I": this.minute (),
|
|
217
|
+
"S": this.second (),
|
|
218
|
+
"A": this.meredian (),
|
|
219
|
+
}
|
|
220
|
+
format = Date.format [format] || format;
|
|
221
|
+
for (var i in date) format = format.split (i).join (date [i]);
|
|
222
|
+
return format;
|
|
223
|
+
}
|
|
224
|
+
year () { return this.date.getFullYear (); }
|
|
225
|
+
month () { return (this.date.getMonth () + 1).toString ().padStart (2, "0"); }
|
|
226
|
+
day () { return this.date.getDate ().toString ().padStart (2, "0"); }
|
|
227
|
+
week () { return this.date.getDay ().toString ().padStart (2, "0"); }
|
|
228
|
+
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"); }
|
|
229
|
+
minute () { return this.date.getMinutes ().toString ().padStart (2, "0"); }
|
|
230
|
+
second () { return this.date.getSeconds ().toString ().padStart (2, "0"); }
|
|
231
|
+
mili () { return this.date.getMilliseconds ().toString ().padStart (3, "0"); }
|
|
232
|
+
meredian () { if (this.date.getHours () > 11) return "PM"; else return "AM"; }
|
|
233
|
+
time () { return this.date.getTime (); }
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
Define (Date, "format", function (format, date) { return new Date.io (date).format (format); });
|
|
237
|
+
Define (Date.format, "string", "Y-M-D");
|
|
238
|
+
Define (Date.format, "number", "YMD");
|
|
239
|
+
Define (Date.format, "default", "m D, Y");
|
|
240
|
+
Define (Date.format, "full", "d, m D, Y - h:I:S A");
|
|
241
|
+
|
|
242
|
+
Define (Date, "month", {
|
|
243
|
+
name: {
|
|
244
|
+
1: "January", "01": "January",
|
|
245
|
+
2: "February", "02": "February",
|
|
246
|
+
3: "March", "03": "March",
|
|
247
|
+
4: "April", "04": "April",
|
|
248
|
+
5: "May", "05": "May",
|
|
249
|
+
6: "June", "06": "June",
|
|
250
|
+
7: "July", "07": "July",
|
|
251
|
+
8: "August", "08": "August",
|
|
252
|
+
9: "September", "09": "September",
|
|
253
|
+
10: "October",
|
|
254
|
+
11: "November",
|
|
255
|
+
12: "December",
|
|
256
|
+
},
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
Define (Date, "day", {
|
|
260
|
+
name: {
|
|
261
|
+
1: "Monday", "01": "Monday",
|
|
262
|
+
2: "Tuesday", "02": "Tuesday",
|
|
263
|
+
3: "Wednesday", "03": "Wednesday",
|
|
264
|
+
4: "Thursday", "04": "Thursday",
|
|
265
|
+
5: "Friday", "05": "Friday",
|
|
266
|
+
6: "Saturday", "06": "Saturday",
|
|
267
|
+
7: "Sunday", "07": "Sunday",
|
|
268
|
+
},
|
|
269
|
+
});
|
|
270
|
+
|
|
174
271
|
Define (Date, "time", function () { return Date.now (); });
|
|
175
272
|
Define (Date, "timeout", function (context, second = 1) { return setTimeout (context, (second * 1000)); });
|
|
176
273
|
Define (Date.timeout, "clear", function (context) { return clearTimeout (context); });
|
|
177
274
|
|
|
275
|
+
Define (Date, "embed", function () {});
|
|
276
|
+
Define (Date.embed, "format", function (input) { if ((input = parseInt (input)) > 3600) return Date.embed.hour (input); else return Date.embed.minute (input); });
|
|
277
|
+
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")}`; });
|
|
278
|
+
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")}`; });
|
|
279
|
+
|
|
178
280
|
/**
|
|
179
281
|
* event
|
|
180
282
|
*
|
|
@@ -291,6 +393,67 @@ Define (URL.header, "status", {
|
|
|
291
393
|
},
|
|
292
394
|
});
|
|
293
395
|
|
|
396
|
+
/**
|
|
397
|
+
* cookie
|
|
398
|
+
*
|
|
399
|
+
* title
|
|
400
|
+
* description
|
|
401
|
+
* sub description
|
|
402
|
+
*
|
|
403
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
404
|
+
*/
|
|
405
|
+
|
|
406
|
+
Function.cookie = function (key, value) {
|
|
407
|
+
var cookie = document.cookie.split (";").map (function (data) { return data.trim ().split ("="); });
|
|
408
|
+
for (var i in cookie) {
|
|
409
|
+
var key = cookie [i][0], value;
|
|
410
|
+
if (key) {
|
|
411
|
+
value = cookie [i][1].trim ();
|
|
412
|
+
Function.cookie.data [key.trim ()] = value;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
Function.cookie.get = function (key) {
|
|
418
|
+
if (key) return Function.cookie.data [key];
|
|
419
|
+
else return Function.cookie.get (Function.cookie.identity);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
Function.cookie.delete = function (key) {
|
|
423
|
+
Function.cookie.set (key);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
Function.cookie.set = function (key, value = "", expire = 0, domain = null, path = "/") {
|
|
427
|
+
if (typeof key === "string") {
|
|
428
|
+
if (expire === null) expire = Function.cookie._expire;
|
|
429
|
+
domain = domain || Function.cookie._domain;
|
|
430
|
+
document.cookie = `${key}=${value};expires=${expire};domain=${domain};path=/;samesite=lax`;
|
|
431
|
+
Function.cookie.data [key] = value;
|
|
432
|
+
}
|
|
433
|
+
else {
|
|
434
|
+
if ("domain" in key) Function.cookie._domain = key.domain;
|
|
435
|
+
if ("expire:day" in key) {
|
|
436
|
+
var expire = new Date ();
|
|
437
|
+
expire.setTime (expire.getTime () + (key ["expire:day"] * 24 * 60 * 60 * 1000));
|
|
438
|
+
Function.cookie._expire = expire.toUTCString ();
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
Function.cookie.start = function (visitor) {
|
|
444
|
+
if (Function.cookie.get (Function.cookie.identity)) {}
|
|
445
|
+
else Function.cookie.set (Function.cookie.identity, Function.unique.id ());
|
|
446
|
+
if (visitor) Function.visitor.cookie (visitor.ip.address, visitor.country.code, visitor.agent);
|
|
447
|
+
Event.emit ("cookie:start", visitor);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
Function.cookie.id = function () {
|
|
451
|
+
return Function.cookie.get (Function.cookie.identity);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
Function.cookie.identity = "cookie";
|
|
455
|
+
Function.cookie.data = {}
|
|
456
|
+
|
|
294
457
|
/**
|
|
295
458
|
* json
|
|
296
459
|
*
|
|
@@ -331,6 +494,17 @@ Define (JSON.db, "select", class {
|
|
|
331
494
|
Define (JSON.db, "file", function (key, value) { if (value) return JSON.db.file.object [key] = value; else return JSON.db.file.object [key] || key; });
|
|
332
495
|
Define (JSON.db.file, "object", {});
|
|
333
496
|
|
|
497
|
+
Define (JSON, "token", function () {});
|
|
498
|
+
Define (JSON.token, "parse", function (token) {
|
|
499
|
+
try {
|
|
500
|
+
if ((token = token.split (".")).length !== 3) throw new Error ("Invalid JWT Structure");
|
|
501
|
+
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 ("")));
|
|
502
|
+
}
|
|
503
|
+
catch (e) {
|
|
504
|
+
return {}
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
|
|
334
508
|
/**
|
|
335
509
|
* path
|
|
336
510
|
*
|
|
@@ -376,65 +550,6 @@ Define (Function.hash, "require", function () { Function.hash.crypto.api = requi
|
|
|
376
550
|
Define (Function.hash, "crypto", function () {});
|
|
377
551
|
Define (Function.hash, "md5", function (input) { return Function.hash.crypto.api.createHash ("md5").update (input).digest ("hex"); });
|
|
378
552
|
|
|
379
|
-
/**
|
|
380
|
-
* appwrite
|
|
381
|
-
*
|
|
382
|
-
* title
|
|
383
|
-
* description
|
|
384
|
-
* sub description
|
|
385
|
-
*
|
|
386
|
-
* xxx://xxx.xxx.xxx/xxx
|
|
387
|
-
*/
|
|
388
|
-
|
|
389
|
-
Define (Function, "appwrite", function () {});
|
|
390
|
-
Define (Function.appwrite, "require", function () { return Function.appwrite.api = require ("node-appwrite"); });
|
|
391
|
-
|
|
392
|
-
Define (Function.appwrite, "db", class {
|
|
393
|
-
constructor (config, json) {
|
|
394
|
-
this.config = config;
|
|
395
|
-
this.client = new Function.appwrite.api.Client ().setEndpoint (this.config.host).setProject (this.config.project);
|
|
396
|
-
this.json = json || {}
|
|
397
|
-
if (this.config.collection) for (var i in this.config.collection) Function.appwrite.db.collection (i, this.config.collection [i]);
|
|
398
|
-
}
|
|
399
|
-
select (collection) { return new Function.appwrite.db.select (this, collection); }
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
Define (Function.appwrite.db, "select", class {
|
|
403
|
-
constructor (db, collection) {
|
|
404
|
-
this.db = db;
|
|
405
|
-
this.collection = {name: collection, id: Function.appwrite.db.collection (collection), json: this.db.json [collection] || []}
|
|
406
|
-
}
|
|
407
|
-
find (filter) {
|
|
408
|
-
var id;
|
|
409
|
-
if (typeof filter !== "object") filter = {id: (id = filter)}
|
|
410
|
-
var __ = function (db) {
|
|
411
|
-
return new Promise (async function (resolve, reject) {
|
|
412
|
-
var error = false;
|
|
413
|
-
var database, result, queries;
|
|
414
|
-
if (id) queries = [Function.appwrite.api.Query.limit (1)]
|
|
415
|
-
else queries = [Function.appwrite.api.Query.limit (5000)]
|
|
416
|
-
try {
|
|
417
|
-
database = new Function.appwrite.api.Databases (db.db.client);
|
|
418
|
-
result = await database.listDocuments ({
|
|
419
|
-
databaseId: db.db.config.id,
|
|
420
|
-
collectionId: db.collection.id,
|
|
421
|
-
queries,
|
|
422
|
-
total: true,
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
catch (e) { error = true; }
|
|
426
|
-
var data = result.documents.map (function (data) { return data; }).select (filter);
|
|
427
|
-
data = db.collection.json.select (filter).implode (data);
|
|
428
|
-
resolve ({error, data});
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
return __ (this);
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
|
|
435
|
-
Define (Function.appwrite.db, "collection", function (key, value) { if (value) return Function.appwrite.db.collection.object [key] = value; else return Function.appwrite.db.collection.object [key] || key; });
|
|
436
|
-
Define (Function.appwrite.db.collection, "object", {});
|
|
437
|
-
|
|
438
553
|
/**
|
|
439
554
|
* xxx
|
|
440
555
|
*
|
|
@@ -445,25 +560,6 @@ Define (Function.appwrite.db.collection, "object", {});
|
|
|
445
560
|
* xxx://xxx.xxx.xxx/xxx
|
|
446
561
|
*/
|
|
447
562
|
|
|
448
|
-
/**
|
|
449
|
-
* miscellaneous
|
|
450
|
-
*
|
|
451
|
-
* title
|
|
452
|
-
* description
|
|
453
|
-
* sub description
|
|
454
|
-
*
|
|
455
|
-
* xxx://xxx.xxx.xxx/xxx
|
|
456
|
-
*/
|
|
457
|
-
|
|
458
|
-
Define (Function, "unique", function () {});
|
|
459
|
-
Define (Function.unique, "id", function () {
|
|
460
|
-
return ("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx").replace (/[xy]/g, function (c) {
|
|
461
|
-
const r = (Math.random () * 16) | 0;
|
|
462
|
-
const v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
463
|
-
return v.toString (16);
|
|
464
|
-
});
|
|
465
|
-
});
|
|
466
|
-
|
|
467
563
|
/**
|
|
468
564
|
* html
|
|
469
565
|
*
|
|
@@ -477,6 +573,7 @@ Define (Function.unique, "id", function () {
|
|
|
477
573
|
Define (Function, "html", class {
|
|
478
574
|
constructor () {
|
|
479
575
|
this.head = new Function.html.head (this);
|
|
576
|
+
this.config = {}
|
|
480
577
|
this.var = {
|
|
481
578
|
"html:attribute": {},
|
|
482
579
|
title: "UnTitled",
|
|
@@ -534,7 +631,9 @@ Define (Function, "html", class {
|
|
|
534
631
|
for (var i in this.var.meta) this.head.meta (this.var.meta [i].attribute, this.var.meta [i].prop);
|
|
535
632
|
this.head.link ({rel: "icon", href: this.var ["favorite.ico"] || "/favicon.ico"});
|
|
536
633
|
this.head.link ({rel: "canonical", href: this.var.canonical || "/"});
|
|
537
|
-
if (this.
|
|
634
|
+
if (this.config ["manifest.json"]) this.head.link ({rel: "manifest", href: this.var ["manifest.json"] || "/manifest.json"});
|
|
635
|
+
if (this.config ["feed.xml"]) this.head.link ({rel: "alternate", href: "/feed/", type: "application/rss+xml", title: "{{ site:name }} » Feed"});
|
|
636
|
+
if (this.config ["feed.xml:atom"]) this.head.link ({rel: "alternate", href: "/feed/atom/", type: "application/rss+xml", title: "{{ site:name }} » Feed (Atom)"});
|
|
538
637
|
this.head.link ({rel: "dns-prefetch", href: "https://www.google-analytics.com"});
|
|
539
638
|
this.head.link ({rel: "dns-prefetch", href: "https://www.googletagmanager.com"});
|
|
540
639
|
this.head.link ({rel: "preconnect", href: "https://fonts.gstatic.com"}, "crossorigin");
|
|
@@ -554,6 +653,7 @@ Define (Function, "html", class {
|
|
|
554
653
|
this.head.script ({src: "https://unpkg.com/lodash@4.17.21/core.min.js"});
|
|
555
654
|
this.head.script ({src: "https://unpkg.com/vue@3.5.27/dist/vue.global.prod.js"});
|
|
556
655
|
this.head.script ({src: "https://unpkg.com/vue-router@4.6.4/dist/vue-router.global.prod.js"});
|
|
656
|
+
this.head.script ({src: "/test.js?123"});
|
|
557
657
|
return this;
|
|
558
658
|
}
|
|
559
659
|
render (variable = {}) {
|
|
@@ -568,6 +668,11 @@ Define (Function, "html", class {
|
|
|
568
668
|
for (var i in this.head.data.style) this.markup.push (2, `<style${Function.html.attribute (this.head.data.style [i].attribute, {space: true, prop: this.head.data.style [i].prop})}>${this.head.data.style [i].css}</style>`);
|
|
569
669
|
this.markup.push (1, `</head>`);
|
|
570
670
|
this.markup.push (1, `<body>`);
|
|
671
|
+
this.markup.push (0, `<script>
|
|
672
|
+
Function.ajax.get ("/test1.js", { success () { console.log ("ajax") } })
|
|
673
|
+
Function.ajax.get ("/test2.js", { success () { console.log ("ajax") } })
|
|
674
|
+
Function.ajax.get ("/test3.js", { success () { console.log ("ajax") } })
|
|
675
|
+
</script>`);
|
|
571
676
|
this.markup.push (1, `</body>`);
|
|
572
677
|
this.markup.push (0, `</html>`);
|
|
573
678
|
if (this.var.debug) {
|
|
@@ -621,6 +726,315 @@ Define (Function.html, "markup", class {
|
|
|
621
726
|
}
|
|
622
727
|
});
|
|
623
728
|
|
|
729
|
+
/**
|
|
730
|
+
* xxx
|
|
731
|
+
*
|
|
732
|
+
* title
|
|
733
|
+
* description
|
|
734
|
+
* sub description
|
|
735
|
+
*
|
|
736
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
737
|
+
*/
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* miscellaneous
|
|
741
|
+
*
|
|
742
|
+
* title
|
|
743
|
+
* description
|
|
744
|
+
* sub description
|
|
745
|
+
*
|
|
746
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
747
|
+
*/
|
|
748
|
+
|
|
749
|
+
Define (Function, "help", function () {});
|
|
750
|
+
|
|
751
|
+
Define (Function.help, "argument", function () {
|
|
752
|
+
var result = {string: "", number: 0}
|
|
753
|
+
for (var i in arguments) {
|
|
754
|
+
if (typeof arguments [i] === "string") result.string = arguments [i];
|
|
755
|
+
else if (typeof arguments [i] === "number") result.number = arguments [i];
|
|
756
|
+
}
|
|
757
|
+
return result;
|
|
758
|
+
});
|
|
759
|
+
|
|
760
|
+
Define (Function, "unique", function () {});
|
|
761
|
+
Define (Function.unique, "shuffle", function () { return String.char.alpha.numeric.repeat (16).shuffle ().substr (0, 64); });
|
|
762
|
+
Define (Function.unique, "id", function () {
|
|
763
|
+
return ("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx").replace (/[xy]/g, function (c) {
|
|
764
|
+
const r = (Math.random () * 16) | 0;
|
|
765
|
+
const v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
766
|
+
return v.toString (16);
|
|
767
|
+
});
|
|
768
|
+
});
|
|
769
|
+
|
|
770
|
+
Function.ajax = function () {}
|
|
771
|
+
|
|
772
|
+
Function.ajax.get = function (url, context) {
|
|
773
|
+
return $.ajax ({
|
|
774
|
+
url,
|
|
775
|
+
... context,
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
Function.ajax.post = function (url, data, context) {
|
|
780
|
+
return $.ajax ({
|
|
781
|
+
url,
|
|
782
|
+
data: JSON.stringify (data),
|
|
783
|
+
type: "POST",
|
|
784
|
+
dataType: "json",
|
|
785
|
+
... context,
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
Define (Function, "google", function () {});
|
|
790
|
+
Define (Function.google, "icon", function (icon) { if (Function.google.icon.src [icon]) return "&#x" + Function.google.icon.src [icon] + ";"; else return "XXXXXXXXXXXX"; });
|
|
791
|
+
Define (Function.google.icon, "src", {
|
|
792
|
+
home: "e88a", home_app_logo: "e295", home_storage: "f86c", home_lot_device: "e283",
|
|
793
|
+
archive: "e149", article: "ef42",
|
|
794
|
+
folder: "e2c7", folder_off: "eb83",
|
|
795
|
+
bookmark: "e866", bookmark_star: "f454",
|
|
796
|
+
notification: "e7f4", notification_unread: "f4fe", notification_audio: "eec1", notification_setting: "f367",
|
|
797
|
+
chat: "e0b7", chat_unread: "f189", chat_error: "f7ac",
|
|
798
|
+
check: "e5ca", check_circle: "e86c",
|
|
799
|
+
lock: "e897", lock_clock: "ef57",
|
|
800
|
+
visibility: "e8f4", visibility_off: "e8f5", visibility_lock: "f653",
|
|
801
|
+
thumb_up: "e8dc", thumb_up_double: "eefc", thumb_down: "e8db",
|
|
802
|
+
shield: "e9e0", shield_lock: "f686", shield_locked: "f592", shield_toggle: "f2ad", shield_watch: "f30f",
|
|
803
|
+
arrow_circle_down: "f181", arrow_drop_down: "e5c5",
|
|
804
|
+
menu: "e5d2", more: "e619", more_vertical: "e5d4", more_horizontal: "e5d3",
|
|
805
|
+
delete: "e872", delete_auto: "ea4c", delete_forever: "e92b",
|
|
806
|
+
download: "f090", downloading: "f001", cloud_download: "e2c0", cloud_upload: "e2c3",
|
|
807
|
+
calendar_clock: "f540", calendar_check: "f243", calendar_today: "e935", calendar_lock: "f242",
|
|
808
|
+
globe: "e64c", globe_asia: "f799",
|
|
809
|
+
local_activity: "e53f", local_fire_department: "ef55",
|
|
810
|
+
image: "e3f4", animated_image: "f49a",
|
|
811
|
+
photo: "e410", photo_camera: "e412",
|
|
812
|
+
star: "e838", star_s: "f31c",
|
|
813
|
+
male: "e58e", female: "e590", transgender: "e58d",
|
|
814
|
+
arrow_left_alt: "ef7d", arrow_right_alt: "e941",
|
|
815
|
+
light_bulb: "e0f0", light_bulb_x: "f3e3",
|
|
816
|
+
theater: "e8da", movie: "e02c", play_circle: "e1c4", play_arrow: "e037",
|
|
817
|
+
tv: "e333", tv_guide: "e1dc", live_tv: "e639",
|
|
818
|
+
close: "e5cd",
|
|
819
|
+
cookie: "eaac",
|
|
820
|
+
file_video: "eb87",
|
|
821
|
+
mobile_vibrate: "f2cb",
|
|
822
|
+
admin_panel_setting: "ef3d",
|
|
823
|
+
cloud_lock: "f386",
|
|
824
|
+
comedy_mask: "f4d6",
|
|
825
|
+
encrypted: "e593",
|
|
826
|
+
fingerprint: "e90d",
|
|
827
|
+
health_safety: "e1d5",
|
|
828
|
+
security: "e32a",
|
|
829
|
+
recpmend: "e9d2",
|
|
830
|
+
keep: "e6aa",
|
|
831
|
+
favorite: "e87d",
|
|
832
|
+
heart_broken: "eac2",
|
|
833
|
+
password: "f042",
|
|
834
|
+
person_shield: "e384",
|
|
835
|
+
verified_user: "e8e8",
|
|
836
|
+
supervisor_account: "e8d3",
|
|
837
|
+
visibility: "e8f4",
|
|
838
|
+
id_card: "e8f4",
|
|
839
|
+
passkey: "f87f",
|
|
840
|
+
circle: "ef4a",
|
|
841
|
+
dns: "e875",
|
|
842
|
+
eco: "ea35",
|
|
843
|
+
explore: "e87a",
|
|
844
|
+
share_location: "f05f",
|
|
845
|
+
search: "e8b6",
|
|
846
|
+
sms: "e625",
|
|
847
|
+
subscription: "e064",
|
|
848
|
+
editor_choice: "f528",
|
|
849
|
+
search_activity: "f3e5",
|
|
850
|
+
timer_play: "f4ba",
|
|
851
|
+
playlist_play: "e05f",
|
|
852
|
+
hotel_class: "e743",
|
|
853
|
+
description: "e873",
|
|
854
|
+
contact: "e0ba",
|
|
855
|
+
link: "e157",
|
|
856
|
+
health_and_safety: "e1d5",
|
|
857
|
+
setting_accessibility: "f05d",
|
|
858
|
+
safety_check: "ebef",
|
|
859
|
+
admin_panel_setting: "ef3d",
|
|
860
|
+
rss_feed: "e0e5",
|
|
861
|
+
setting: "e8b8",
|
|
862
|
+
recycling: "e760",
|
|
863
|
+
key: "e73c",
|
|
864
|
+
chart_show: "e6e1",
|
|
865
|
+
trending_up: "e8e5",
|
|
866
|
+
auto_read_play: "f216",
|
|
867
|
+
smart_display: "f06a",
|
|
868
|
+
crown: "ecb3",
|
|
869
|
+
trophy: "e71a",
|
|
870
|
+
review: "f054",
|
|
871
|
+
workspace_premium: "e7af",
|
|
872
|
+
card_star: "f375",
|
|
873
|
+
acute: "e4cb",
|
|
874
|
+
person: "e7fd",
|
|
875
|
+
event: "e878",
|
|
876
|
+
date_range: "e916",
|
|
877
|
+
chronic: "ebb2",
|
|
878
|
+
sticker: "e707",
|
|
879
|
+
flash_on: "e3e7",
|
|
880
|
+
trail_length_short: "eb6d",
|
|
881
|
+
slide_show: "e41b",
|
|
882
|
+
bolt: "ea0b",
|
|
883
|
+
speed: "e9e4",
|
|
884
|
+
rocket: "eba5",
|
|
885
|
+
});
|
|
886
|
+
|
|
887
|
+
Function.owl = function () {}
|
|
888
|
+
Function.owl.carousel = function (element, reference, option) {
|
|
889
|
+
option = option || {}
|
|
890
|
+
var padding = option.padding || 0;
|
|
891
|
+
var setting = {
|
|
892
|
+
onTranslated: option ["on:translate"] || function () {},
|
|
893
|
+
gap: (option.gap || 0),
|
|
894
|
+
loop: (option.loop || false),
|
|
895
|
+
center: (option.center || false),
|
|
896
|
+
nav: (option.nav || false), dots: (option ["nav:dot"] || false),
|
|
897
|
+
autoplay: (option.play === "auto" || option.play || false),
|
|
898
|
+
margin: (option.margin || 10),
|
|
899
|
+
autoWidth: (option.width === "auto" || false),
|
|
900
|
+
stagePadding: (option ["stage:padding"] || 0),
|
|
901
|
+
autoplayTimeout: (option.timeout || 10000),
|
|
902
|
+
autoplayHoverPause: true,
|
|
903
|
+
responsive: option.responsive || Function.owl.carousel ["item:default"],
|
|
904
|
+
}
|
|
905
|
+
var el = $ (element).removeClass ("none");
|
|
906
|
+
if (el) {
|
|
907
|
+
if (reference) el.width ($ (reference).width () - setting.gap - padding);
|
|
908
|
+
el.owlCarousel (setting);
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
Function.owl.carousel ["item:default"] = {
|
|
913
|
+
0: {items: 1},
|
|
914
|
+
600: {items: 3},
|
|
915
|
+
1000: {items: 5},
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
Function.owl.carousel ["item:pop"] = {
|
|
919
|
+
0: {items: 2},
|
|
920
|
+
600: {items: 4},
|
|
921
|
+
1000: {items: 6},
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
Function.owl.carousel ["item:best"] = {
|
|
925
|
+
0: {items: 1},
|
|
926
|
+
600: {items: 2},
|
|
927
|
+
1000: {items: 3},
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
Function.owl.carousel ["item:sky"] = {
|
|
931
|
+
0: {items: 1},
|
|
932
|
+
600: {items: 3},
|
|
933
|
+
1000: {items: 4},
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
Function.owl.carousel ["wide"] = {
|
|
937
|
+
0: {items: 1},
|
|
938
|
+
600: {items: 3},
|
|
939
|
+
1000: {items: 3},
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
Function.owl.carousel ["relation"] = {
|
|
943
|
+
0: {items: 2},
|
|
944
|
+
600: {items: 3},
|
|
945
|
+
1000: {items: 3},
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
Function.owl.carousel ["short"] = {
|
|
949
|
+
0: {items: 2},
|
|
950
|
+
600: {items: 4},
|
|
951
|
+
1000: {items: 6},
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
Function.owl.carousel ["flash"] = {
|
|
955
|
+
0: {items: 2},
|
|
956
|
+
600: {items: 4},
|
|
957
|
+
1000: {items: 6},
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
/**
|
|
961
|
+
* appwrite
|
|
962
|
+
*
|
|
963
|
+
* title
|
|
964
|
+
* description
|
|
965
|
+
* sub description
|
|
966
|
+
*
|
|
967
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
968
|
+
*/
|
|
969
|
+
|
|
970
|
+
Define (Function, "appwrite", function () {});
|
|
971
|
+
Define (Function.appwrite, "require", function () { return Function.appwrite.api = require ("node-appwrite"); });
|
|
972
|
+
|
|
973
|
+
Define (Function.appwrite, "db", class {
|
|
974
|
+
constructor (config, json) {
|
|
975
|
+
this.config = config;
|
|
976
|
+
this.client = new Function.appwrite.api.Client ().setEndpoint (this.config.host).setProject (this.config.project);
|
|
977
|
+
this.json = json || {}
|
|
978
|
+
if (this.config.collection) for (var i in this.config.collection) Function.appwrite.db.collection (i, this.config.collection [i]);
|
|
979
|
+
}
|
|
980
|
+
select (collection) { return new Function.appwrite.db.select (this, collection); }
|
|
981
|
+
});
|
|
982
|
+
|
|
983
|
+
Define (Function.appwrite.db, "select", class {
|
|
984
|
+
constructor (db, collection) {
|
|
985
|
+
this.db = db;
|
|
986
|
+
this.collection = {name: collection, id: Function.appwrite.db.collection (collection), json: this.db.json [collection] || []}
|
|
987
|
+
this.prop = {filter: {}, sort: {}, offset: 0, limit: 5000}
|
|
988
|
+
}
|
|
989
|
+
sort (sort) {
|
|
990
|
+
return this;
|
|
991
|
+
}
|
|
992
|
+
limit () {
|
|
993
|
+
if (arguments.length > 1) { this.prop.offset = arguments [0]; this.prop.limit = arguments [1]; }
|
|
994
|
+
else if (arguments.length) { this.prop.offset = 0; this.prop.limit = arguments [0]; }
|
|
995
|
+
else { this.prop.offset = 0; this.prop.limit = 5000; }
|
|
996
|
+
return this;
|
|
997
|
+
}
|
|
998
|
+
find (filter = {}) {
|
|
999
|
+
this.prop.filter = filter;
|
|
1000
|
+
return this;
|
|
1001
|
+
}
|
|
1002
|
+
query () {
|
|
1003
|
+
var serial;
|
|
1004
|
+
if (typeof this.prop.filter !== "object") this.prop.filter = {serial: (serial = this.prop.filter)}
|
|
1005
|
+
var __ = function (db) {
|
|
1006
|
+
return new Promise (async function (resolve, reject) {
|
|
1007
|
+
var data;
|
|
1008
|
+
var error = false;
|
|
1009
|
+
var database, result, query = [];
|
|
1010
|
+
if (serial) query = [Function.appwrite.api.Query.limit (1)]
|
|
1011
|
+
else {
|
|
1012
|
+
if (db.prop.limit) query.push (Function.appwrite.api.Query.limit (db.prop.limit));
|
|
1013
|
+
}
|
|
1014
|
+
try {
|
|
1015
|
+
database = new Function.appwrite.api.Databases (db.db.client);
|
|
1016
|
+
result = await database.listDocuments ({
|
|
1017
|
+
databaseId: db.db.config.id,
|
|
1018
|
+
collectionId: db.collection.id,
|
|
1019
|
+
queries: query,
|
|
1020
|
+
total: true,
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1023
|
+
catch (e) { if (error = true) console.log (e); }
|
|
1024
|
+
if (error === false) {
|
|
1025
|
+
data = result.documents.map (function (data) { return data; }).select (db.prop.filter);
|
|
1026
|
+
data = db.collection.json.select (db.prop.filter).implode (data);
|
|
1027
|
+
}
|
|
1028
|
+
resolve ({error, data});
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
return __ (this);
|
|
1032
|
+
}
|
|
1033
|
+
});
|
|
1034
|
+
|
|
1035
|
+
Define (Function.appwrite.db, "collection", function (key, value) { if (value) return Function.appwrite.db.collection.object [key] = value; else return Function.appwrite.db.collection.object [key] || key; });
|
|
1036
|
+
Define (Function.appwrite.db.collection, "object", {});
|
|
1037
|
+
|
|
624
1038
|
/**
|
|
625
1039
|
* xxx
|
|
626
1040
|
*
|
|
@@ -636,10 +1050,13 @@ Symbol.export = {
|
|
|
636
1050
|
object: Object, array: Array, string: String, number: Number, function: Function,
|
|
637
1051
|
date: Date, time: Date.time, event: Event, promise: Promise,
|
|
638
1052
|
url: URL, serialize: Function.serialize, xml: Function.xml, json: JSON,
|
|
1053
|
+
cookie: Function.cookie,
|
|
639
1054
|
path: Function.path, file: Function.file, dir: Function.dir,
|
|
640
1055
|
html: Function.html,
|
|
641
1056
|
hash: Function.hash, unique: Function.unique,
|
|
642
|
-
|
|
1057
|
+
help: Function.help, next: function (resolve) { return Promise.resolve (resolve); },
|
|
1058
|
+
ajax: Function.ajax, owl: Function.owl,
|
|
1059
|
+
express: Function.express, appwrite: Function.appwrite, google: Function.google,
|
|
643
1060
|
}
|
|
644
1061
|
|
|
645
1062
|
/**
|