script.exe 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HISTORY.md +0 -0
- package/LICENSE +0 -0
- package/README.md +0 -0
- package/SECURITY.md +0 -0
- package/index.js +9 -0
- package/node_packages/html.js +270 -0
- package/node_packages/script.js +1004 -0
- package/package.json +25 -0
package/HISTORY.md
ADDED
|
File without changes
|
package/LICENSE
ADDED
|
File without changes
|
package/README.md
ADDED
|
File without changes
|
package/SECURITY.md
ADDED
|
File without changes
|
package/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
require ("./node_packages/script.js");
|
|
2
|
+
require ("./node_packages/html.js");
|
|
3
|
+
Function.path.require ();
|
|
4
|
+
Function.file.require ();
|
|
5
|
+
Function.hash.require ();
|
|
6
|
+
Function.mongo.require ();
|
|
7
|
+
Function.socket.require ();
|
|
8
|
+
Function.appwrite.require ();
|
|
9
|
+
module.exports = exports = Symbol.export;
|
|
@@ -0,0 +1,270 @@
|
|
|
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
|
+
Define.properties = class {
|
|
16
|
+
constructor (property) {
|
|
17
|
+
this.property = property;
|
|
18
|
+
}
|
|
19
|
+
export (data) {
|
|
20
|
+
return this.property.exports = data;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* markup
|
|
26
|
+
*
|
|
27
|
+
* title
|
|
28
|
+
* description
|
|
29
|
+
* sub description
|
|
30
|
+
*
|
|
31
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
Define (Function, "markup", class {
|
|
35
|
+
constructor (markup = [], tab) {
|
|
36
|
+
if (typeof markup === "string") this.markup = markup.split ("\n");
|
|
37
|
+
else this.markup = markup;
|
|
38
|
+
this.tab = tab || 0;
|
|
39
|
+
}
|
|
40
|
+
push (content, tab) {
|
|
41
|
+
if (tab) this.markup.push (("\t").repeat (tab) + content);
|
|
42
|
+
else this.markup.push (content);
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
render (tab) {
|
|
46
|
+
return this.markup.filter (function (markup) { if (markup) return true; else return false; }).map (function (markup) { return ("\t").repeat (this.tab) + markup; }.bind ({tab: tab || this.tab})).join ("\n");
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
Define (Function.markup, "render", function (markup, tab) {
|
|
51
|
+
return new Function.markup (markup, tab).render ();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
Define (Function.markup, "value", function (value) {
|
|
55
|
+
if (Array.isArray (value)) return value.join (", ");
|
|
56
|
+
else return value;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* html
|
|
61
|
+
*
|
|
62
|
+
* title
|
|
63
|
+
* description
|
|
64
|
+
* sub description
|
|
65
|
+
*
|
|
66
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
Define (Function, "html", class {
|
|
70
|
+
constructor () {
|
|
71
|
+
this.populated = false;
|
|
72
|
+
this.head = new Function.html.head (this);
|
|
73
|
+
this.var = {
|
|
74
|
+
"html:attribute": {},
|
|
75
|
+
title: "UnTitled",
|
|
76
|
+
description: "",
|
|
77
|
+
charset: "UTF-8",
|
|
78
|
+
meta: [],
|
|
79
|
+
link: {style: []},
|
|
80
|
+
google: {font: [], "tag:manager": "G-6JM1DVVQPT"},
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
set (key, value) {
|
|
84
|
+
if (key === "html:attribute") for (var i in value) this.var ["html:attribute"][i] = value [i];
|
|
85
|
+
else if (key === "language") this.var ["html:attribute"]["lang"] = value;
|
|
86
|
+
else if (key === "meta") this.var.meta.push (value);
|
|
87
|
+
else if (key === "link:style") this.var.link.style.push (value);
|
|
88
|
+
else if (key === "google:font") this.var.google.font.push (value);
|
|
89
|
+
else this.var [key] = value;
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
delete (key, value) {
|
|
93
|
+
if (key === "html:attribute") delete this.var ["html:attribute"][value];
|
|
94
|
+
else if (key === "language") delete this.var ["html:attribute"]["lang"];
|
|
95
|
+
else delete this.var [key];
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
populate (variable = {}) {
|
|
99
|
+
for (var i in variable) this.set (i, variable [i]);
|
|
100
|
+
this.populated = true;
|
|
101
|
+
this.head.meta ({charset: this.var.charset});
|
|
102
|
+
this.head.meta ({"http-equiv": "X-UA-Compatible", content: "IE=edge"});
|
|
103
|
+
this.head.meta ({"http-equiv": "X-Cross-Origin", content: "*"});
|
|
104
|
+
this.head.meta ({name: "viewport", content: this.var.viewport || "width=device-width, initial-scale=1.0, maximum-scale=3.0, user-scalable=1"});
|
|
105
|
+
this.head.meta ({name: "generator", content: this.var.generator || "Vercel" || "Express (5.2.1) Vue (3.5.27)"});
|
|
106
|
+
this.head.meta ({name: "author", content: this.var.author || this.var ["site:name"]});
|
|
107
|
+
this.head.meta ({name: "description", content: this.var.description});
|
|
108
|
+
this.head.meta ({name: "keywords", content: Function.markup.value (this.var.keyword)});
|
|
109
|
+
this.head.meta ({name: "robots", content: this.var.robot || "index, follow, max-snippet:-1, max-video-preview:-1, max-image-preview:large"});
|
|
110
|
+
this.head.meta ({name: "rating", content: this.var.rating || "general"});
|
|
111
|
+
this.head.meta ({name: "google", content: "notranslate"});
|
|
112
|
+
this.head.meta ({name: "googlebot", content: "notranslate"});
|
|
113
|
+
this.head.meta ({name: "googlebot-news", content: this.var ["google-bot:article"] || "index, follow"});
|
|
114
|
+
if (this.var ["google-site-verification"]) this.head.meta ({name: "google-site-verification", content: this.var ["google-site-verification"]});
|
|
115
|
+
if (this.var ["yandex-verification"]) this.head.meta ({name: "yandex-verification", content: this.var ["yandex-verification"]});
|
|
116
|
+
this.head.meta ({name: "twitter:card", content: this.var ["twitter:card"] || "summary_large_image"});
|
|
117
|
+
this.head.meta ({name: "twitter:title", content: this.var ["twitter:title"]});
|
|
118
|
+
this.head.meta ({name: "twitter:description", content: this.var ["twitter:description"] || this.var.description});
|
|
119
|
+
this.head.meta ({name: "twitter:image", content: this.var ["twitter:image"]});
|
|
120
|
+
this.head.meta ({property: "og:site_name", content: this.var ["og:site_name"]});
|
|
121
|
+
this.head.meta ({property: "og:site_description", content: this.var ["og:site_description"]});
|
|
122
|
+
this.head.meta ({property: "og:title", content: this.var ["og:title"] || this.var.title});
|
|
123
|
+
this.head.meta ({property: "og:description", content: this.var ["og:description"] || this.var.description});
|
|
124
|
+
this.head.meta ({property: "og:url", content: this.var ["og:url"] || this.var.canonical});
|
|
125
|
+
this.head.meta ({property: "og:image", content: this.var ["og:image"]});
|
|
126
|
+
this.head.meta ({property: "og:type", content: this.var ["og:type"] || "website"});
|
|
127
|
+
this.head.meta ({property: "og:locale", content: this.var ["og:locale"] || this.var ["html:attribute"]["lang"] || "en"});
|
|
128
|
+
for (var i in this.var.meta) this.head.meta (this.var.meta [i].attribute, this.var.meta [i].prop);
|
|
129
|
+
this.head.link ({rel: "icon", href: this.var ["favorite.ico"] || "/favicon.ico"});
|
|
130
|
+
this.head.link ({rel: "canonical", href: this.var.canonical || "/"});
|
|
131
|
+
if (this.var ["manifest.json"]) this.head.link ({rel: "manifest", href: this.var ["manifest.json"] || "/manifest.json"});
|
|
132
|
+
if (this.var ["feed.xml"]) this.head.link ({rel: "alternate", href: "/feed/", type: "application/rss+xml", title: "{{ site:name }} » Feed"});
|
|
133
|
+
if (this.var ["feed.xml:atom"]) this.head.link ({rel: "alternate", href: "/feed/atom/", type: "application/rss+xml", title: "{{ site:name }} » Feed (Atom)"});
|
|
134
|
+
this.head.link ({rel: "dns-prefetch", href: "https://www.google-analytics.com"});
|
|
135
|
+
this.head.link ({rel: "dns-prefetch", href: "https://www.googletagmanager.com"});
|
|
136
|
+
this.head.link ({rel: "preconnect", href: "https://fonts.gstatic.com"}, "crossorigin");
|
|
137
|
+
this.head.link ({rel: "preconnect", href: "https://fonts.googleapis.com"}, "crossorigin");
|
|
138
|
+
this.head.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"});
|
|
139
|
+
this.head.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"});
|
|
140
|
+
this.head.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"});
|
|
141
|
+
this.head.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"});
|
|
142
|
+
this.head.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"});
|
|
143
|
+
for (var i in this.var.google.font) this.head.link ({rel: "stylesheet", href: this.var.google.font [i]});
|
|
144
|
+
for (var i in this.var.link.style) this.head.link ({rel: "stylesheet", href: this.var.link.style [i]});
|
|
145
|
+
this.head.link ({rel: "stylesheet", href: "https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css"});
|
|
146
|
+
this.head.link ({rel: "stylesheet", href: "https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.min.css"});
|
|
147
|
+
if (this.var ["style.css"]) this.head.link ({rel: "stylesheet", href: this.var ["style.css"]});
|
|
148
|
+
if (this.var ["theme:style.css"]) this.head.link ({rel: "stylesheet", href: this.var ["theme:style.css"]});
|
|
149
|
+
if (this.var ["google-tag-manager"]) this.head.script ({src: "https://www.googletagmanager.com/gtag/js?id=" + this.var ["google-tag-manager"]}, "async");
|
|
150
|
+
this.head.script ({src: "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"});
|
|
151
|
+
this.head.script ({src: "https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"});
|
|
152
|
+
this.head.script ({src: "https://unpkg.com/lodash@4.17.21/core.min.js"});
|
|
153
|
+
this.head.script ({src: "https://unpkg.com/vue@3.5.27/dist/vue.global.prod.js"});
|
|
154
|
+
this.head.script ({src: "https://unpkg.com/vue-router@4.6.4/dist/vue-router.global.prod.js"});
|
|
155
|
+
if (this.var ["prototype.js"]) this.head.script ({src: this.var ["prototype.js"]});
|
|
156
|
+
if (this.var ["vue.js:core"]) this.head.script ({src: this.var ["vue.js:core"]});
|
|
157
|
+
if (this.var ["vue.js:layout"]) this.head.script ({src: this.var ["vue.js:layout"]});
|
|
158
|
+
if (this.var ["vue.js:component"]) this.head.script ({src: this.var ["vue.js:component"]});
|
|
159
|
+
if (this.var ["vue.js:element"]) this.head.script ({src: this.var ["vue.js:element"]});
|
|
160
|
+
return this;
|
|
161
|
+
}
|
|
162
|
+
render (body) {
|
|
163
|
+
if (this.populated) {}
|
|
164
|
+
else this.populate ();
|
|
165
|
+
this.markup = new Function.html.markup (`<!DOCTYPE html>`);
|
|
166
|
+
this.markup.push (0, `<html${Function.html.attribute (this.var ["html:attribute"], {space: true})}>`);
|
|
167
|
+
this.markup.push (1, `<head>`);
|
|
168
|
+
this.markup.push (2, `<title>${this.var.title}</title>`);
|
|
169
|
+
for (var i in this.head.data.meta) this.markup.push (2, `<meta${Function.html.attribute (this.head.data.meta [i].attribute, {space: true, prop: this.head.data.meta [i].prop})}>`);
|
|
170
|
+
for (var i in this.head.data.link) this.markup.push (2, `<link${Function.html.attribute (this.head.data.link [i].attribute, {space: true, prop: this.head.data.link [i].prop})}>`);
|
|
171
|
+
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>`);
|
|
172
|
+
for (var i in this.head.data.script) this.markup.push (2, `<script${Function.html.attribute (this.head.data.script [i].attribute, {space: true, prop: this.head.data.script [i].prop})}></script>`);
|
|
173
|
+
this.markup.push (2, `<script type="application/ld+json">{"@context": "https://schema.org", "@type": "WebPage", "name": "{{ site:name }}", "alternateName": "{{ site:alternate-name }}", "url": "{{ canonical }}", "description": "{{ meta:description }}"}</script>`);
|
|
174
|
+
this.markup.push (2, `<script type="application/ld+json">{"@context": "https://schema.org", "@graph": [{"@type": "website", "@id": "{{ canonical }}", "name": "{{ site:name }}", "url": "{{ canonical }}", "description": "{{ meta:description }}"}]}</script>`);
|
|
175
|
+
this.markup.push (2, `<script>vue.app.theme = {{ vue.app.theme }}</script>`);
|
|
176
|
+
this.markup.push (2, `<script>vue.app.var = {{ vue.app.var }}</script>`);
|
|
177
|
+
if (this.var ["google-tag-manager"]) this.markup.push (2, `<script>window.dataLayer = window.dataLayer || []; function gtag () { dataLayer.push (arguments); gtag ("js", new Date ()); gtag ("config", "${this.var ['google-tag-manager']}"); }</script>`);
|
|
178
|
+
this.markup.push (2, `<style>img:is([sizes="auto" i], [sizes^="auto," i]) { contain-intrinsic-size: 3000px 1500px }</style>`);
|
|
179
|
+
this.markup.push (2, `<style>[application] { opacity: 0; }</style>`);
|
|
180
|
+
this.markup.push (1, `</head>`);
|
|
181
|
+
this.markup.push (1, `<body>`);
|
|
182
|
+
this.markup.push (0, Function.markup.render (body, 2));
|
|
183
|
+
if (this.var ["vue.js"]) this.markup.push (2, `<script src="${this.var ["vue.js"]}"></script>`);
|
|
184
|
+
this.markup.push (1, `</body>`);
|
|
185
|
+
this.markup.push (0, `</html>`);
|
|
186
|
+
if (this.var.debug) {
|
|
187
|
+
this.markup.push (0, `<!--`);
|
|
188
|
+
this.markup.push (0, (this.var.debug || ""));
|
|
189
|
+
this.markup.push (0, `-->`);
|
|
190
|
+
}
|
|
191
|
+
return this.markup.string ().format (this.var);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
Define (Function.html, "template", function () {});
|
|
196
|
+
Define (Function.html.template, "default", function (data = {}) {
|
|
197
|
+
var markup = [];
|
|
198
|
+
markup.push (`<div id="app">`);
|
|
199
|
+
markup.push (` <div application>`);
|
|
200
|
+
for (var i in data.heading) {
|
|
201
|
+
var n = parseInt (i) + 1;
|
|
202
|
+
markup.push (` <h${n}>${data.heading [i]}</h${n}>`);
|
|
203
|
+
}
|
|
204
|
+
markup.push (` <date>${data.date}</date>`);
|
|
205
|
+
markup.push (` <p>${data.description}</p>`);
|
|
206
|
+
markup.push (` </div>`);
|
|
207
|
+
markup.push (`</div>`);
|
|
208
|
+
return Function.markup.render (markup);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
Define (Function.html, "head", class {
|
|
212
|
+
constructor () {
|
|
213
|
+
this.data = {meta: [], link: [], style: [], script: []}
|
|
214
|
+
}
|
|
215
|
+
meta (attribute, prop) {
|
|
216
|
+
this.data.meta.push ({attribute, prop});
|
|
217
|
+
return this;
|
|
218
|
+
}
|
|
219
|
+
link (attribute, prop) {
|
|
220
|
+
this.data.link.push ({attribute, prop});
|
|
221
|
+
return this;
|
|
222
|
+
}
|
|
223
|
+
style (attribute, prop, css) {
|
|
224
|
+
this.data.style.push ({attribute, prop, css});
|
|
225
|
+
return this;
|
|
226
|
+
}
|
|
227
|
+
script (attribute, prop) {
|
|
228
|
+
this.data.script.push ({attribute, prop});
|
|
229
|
+
return this;
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
Define (Function.html, "attribute", function (attribute, option = {}) {
|
|
234
|
+
var result = [];
|
|
235
|
+
for (var i in attribute) result.push (`${i}="${attribute [i] || ''}"`);
|
|
236
|
+
if (option.prop) result.push (option.prop);
|
|
237
|
+
if (result = result.join (" ")) return (option.space ? " " : "") + result;
|
|
238
|
+
else return "";
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
Define (Function.html, "markup", class {
|
|
242
|
+
constructor (... markup) {
|
|
243
|
+
this.markup = [... markup];
|
|
244
|
+
}
|
|
245
|
+
push (tab, content) {
|
|
246
|
+
this.markup.push (("\t").repeat (tab) + content);
|
|
247
|
+
}
|
|
248
|
+
string (ln = "\n") {
|
|
249
|
+
return this.markup.join (ln);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* xxx
|
|
255
|
+
*
|
|
256
|
+
* title
|
|
257
|
+
* description
|
|
258
|
+
* sub description
|
|
259
|
+
*
|
|
260
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
261
|
+
*/
|
|
262
|
+
|
|
263
|
+
Symbol.export.markup = Function.markup;
|
|
264
|
+
Symbol.export.html = Function.html;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* the end
|
|
268
|
+
*
|
|
269
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
270
|
+
*/
|
|
@@ -0,0 +1,1004 @@
|
|
|
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
|
+
Define.properties = class {
|
|
16
|
+
constructor (property) {
|
|
17
|
+
this.property = property;
|
|
18
|
+
}
|
|
19
|
+
export (data) {
|
|
20
|
+
return this.property.exports = data;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* object
|
|
26
|
+
*
|
|
27
|
+
* title
|
|
28
|
+
* description
|
|
29
|
+
* sub description
|
|
30
|
+
*
|
|
31
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
Define (Object, "define", Define);
|
|
35
|
+
|
|
36
|
+
Define (Object, "type", function (input) { return typeof input; });
|
|
37
|
+
Define (Object.type, "array", function (input) { if (arguments.length) return input instanceof Array || typeof input === "array"; else return Array; });
|
|
38
|
+
Define (Object.type, "boolean", function (input) { if (arguments.length) return input instanceof Boolean || typeof input === "boolean"; else return Boolean; });
|
|
39
|
+
Define (Object.type, "buffer", function (input) { if (arguments.length) return input instanceof Buffer || typeof input === "buffer"; else return Boolean; });
|
|
40
|
+
Define (Object.type, "date", function (input) { if (arguments.length) return input instanceof Date || typeof input === "date"; else return Date; });
|
|
41
|
+
Define (Object.type, "error", function (input) { if (arguments.length) return input instanceof Error || typeof input === "error"; else return Error; });
|
|
42
|
+
Define (Object.type, "function", function (input) { if (arguments.length) return input instanceof Function || typeof input === "function"; else return Function; });
|
|
43
|
+
Define (Object.type, "number", function (input) { if (arguments.length) return input instanceof Number || typeof input === "number"; else return Number; });
|
|
44
|
+
Define (Object.type, "object", function (input) { if (arguments.length) return input instanceof Object || typeof input === "object"; else return Object; });
|
|
45
|
+
Define (Object.type, "promise", function (input) { if (arguments.length) return input instanceof Promise || typeof input === "promise"; else return Promise; });
|
|
46
|
+
Define (Object.type, "regex", function (input) { if (arguments.length) return input instanceof RegExp || typeof input === "regex"; else return RegExp; });
|
|
47
|
+
Define (Object.type, "string", function (input) { if (arguments.length) return input instanceof String || typeof input === "string"; else return String; });
|
|
48
|
+
|
|
49
|
+
Define (Object, "type_of", function (input) { return Object.prototype.toString.call (input); });
|
|
50
|
+
Define (Object.type_of, "array", function (input) { if (arguments.length) return Object.type_of (input) === "[object Array]"; else return "[object Array]"; });
|
|
51
|
+
Define (Object.type_of, "boolean", function (input) { if (arguments.length) return Object.type_of (input) === "[object Boolean]"; else return "[object Boolean]"; });
|
|
52
|
+
Define (Object.type_of, "buffer", function (input) { if (arguments.length) return Object.type_of (input) === "[object Buffer]"; else return "[object Buffer]"; });
|
|
53
|
+
Define (Object.type_of, "date", function (input) { if (arguments.length) return Object.type_of (input) === "[object Date]"; else return "[object Date]"; });
|
|
54
|
+
Define (Object.type_of, "function", function (input) { if (arguments.length) return Object.type_of (input) === "[object Function]"; else return "[object Function]"; });
|
|
55
|
+
Define (Object.type_of, "null", function (input) { if (arguments.length) return Object.type_of (input) === "[object Null]"; else return "[object Null]"; });
|
|
56
|
+
Define (Object.type_of, "number", function (input) { if (arguments.length) return Object.type_of (input) === "[object Number]"; else return "[object Number]"; });
|
|
57
|
+
Define (Object.type_of, "object", function (input) { if (arguments.length) return Object.type_of (input) === "[object Object]"; else return "[object Object]"; });
|
|
58
|
+
Define (Object.type_of, "promise", function (input) { if (arguments.length) return Object.type_of (input) === "[object Promise]"; else return "[object Promise]"; });
|
|
59
|
+
Define (Object.type_of, "regex", function (input) { if (arguments.length) return Object.type_of (input) === "[object RegExp]"; else return "[object RegExp]"; });
|
|
60
|
+
Define (Object.type_of, "string", function (input) { if (arguments.length) return Object.type_of (input) === "[object String]"; else return "[object String]"; });
|
|
61
|
+
|
|
62
|
+
Define (Object, "length", function (object) { return Object.keys (object).length; });
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* array
|
|
66
|
+
*
|
|
67
|
+
* title
|
|
68
|
+
* description
|
|
69
|
+
* sub description
|
|
70
|
+
*
|
|
71
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
Define (Array.prototype, "json", function () { return JSON.pretty (this); });
|
|
75
|
+
Define (Array.prototype, "clone", function () { return JSON.parse (JSON.stringify (this)); });
|
|
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); });
|
|
77
|
+
Define (Array.prototype, "first", function () { for (var i in this) return this [i]; return undefined; }); Define (Array.prototype, "one", function () { return this.first (); });
|
|
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); });
|
|
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; });
|
|
82
|
+
Define (Array.prototype, "limit", function (limit) { return this.clone ().slice (0, limit); });
|
|
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))); });
|
|
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; } }); });
|
|
85
|
+
Define (Array.prototype, "implode", function (data) { var array = this.clone (); array.push (... data); return array; });
|
|
86
|
+
|
|
87
|
+
Define (Array.prototype, "select", function (filter) {
|
|
88
|
+
return this.filter (function (array, index) {
|
|
89
|
+
var error = 0;
|
|
90
|
+
for (var i in filter) {
|
|
91
|
+
if (typeof filter [i] === "object") {
|
|
92
|
+
if (filter [i].key === "!") {
|
|
93
|
+
if (filter [i].value !== array [i]) continue;
|
|
94
|
+
else error ++;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else if (Array.isArray (filter [i])) if (filter [i].includes (array [i])) continue; else error ++;
|
|
98
|
+
else if (Array.isArray (array [i])) if (array [i].includes (filter [i])) continue; else error ++;
|
|
99
|
+
else if (filter [i] === array [i]) continue;
|
|
100
|
+
else error ++;
|
|
101
|
+
}
|
|
102
|
+
if (error) return false;
|
|
103
|
+
else return true;
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
Define (Array.prototype, "order", function (sort) {
|
|
108
|
+
var array = this.clone (), type = "string";
|
|
109
|
+
var object = sort.split (".");
|
|
110
|
+
if (object.length > 2) {
|
|
111
|
+
if (this.length) if (typeof this [0][object [0]][object [1]][object [2]] === "number") type = "number";
|
|
112
|
+
if (type === "string") array.sort (function (a, b) { return a [object [0]][object [1]][object [2]].localeCompare (b [object [0]][object [1]][object [2]]); });
|
|
113
|
+
if (type === "number") array.sort (function (a, b) { return a [object [0]][object [1]][object [2]] - b [object [0]][object [1]][object [2]]; });
|
|
114
|
+
}
|
|
115
|
+
else if (object.length > 1) {
|
|
116
|
+
if (this.length) if (typeof this [0][object [0]][object [1]] === "number") type = "number";
|
|
117
|
+
if (type === "string") array.sort (function (a, b) { return a [object [0]][object [1]].localeCompare (b [object [0]][object [1]]); });
|
|
118
|
+
if (type === "number") array.sort (function (a, b) { return a [object [0]][object [1]] - b [object [0]][object [1]]; });
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
if (this.length) if (typeof this [0][sort] === "number") type = "number";
|
|
122
|
+
if (type === "string") array.sort (function (a, b) { return a [sort].localeCompare (b [sort]); });
|
|
123
|
+
if (type === "number") array.sort (function (a, b) { return a [sort] - b [sort]; });
|
|
124
|
+
}
|
|
125
|
+
return array;
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
Define (Array, "config", function (array = {}) {
|
|
129
|
+
if ("page" in array) if ("limit" in array.page) Array.config.page.limit = array.page.limit;
|
|
130
|
+
});
|
|
131
|
+
Define (Array.config, "page", {limit: 20}, {writable: true});
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* string
|
|
135
|
+
*
|
|
136
|
+
* title
|
|
137
|
+
* description
|
|
138
|
+
* sub description
|
|
139
|
+
*
|
|
140
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
Define (String.prototype, "number", function () { return Number (this); });
|
|
144
|
+
Define (String.prototype, "integer", function () { return parseInt (this); });
|
|
145
|
+
Define (String.prototype, "float", function () { return parseFloat (this); });
|
|
146
|
+
Define (String.prototype, "json", function (type = "object") { try { return JSON.parse (this); } catch (e) { return type === "object" ? {} : []; } });
|
|
147
|
+
Define (String.prototype, "clone", function () { return this.trim (); });
|
|
148
|
+
Define (String.prototype, "format", function (format) { var string = this.trim (); for (var i in format) string = string.split (`{{ ${i} }}`).join (format [i]); return string; });
|
|
149
|
+
Define (String.prototype, "small", function () { return this.toLowerCase (); });
|
|
150
|
+
Define (String.prototype, "big", function () { return this.toUpperCase (); });
|
|
151
|
+
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); });
|
|
152
|
+
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); });
|
|
153
|
+
Define (String.prototype, "after", function (input, offset) { if ((offset = this.indexOf (input, offset)) >= 0) return this.substr (offset + input.length); else return ""; });
|
|
154
|
+
Define (String.prototype, "before", function (input, offset) { if ((offset = this.indexOf (input, offset)) >= 0) return this.substr (0, offset); else return ""; });
|
|
155
|
+
Define (String.prototype, "pop", function (length = 1) { return this.substr (0, (this.length - length)); });
|
|
156
|
+
Define (String.prototype, "exist", function (input, offset) { return this.includes (input, offset); });
|
|
157
|
+
Define (String.prototype, "reverse", function () { return this.split ("").reverse ().join (""); });
|
|
158
|
+
Define (String.prototype, "join", function (string) { return this + string; });
|
|
159
|
+
Define (String.prototype, "shuffle", function () { return this.split ("").shuffle ().join (""); });
|
|
160
|
+
|
|
161
|
+
Define (String, "char", function () {});
|
|
162
|
+
Define (String.char, "small", "abcdefghijklmnopqrstuvwxyz");
|
|
163
|
+
Define (String.char, "big", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
|
164
|
+
Define (String.char, "alpha", {numeric: "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789"});
|
|
165
|
+
Define (String.char, "space", " ");
|
|
166
|
+
Define (String.char, "underscore", "_");
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* number
|
|
170
|
+
*
|
|
171
|
+
* title
|
|
172
|
+
* description
|
|
173
|
+
* sub description
|
|
174
|
+
*
|
|
175
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
176
|
+
*/
|
|
177
|
+
|
|
178
|
+
Define (Number.prototype, "number", function () { return this; });
|
|
179
|
+
Define (Number.prototype, "integer", function () { return parseInt (this); });
|
|
180
|
+
Define (Number.prototype, "string", function () { return this.toString (); });
|
|
181
|
+
Define (Number.prototype, "shuffle", function (number) { return Math.floor (Math.random () * (number - this + 1)) + this; });
|
|
182
|
+
|
|
183
|
+
Define (Number, "format", function (input, separator = ",") {
|
|
184
|
+
var number = input.toString ().split (""), n = [], x = 0;
|
|
185
|
+
number.reverse ();
|
|
186
|
+
for (var i in number) {
|
|
187
|
+
if (x > 2) if ((x = 0) === 0) n.push (separator);
|
|
188
|
+
x ++;
|
|
189
|
+
n.push (number [i]);
|
|
190
|
+
}
|
|
191
|
+
n.reverse ();
|
|
192
|
+
return n.join ("");
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* date
|
|
197
|
+
*
|
|
198
|
+
* title
|
|
199
|
+
* description
|
|
200
|
+
* sub description
|
|
201
|
+
*
|
|
202
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
203
|
+
*/
|
|
204
|
+
|
|
205
|
+
Define (Date, "io", class {
|
|
206
|
+
constructor (date) {
|
|
207
|
+
if (date instanceof Date) this.date = date;
|
|
208
|
+
else if (date) this.date = new Date (date);
|
|
209
|
+
else this.date = new Date ();
|
|
210
|
+
}
|
|
211
|
+
string () { return this.format ("string"); }
|
|
212
|
+
format (format = "default") {
|
|
213
|
+
var date = {
|
|
214
|
+
"Y": this.year (),
|
|
215
|
+
"M": this.month (), "m": Date.month.name [this.month ()],
|
|
216
|
+
"D": this.day (), "d": Date.day.name [this.week ()], "W": this.week (),
|
|
217
|
+
"H": this.hour (), "h": this.hour ("meredian"),
|
|
218
|
+
"I": this.minute (),
|
|
219
|
+
"S": this.second (),
|
|
220
|
+
"A": this.meredian (),
|
|
221
|
+
}
|
|
222
|
+
format = Date.format [format] || format;
|
|
223
|
+
for (var i in date) format = format.split (i).join (date [i]);
|
|
224
|
+
return format;
|
|
225
|
+
}
|
|
226
|
+
year () { return this.date.getFullYear (); }
|
|
227
|
+
month () { return (this.date.getMonth () + 1).toString ().padStart (2, "0"); }
|
|
228
|
+
day () { return this.date.getDate ().toString ().padStart (2, "0"); }
|
|
229
|
+
week () { return (this.date.getDay () + 1).toString ().padStart (2, "0"); }
|
|
230
|
+
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"); }
|
|
231
|
+
minute () { return this.date.getMinutes ().toString ().padStart (2, "0"); }
|
|
232
|
+
second () { return this.date.getSeconds ().toString ().padStart (2, "0"); }
|
|
233
|
+
mili () { return this.date.getMilliseconds ().toString ().padStart (3, "0"); }
|
|
234
|
+
meredian () { if (this.date.getHours () > 11) return "PM"; else return "AM"; }
|
|
235
|
+
time () { return this.date.getTime (); }
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
Define (Date, "format", function (format, date) { return new Date.io (date).format (format); });
|
|
239
|
+
Define (Date.format, "string", "Y-M-D");
|
|
240
|
+
Define (Date.format, "number", "YMD");
|
|
241
|
+
Define (Date.format, "default", "m D, Y");
|
|
242
|
+
Define (Date.format, "full", "d, m D, Y - h:I:S A");
|
|
243
|
+
|
|
244
|
+
Define (Date, "month", {
|
|
245
|
+
name: {
|
|
246
|
+
1: "January", "01": "January",
|
|
247
|
+
2: "February", "02": "February",
|
|
248
|
+
3: "March", "03": "March",
|
|
249
|
+
4: "April", "04": "April",
|
|
250
|
+
5: "May", "05": "May",
|
|
251
|
+
6: "June", "06": "June",
|
|
252
|
+
7: "July", "07": "July",
|
|
253
|
+
8: "August", "08": "August",
|
|
254
|
+
9: "September", "09": "September",
|
|
255
|
+
10: "October",
|
|
256
|
+
11: "November",
|
|
257
|
+
12: "December",
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
Define (Date, "day", {
|
|
262
|
+
name: {
|
|
263
|
+
1: "Monday", "01": "Monday",
|
|
264
|
+
2: "Tuesday", "02": "Tuesday",
|
|
265
|
+
3: "Wednesday", "03": "Wednesday",
|
|
266
|
+
4: "Thursday", "04": "Thursday",
|
|
267
|
+
5: "Friday", "05": "Friday",
|
|
268
|
+
6: "Saturday", "06": "Saturday",
|
|
269
|
+
7: "Sunday", "07": "Sunday",
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
Define (Date, "time", function () { return Date.now (); });
|
|
274
|
+
Define (Date, "timeout", function (context, second = 1) { return setTimeout (context, (second * 1000)); });
|
|
275
|
+
Define (Date.timeout, "clear", function (context) { return clearTimeout (context); });
|
|
276
|
+
|
|
277
|
+
Define (Date, "embed", function () {});
|
|
278
|
+
Define (Date.embed, "format", function (input) { if ((input = parseInt (input)) > 3600) return Date.embed.hour (input); else return Date.embed.minute (input); });
|
|
279
|
+
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")}`; });
|
|
280
|
+
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")}`; });
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* event
|
|
284
|
+
*
|
|
285
|
+
* title
|
|
286
|
+
* description
|
|
287
|
+
* sub description
|
|
288
|
+
*
|
|
289
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
290
|
+
*/
|
|
291
|
+
|
|
292
|
+
Define (Event, "io", class {
|
|
293
|
+
constructor () {
|
|
294
|
+
this.data = Object.create (null);
|
|
295
|
+
}
|
|
296
|
+
on (key, value) {
|
|
297
|
+
if (this.data [key]) this.data [key].push (value);
|
|
298
|
+
else this.data [key] = [value];
|
|
299
|
+
}
|
|
300
|
+
emit (key, ... value) {
|
|
301
|
+
var e;
|
|
302
|
+
for (var i in this.data [key]) {
|
|
303
|
+
e = this.data [key][i] (... value);
|
|
304
|
+
}
|
|
305
|
+
return e;
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
Define (Event, "proto", function (proto) {
|
|
310
|
+
if (proto) {}
|
|
311
|
+
else proto = Object.create (null);
|
|
312
|
+
proto.event = proto.event || Object.create (null);
|
|
313
|
+
proto.on = function (key, value) {
|
|
314
|
+
if (proto.event [key]) proto.event [key].push (value);
|
|
315
|
+
else proto.event [key] = [value];
|
|
316
|
+
}
|
|
317
|
+
proto.emit = function (key, ... value) {
|
|
318
|
+
var e;
|
|
319
|
+
for (var i in proto.event [key]) {
|
|
320
|
+
e = proto.event [key][i] (... value);
|
|
321
|
+
}
|
|
322
|
+
return e;
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* promise
|
|
328
|
+
*
|
|
329
|
+
* title
|
|
330
|
+
* description
|
|
331
|
+
* sub description
|
|
332
|
+
*
|
|
333
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
334
|
+
*/
|
|
335
|
+
|
|
336
|
+
Define (Promise, "io", function (context) {
|
|
337
|
+
return new Promise (function (resolve, reject) {
|
|
338
|
+
context (function (value = true) { resolve (value); }, function (error = "") { reject (error); });
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* url
|
|
344
|
+
*
|
|
345
|
+
* title
|
|
346
|
+
* description
|
|
347
|
+
* sub description
|
|
348
|
+
*
|
|
349
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
350
|
+
*/
|
|
351
|
+
|
|
352
|
+
Define (URL, "parse", function (url) {
|
|
353
|
+
var parse_url, result = {
|
|
354
|
+
host: {address: "", name: ""},
|
|
355
|
+
domain: {name: "", base: {name: ""}, sub: "www", extension: ""},
|
|
356
|
+
protocol: "http", port: "", user: "", password: "",
|
|
357
|
+
path: "", tag: "",
|
|
358
|
+
queries: {},
|
|
359
|
+
}
|
|
360
|
+
try {
|
|
361
|
+
var parse_url = new URL (url);
|
|
362
|
+
result.host = {address: parse_url.host, name: parse_url.hostname}
|
|
363
|
+
result.domain = {name: "", base: {name: ""}, sub: "www", extension: ""}
|
|
364
|
+
result.protocol = parse_url.protocol.pop ();
|
|
365
|
+
result.port = parse_url.port ? parse_url.port.integer () : "";
|
|
366
|
+
result.user = parse_url.username;
|
|
367
|
+
result.password = parse_url.password;
|
|
368
|
+
result.path = parse_url.pathname;
|
|
369
|
+
result.tag = parse_url.hash;
|
|
370
|
+
result.query = function (key) { return result.queries [key] || ""; }
|
|
371
|
+
result.queries = {}
|
|
372
|
+
var queries = parse_url.search.after ("?").split ("&");
|
|
373
|
+
for (var i in queries) {
|
|
374
|
+
if (queries [i]) {
|
|
375
|
+
var key = queries [i].before ("=");
|
|
376
|
+
var value = queries [i].after ("=");
|
|
377
|
+
if (key) if (value) result.queries [key] = value;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return result;
|
|
381
|
+
}
|
|
382
|
+
catch (e) {
|
|
383
|
+
return result;
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
Define (URL, "header", function () {});
|
|
388
|
+
Define (URL.header, "status", {
|
|
389
|
+
OK: 200, success: 200,
|
|
390
|
+
error: {request: 400, forbidden: 403, exist: 404, timeout: 408, legal: 451, internal: 500},
|
|
391
|
+
code: {
|
|
392
|
+
100: "Continue", 101: "Switching Protocols", 102: "Processing",
|
|
393
|
+
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",
|
|
394
|
+
300: "Multiple Choices", 301: "Moved Permanently", 302: "Found", 303: "See Other", 304: "Not Modified", 305: "Use Proxy", 307: "Temporary Redirect", 308: "Permanent Redirect",
|
|
395
|
+
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",
|
|
396
|
+
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",
|
|
397
|
+
},
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* cookie
|
|
402
|
+
*
|
|
403
|
+
* title
|
|
404
|
+
* description
|
|
405
|
+
* sub description
|
|
406
|
+
*
|
|
407
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
408
|
+
*/
|
|
409
|
+
|
|
410
|
+
Function.cookie = function (key, value) {
|
|
411
|
+
var cookie = document.cookie.split (";").map (function (data) { return data.trim ().split ("="); });
|
|
412
|
+
for (var i in cookie) {
|
|
413
|
+
var key = cookie [i][0], value;
|
|
414
|
+
if (key) {
|
|
415
|
+
value = cookie [i][1].trim ();
|
|
416
|
+
Function.cookie.data [key.trim ()] = value;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
Function.cookie.get = function (key) {
|
|
422
|
+
if (key) return Function.cookie.data [key];
|
|
423
|
+
else return Function.cookie.get (Function.cookie.identity);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
Function.cookie.delete = function (key) {
|
|
427
|
+
Function.cookie.set (key);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
Function.cookie.set = function (key, value = "", expire = 0, domain = null, path = "/") {
|
|
431
|
+
if (typeof key === "string") {
|
|
432
|
+
if (expire === null) expire = Function.cookie._expire;
|
|
433
|
+
domain = domain || Function.cookie._domain;
|
|
434
|
+
document.cookie = `${key}=${value};expires=${expire};domain=${domain};path=/;samesite=lax`;
|
|
435
|
+
Function.cookie.data [key] = value;
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
if ("domain" in key) Function.cookie._domain = key.domain;
|
|
439
|
+
if ("expire:day" in key) {
|
|
440
|
+
var expire = new Date ();
|
|
441
|
+
expire.setTime (expire.getTime () + (key ["expire:day"] * 24 * 60 * 60 * 1000));
|
|
442
|
+
Function.cookie._expire = expire.toUTCString ();
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
Function.cookie.start = function (visitor) {
|
|
448
|
+
if (Function.cookie.get (Function.cookie.identity)) {}
|
|
449
|
+
else Function.cookie.set (Function.cookie.identity, Function.unique.id ());
|
|
450
|
+
if (visitor) Function.visitor.cookie (visitor.ip.address, visitor.country.code, visitor.agent);
|
|
451
|
+
Event.emit ("cookie:start", visitor);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
Function.cookie.id = function () {
|
|
455
|
+
return Function.cookie.get (Function.cookie.identity);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
Function.cookie.identity = "cookie";
|
|
459
|
+
Function.cookie.data = {}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* json
|
|
463
|
+
*
|
|
464
|
+
* title
|
|
465
|
+
* description
|
|
466
|
+
* sub description
|
|
467
|
+
*
|
|
468
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
469
|
+
*/
|
|
470
|
+
|
|
471
|
+
Define (JSON, "pretty", function (json) { return JSON.stringify (json, null, "\t"); });
|
|
472
|
+
|
|
473
|
+
Define (JSON, "db", class {
|
|
474
|
+
constructor (config) {
|
|
475
|
+
this.dir = config.dir;
|
|
476
|
+
this.collection = config.collection || {}
|
|
477
|
+
}
|
|
478
|
+
select (collection) { return new JSON.db.select (this, collection); }
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
Define (JSON.db, "select", class {
|
|
482
|
+
constructor (db, collection) {
|
|
483
|
+
this.db = db;
|
|
484
|
+
this.collection = {name: collection, file: JSON.db.file (collection)}
|
|
485
|
+
if (this.db.collection [this.collection.name]) this.collection.data = this.db.collection [this.collection.name];
|
|
486
|
+
else this.collection.data = JSON.parse (Function.file.read (Function.path.join (this.db.dir, `${this.collection.file}.json`)) || "[]");
|
|
487
|
+
}
|
|
488
|
+
find (filter = {}) {
|
|
489
|
+
var __ = function (db) {
|
|
490
|
+
return new Promise (function (resolve, reject) {
|
|
491
|
+
resolve ({collection: db.collection.name, data: db.collection.data.select (filter)});
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
return __ (this);
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
Define (JSON.db, "file", function (key, value) { if (value) return JSON.db.file.object [key] = value; else return JSON.db.file.object [key] || key; });
|
|
499
|
+
Define (JSON.db.file, "object", {});
|
|
500
|
+
|
|
501
|
+
Define (JSON, "token", function () {});
|
|
502
|
+
Define (JSON.token, "parse", function (token) {
|
|
503
|
+
try {
|
|
504
|
+
if ((token = token.split (".")).length !== 3) throw new Error ("Invalid JWT Structure");
|
|
505
|
+
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 ("")));
|
|
506
|
+
}
|
|
507
|
+
catch (e) {
|
|
508
|
+
return {}
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* path
|
|
514
|
+
*
|
|
515
|
+
* title
|
|
516
|
+
* description
|
|
517
|
+
* sub description
|
|
518
|
+
*
|
|
519
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
520
|
+
*/
|
|
521
|
+
|
|
522
|
+
Define (Function, "path", function () {});
|
|
523
|
+
Define (Function.path, "require", function () { return Function.path.api = require ("path"); });
|
|
524
|
+
Define (Function.path, "join", function (... path) { return Function.path.api.join (... path); });
|
|
525
|
+
Define (Function.path, "current", function (path) { return "./" + path; });
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* file
|
|
529
|
+
*
|
|
530
|
+
* title
|
|
531
|
+
* description
|
|
532
|
+
* sub description
|
|
533
|
+
*
|
|
534
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
535
|
+
*/
|
|
536
|
+
|
|
537
|
+
Define (Function, "file", function () {});
|
|
538
|
+
Define (Function.file, "require", function () { return Function.file.api = require ("fs"); });
|
|
539
|
+
Define (Function.file, "write", function (file, content, context) { if (context) return Function.file.api.writeFile (file, content, context); else return Function.file.api.writeFileSync (file, content); });
|
|
540
|
+
Define (Function.file, "read", function (file, context) { if (context) return Function.file.api.readFile (file, context); else return Function.file.api.readFileSync (file); });
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* hash
|
|
544
|
+
*
|
|
545
|
+
* title
|
|
546
|
+
* description
|
|
547
|
+
* sub description
|
|
548
|
+
*
|
|
549
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
550
|
+
*/
|
|
551
|
+
|
|
552
|
+
Define (Function, "hash", function () {});
|
|
553
|
+
Define (Function.hash, "require", function () { Function.hash.crypto.api = require ("crypto"); });
|
|
554
|
+
Define (Function.hash, "crypto", function () {});
|
|
555
|
+
Define (Function.hash, "md5", function (input) { return Function.hash.crypto.api.createHash ("md5").update (input).digest ("hex"); });
|
|
556
|
+
|
|
557
|
+
Define (Function, "unique", function () {});
|
|
558
|
+
Define (Function.unique, "shuffle", function () { return String.char.alpha.numeric.repeat (16).shuffle ().substr (0, 64); });
|
|
559
|
+
Define (Function.unique, "id", function () {
|
|
560
|
+
return ("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx").replace (/[xy]/g, function (c) {
|
|
561
|
+
const r = (Math.random () * 16) | 0;
|
|
562
|
+
const v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
563
|
+
return v.toString (16);
|
|
564
|
+
});
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* mongo
|
|
569
|
+
*
|
|
570
|
+
* title
|
|
571
|
+
* description
|
|
572
|
+
* sub description
|
|
573
|
+
*
|
|
574
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
575
|
+
*/
|
|
576
|
+
|
|
577
|
+
Define (Function, "mongo", function () {});
|
|
578
|
+
Define (Function.mongo, "require", function () { return Function.mongo.api = require ("mongodb"); });
|
|
579
|
+
|
|
580
|
+
Define (Function.mongo, "db", class {
|
|
581
|
+
constructor (url, option) {
|
|
582
|
+
this.client = new Function.mongo.api.MongoClient (url, option);
|
|
583
|
+
}
|
|
584
|
+
connect () {
|
|
585
|
+
return this.client.connect ();
|
|
586
|
+
}
|
|
587
|
+
db (db) {
|
|
588
|
+
return new Function.mongo.db.client (this.client, db);
|
|
589
|
+
}
|
|
590
|
+
use (db) {
|
|
591
|
+
return this.db (db);
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
Define (Function.mongo.db, "client", class {
|
|
596
|
+
constructor (client, db) {
|
|
597
|
+
this.client = client;
|
|
598
|
+
this.db = this.client.db (db);
|
|
599
|
+
}
|
|
600
|
+
collection (collection) {
|
|
601
|
+
return new Function.mongo.db.collection (this.client, this.db, collection);
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
|
|
605
|
+
Define (Function.mongo.db, "collection", class {
|
|
606
|
+
constructor (client, db, collection) {
|
|
607
|
+
this.client = client;
|
|
608
|
+
this.db = db;
|
|
609
|
+
this.collection = this.db.collection (collection);
|
|
610
|
+
this.option = {filter: {}}
|
|
611
|
+
}
|
|
612
|
+
find (filter) {
|
|
613
|
+
if (typeof filter === "string") this.option.filter = {serial: filter}
|
|
614
|
+
else this.option.filter = filter || {}
|
|
615
|
+
return this;
|
|
616
|
+
}
|
|
617
|
+
limit () {
|
|
618
|
+
if (arguments.length === 1) this.option.limit = arguments [0];
|
|
619
|
+
if (arguments.length === 2) {
|
|
620
|
+
this.option.offset = arguments [0];
|
|
621
|
+
this.option.limit = arguments [1];
|
|
622
|
+
}
|
|
623
|
+
return this;
|
|
624
|
+
}
|
|
625
|
+
select (filter, option) {
|
|
626
|
+
var __ = function (mongo) {
|
|
627
|
+
return new Promise (async function (resolve, reject) {
|
|
628
|
+
var error, data;
|
|
629
|
+
try {
|
|
630
|
+
if (mongo.option.limit === 1) data = await mongo.collection.findOne (mongo.option.filter);
|
|
631
|
+
else data = await mongo.collection.find (mongo.option.filter).toArray ();
|
|
632
|
+
}
|
|
633
|
+
catch (e) { error = true; }
|
|
634
|
+
resolve ({error, data});
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
return __ (this);
|
|
638
|
+
}
|
|
639
|
+
insert (data) {
|
|
640
|
+
var __ = function (mongo) {
|
|
641
|
+
return new Promise (async function (resolve, reject) {
|
|
642
|
+
var error, result;
|
|
643
|
+
try {
|
|
644
|
+
if (Array.isArray (data)) result = await mongo.collection.insertMany (data, {ordered: false, forceServerObjectId: true});
|
|
645
|
+
}
|
|
646
|
+
catch (e) { error = true; }
|
|
647
|
+
resolve ({error, result});
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
return __ (this);
|
|
651
|
+
}
|
|
652
|
+
truncate () {
|
|
653
|
+
var __ = function (mongo) {
|
|
654
|
+
return new Promise (async function (resolve, reject) {
|
|
655
|
+
var result = await mongo.collection.deleteMany ({});
|
|
656
|
+
resolve (result);
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
return __ (this);
|
|
660
|
+
}
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* socket.io
|
|
665
|
+
*
|
|
666
|
+
* title
|
|
667
|
+
* description
|
|
668
|
+
* sub description
|
|
669
|
+
*
|
|
670
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
671
|
+
*/
|
|
672
|
+
|
|
673
|
+
Define (Function, "socket", function () {});
|
|
674
|
+
Define (Function.socket, "require", function () { return Function.socket.api = require ("socket.io"); });
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* 3rd party
|
|
678
|
+
*
|
|
679
|
+
* title
|
|
680
|
+
* description
|
|
681
|
+
* sub description
|
|
682
|
+
*
|
|
683
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
684
|
+
*/
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* miscellaneous
|
|
688
|
+
*
|
|
689
|
+
* title
|
|
690
|
+
* description
|
|
691
|
+
* sub description
|
|
692
|
+
*
|
|
693
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
694
|
+
*/
|
|
695
|
+
|
|
696
|
+
Define (Function, "help", function () {});
|
|
697
|
+
|
|
698
|
+
Define (Function.help, "argument", function () {
|
|
699
|
+
var result = {string: "", number: 0}
|
|
700
|
+
for (var i in arguments) {
|
|
701
|
+
if (typeof arguments [i] === "string") result.string = arguments [i];
|
|
702
|
+
else if (typeof arguments [i] === "number") result.number = arguments [i];
|
|
703
|
+
}
|
|
704
|
+
return result;
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
Function.ajax = function () {}
|
|
708
|
+
|
|
709
|
+
Function.ajax.get = function (url, context) {
|
|
710
|
+
return $.ajax ({
|
|
711
|
+
url,
|
|
712
|
+
... context,
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
Function.ajax.post = function (url, data, context) {
|
|
717
|
+
return $.ajax ({
|
|
718
|
+
url,
|
|
719
|
+
data: JSON.stringify (data),
|
|
720
|
+
type: "POST",
|
|
721
|
+
dataType: "json",
|
|
722
|
+
... context,
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
Define (Function, "google", function () {});
|
|
727
|
+
Define (Function.google, "icon", function (icon) { if (Function.google.icon.src [icon]) return "&#x" + Function.google.icon.src [icon] + ";"; else return "XXXXXXXXXXXX"; });
|
|
728
|
+
Define (Function.google.icon, "src", {
|
|
729
|
+
home: "e88a", home_app_logo: "e295", home_storage: "f86c", home_lot_device: "e283",
|
|
730
|
+
archive: "e149", article: "ef42",
|
|
731
|
+
folder: "e2c7", folder_off: "eb83",
|
|
732
|
+
bookmark: "e866", bookmark_star: "f454",
|
|
733
|
+
notification: "e7f4", notification_unread: "f4fe", notification_audio: "eec1", notification_setting: "f367",
|
|
734
|
+
chat: "e0b7", chat_unread: "f189", chat_error: "f7ac",
|
|
735
|
+
check: "e5ca", check_circle: "e86c",
|
|
736
|
+
lock: "e897", lock_clock: "ef57",
|
|
737
|
+
visibility: "e8f4", visibility_off: "e8f5", visibility_lock: "f653",
|
|
738
|
+
thumb_up: "e8dc", thumb_up_double: "eefc", thumb_down: "e8db",
|
|
739
|
+
shield: "e9e0", shield_lock: "f686", shield_locked: "f592", shield_toggle: "f2ad", shield_watch: "f30f",
|
|
740
|
+
arrow_circle_down: "f181", arrow_drop_down: "e5c5",
|
|
741
|
+
menu: "e5d2", more: "e619", more_vertical: "e5d4", more_horizontal: "e5d3",
|
|
742
|
+
delete: "e872", delete_auto: "ea4c", delete_forever: "e92b",
|
|
743
|
+
download: "f090", downloading: "f001", cloud_download: "e2c0", cloud_upload: "e2c3",
|
|
744
|
+
calendar_clock: "f540", calendar_check: "f243", calendar_today: "e935", calendar_lock: "f242",
|
|
745
|
+
globe: "e64c", globe_asia: "f799",
|
|
746
|
+
local_activity: "e53f", local_fire_department: "ef55",
|
|
747
|
+
image: "e3f4", animated_image: "f49a",
|
|
748
|
+
photo: "e410", photo_camera: "e412",
|
|
749
|
+
star: "e838", star_s: "f31c",
|
|
750
|
+
male: "e58e", female: "e590", transgender: "e58d",
|
|
751
|
+
arrow_left_alt: "ef7d", arrow_right_alt: "e941",
|
|
752
|
+
light_bulb: "e0f0", light_bulb_x: "f3e3",
|
|
753
|
+
theater: "e8da", movie: "e02c", play_circle: "e1c4", play_arrow: "e037",
|
|
754
|
+
tv: "e333", tv_guide: "e1dc", live_tv: "e639",
|
|
755
|
+
close: "e5cd",
|
|
756
|
+
cookie: "eaac",
|
|
757
|
+
file_video: "eb87",
|
|
758
|
+
mobile_vibrate: "f2cb",
|
|
759
|
+
admin_panel_setting: "ef3d",
|
|
760
|
+
cloud_lock: "f386",
|
|
761
|
+
comedy_mask: "f4d6",
|
|
762
|
+
encrypted: "e593",
|
|
763
|
+
fingerprint: "e90d",
|
|
764
|
+
health_safety: "e1d5",
|
|
765
|
+
security: "e32a",
|
|
766
|
+
recpmend: "e9d2",
|
|
767
|
+
keep: "e6aa",
|
|
768
|
+
favorite: "e87d",
|
|
769
|
+
heart_broken: "eac2",
|
|
770
|
+
password: "f042",
|
|
771
|
+
person_shield: "e384",
|
|
772
|
+
verified_user: "e8e8",
|
|
773
|
+
supervisor_account: "e8d3",
|
|
774
|
+
visibility: "e8f4",
|
|
775
|
+
id_card: "e8f4",
|
|
776
|
+
passkey: "f87f",
|
|
777
|
+
circle: "ef4a",
|
|
778
|
+
dns: "e875",
|
|
779
|
+
eco: "ea35",
|
|
780
|
+
explore: "e87a",
|
|
781
|
+
share_location: "f05f",
|
|
782
|
+
search: "e8b6",
|
|
783
|
+
sms: "e625",
|
|
784
|
+
subscription: "e064",
|
|
785
|
+
editor_choice: "f528",
|
|
786
|
+
search_activity: "f3e5",
|
|
787
|
+
timer_play: "f4ba",
|
|
788
|
+
playlist_play: "e05f",
|
|
789
|
+
hotel_class: "e743",
|
|
790
|
+
description: "e873",
|
|
791
|
+
contact: "e0ba",
|
|
792
|
+
link: "e157",
|
|
793
|
+
health_and_safety: "e1d5",
|
|
794
|
+
setting_accessibility: "f05d",
|
|
795
|
+
safety_check: "ebef",
|
|
796
|
+
admin_panel_setting: "ef3d",
|
|
797
|
+
rss_feed: "e0e5",
|
|
798
|
+
setting: "e8b8",
|
|
799
|
+
recycling: "e760",
|
|
800
|
+
key: "e73c",
|
|
801
|
+
chart_show: "e6e1",
|
|
802
|
+
trending_up: "e8e5",
|
|
803
|
+
auto_read_play: "f216",
|
|
804
|
+
smart_display: "f06a",
|
|
805
|
+
crown: "ecb3",
|
|
806
|
+
trophy: "e71a",
|
|
807
|
+
review: "f054",
|
|
808
|
+
workspace_premium: "e7af",
|
|
809
|
+
card_star: "f375",
|
|
810
|
+
acute: "e4cb",
|
|
811
|
+
person: "e7fd",
|
|
812
|
+
event: "e878",
|
|
813
|
+
date_range: "e916",
|
|
814
|
+
chronic: "ebb2",
|
|
815
|
+
sticker: "e707",
|
|
816
|
+
flash_on: "e3e7",
|
|
817
|
+
trail_length_short: "eb6d",
|
|
818
|
+
slide_show: "e41b",
|
|
819
|
+
bolt: "ea0b",
|
|
820
|
+
speed: "e9e4",
|
|
821
|
+
rocket: "eba5",
|
|
822
|
+
});
|
|
823
|
+
|
|
824
|
+
Function.owl = function () {}
|
|
825
|
+
Function.owl.carousel = function (element, reference, option) {
|
|
826
|
+
option = option || {}
|
|
827
|
+
var padding = option.padding || 0;
|
|
828
|
+
var setting = {
|
|
829
|
+
onTranslated: option ["on:translate"] || function () {},
|
|
830
|
+
gap: (option.gap || 0),
|
|
831
|
+
loop: (option.loop || false),
|
|
832
|
+
center: (option.center || false),
|
|
833
|
+
nav: (option.nav || false), dots: (option ["nav:dot"] || false),
|
|
834
|
+
autoplay: (option.play === "auto" || option.play || false),
|
|
835
|
+
margin: (option.margin || 10),
|
|
836
|
+
autoWidth: (option.width === "auto" || false),
|
|
837
|
+
stagePadding: (option ["stage:padding"] || 0),
|
|
838
|
+
autoplayTimeout: (option.timeout || 10000),
|
|
839
|
+
autoplayHoverPause: true,
|
|
840
|
+
responsive: option.responsive || Function.owl.carousel ["item:default"],
|
|
841
|
+
}
|
|
842
|
+
var el = $ (element).removeClass ("none");
|
|
843
|
+
if (el) {
|
|
844
|
+
if (reference) el.width ($ (reference).width () - setting.gap - padding);
|
|
845
|
+
el.owlCarousel (setting);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
Function.owl.carousel ["item:default"] = {
|
|
850
|
+
0: {items: 1},
|
|
851
|
+
600: {items: 3},
|
|
852
|
+
1000: {items: 5},
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
Function.owl.carousel ["item:pop"] = {
|
|
856
|
+
0: {items: 2},
|
|
857
|
+
600: {items: 4},
|
|
858
|
+
1000: {items: 6},
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
Function.owl.carousel ["item:best"] = {
|
|
862
|
+
0: {items: 1},
|
|
863
|
+
600: {items: 2},
|
|
864
|
+
1000: {items: 3},
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
Function.owl.carousel ["item:sky"] = {
|
|
868
|
+
0: {items: 1},
|
|
869
|
+
600: {items: 3},
|
|
870
|
+
1000: {items: 4},
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
Function.owl.carousel ["wide"] = {
|
|
874
|
+
0: {items: 1},
|
|
875
|
+
600: {items: 3},
|
|
876
|
+
1000: {items: 3},
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
Function.owl.carousel ["relation"] = {
|
|
880
|
+
0: {items: 2},
|
|
881
|
+
600: {items: 3},
|
|
882
|
+
1000: {items: 3},
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
Function.owl.carousel ["short"] = {
|
|
886
|
+
0: {items: 2},
|
|
887
|
+
600: {items: 4},
|
|
888
|
+
1000: {items: 6},
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
Function.owl.carousel ["flash"] = {
|
|
892
|
+
0: {items: 2},
|
|
893
|
+
600: {items: 4},
|
|
894
|
+
1000: {items: 6},
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
/**
|
|
898
|
+
* appwrite
|
|
899
|
+
*
|
|
900
|
+
* title
|
|
901
|
+
* description
|
|
902
|
+
* sub description
|
|
903
|
+
*
|
|
904
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
905
|
+
*/
|
|
906
|
+
|
|
907
|
+
Define (Function, "appwrite", function () {});
|
|
908
|
+
Define (Function.appwrite, "require", function () { return Function.appwrite.api = require ("node-appwrite"); });
|
|
909
|
+
|
|
910
|
+
Define (Function.appwrite, "db", class {
|
|
911
|
+
constructor (config, json) {
|
|
912
|
+
this.config = config;
|
|
913
|
+
this.client = new Function.appwrite.api.Client ().setEndpoint (this.config.host).setProject (this.config.project);
|
|
914
|
+
this.json = json || {}
|
|
915
|
+
if (this.config.collection) for (var i in this.config.collection) Function.appwrite.db.collection (i, this.config.collection [i]);
|
|
916
|
+
}
|
|
917
|
+
select (collection) { return new Function.appwrite.db.select (this, collection); }
|
|
918
|
+
});
|
|
919
|
+
|
|
920
|
+
Define (Function.appwrite.db, "select", class {
|
|
921
|
+
constructor (db, collection) {
|
|
922
|
+
this.db = db;
|
|
923
|
+
this.collection = {name: collection, id: Function.appwrite.db.collection (collection), json: this.db.json [collection] || []}
|
|
924
|
+
this.prop = {filter: {}, sort: {}, offset: 0, limit: 5000}
|
|
925
|
+
}
|
|
926
|
+
sort (sort) {
|
|
927
|
+
return this;
|
|
928
|
+
}
|
|
929
|
+
limit () {
|
|
930
|
+
if (arguments.length > 1) { this.prop.offset = arguments [0]; this.prop.limit = arguments [1]; }
|
|
931
|
+
else if (arguments.length) { this.prop.offset = 0; this.prop.limit = arguments [0]; }
|
|
932
|
+
else { this.prop.offset = 0; this.prop.limit = 5000; }
|
|
933
|
+
return this;
|
|
934
|
+
}
|
|
935
|
+
find (filter = {}) {
|
|
936
|
+
this.prop.filter = filter;
|
|
937
|
+
return this;
|
|
938
|
+
}
|
|
939
|
+
query () {
|
|
940
|
+
var serial;
|
|
941
|
+
if (typeof this.prop.filter !== "object") this.prop.filter = {serial: (serial = this.prop.filter)}
|
|
942
|
+
var __ = function (db) {
|
|
943
|
+
return new Promise (async function (resolve, reject) {
|
|
944
|
+
var data = [];
|
|
945
|
+
var error = false;
|
|
946
|
+
var database, result, query = [];
|
|
947
|
+
if (serial) query = [Function.appwrite.api.Query.limit (1)]
|
|
948
|
+
else {
|
|
949
|
+
if (db.prop.limit) query.push (Function.appwrite.api.Query.limit (db.prop.limit));
|
|
950
|
+
}
|
|
951
|
+
try {
|
|
952
|
+
database = new Function.appwrite.api.Databases (db.db.client);
|
|
953
|
+
result = await database.listDocuments ({
|
|
954
|
+
databaseId: db.db.config.id,
|
|
955
|
+
collectionId: db.collection.id,
|
|
956
|
+
queries: query,
|
|
957
|
+
total: true,
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
catch (e) { if (error = true) console.log (e); }
|
|
961
|
+
if (error === false) {
|
|
962
|
+
data = result.documents.map (function (data) { return data; }).select (db.prop.filter);
|
|
963
|
+
data = db.collection.json.select (db.prop.filter).implode (data);
|
|
964
|
+
}
|
|
965
|
+
resolve ({error, data});
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
return __ (this);
|
|
969
|
+
}
|
|
970
|
+
});
|
|
971
|
+
|
|
972
|
+
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; });
|
|
973
|
+
Define (Function.appwrite.db.collection, "object", {});
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* xxx
|
|
977
|
+
*
|
|
978
|
+
* title
|
|
979
|
+
* description
|
|
980
|
+
* sub description
|
|
981
|
+
*
|
|
982
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
983
|
+
*/
|
|
984
|
+
|
|
985
|
+
Symbol.export = {
|
|
986
|
+
define: Object.define,
|
|
987
|
+
object: Object, array: Array, string: String, number: Number, function: Function,
|
|
988
|
+
date: Date, time: Date.time, event: Event, promise: Promise,
|
|
989
|
+
cookie: Function.cookie, session: Function.session, ls: Function.ls,
|
|
990
|
+
url: URL, path: Function.path, file: Function.file, dir: Function.dir,
|
|
991
|
+
markup: Function.markup, html: Function.html, css: Function.css, js: Function.js, json: JSON, xml: Function.xml, serialize: Function.serialize,
|
|
992
|
+
help: Function.help, next: function (resolve) { return Promise.resolve (resolve); },
|
|
993
|
+
hash: Function.hash, unique: Function.unique,
|
|
994
|
+
ajax: Function.ajax, owl: Function.owl,
|
|
995
|
+
express: Function.express, mongo: Function.mongo, firebase: Function.firebase, appwrite: Function.appwrite,
|
|
996
|
+
cloudflare: Function.cloudflare, google: Function.google,
|
|
997
|
+
zero: 0, one: 1,
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
* the end
|
|
1002
|
+
*
|
|
1003
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
1004
|
+
*/
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "script.exe",
|
|
3
|
+
"description": "Hello World",
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"author": "Seindi Rahmat Barus <xseindi@gmail.com>",
|
|
6
|
+
"contributors": [
|
|
7
|
+
"Seindi Rahmat Barus <xseindi@gmail.com>"
|
|
8
|
+
],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"express",
|
|
12
|
+
"vue",
|
|
13
|
+
"mongodb"
|
|
14
|
+
],
|
|
15
|
+
"main": "index.js",
|
|
16
|
+
"files": [
|
|
17
|
+
"LICENSE",
|
|
18
|
+
"README.md",
|
|
19
|
+
"HISTORY.md",
|
|
20
|
+
"SECURITY.md",
|
|
21
|
+
"index.js",
|
|
22
|
+
"node_packages/"
|
|
23
|
+
],
|
|
24
|
+
"dependencies": {}
|
|
25
|
+
}
|