prototype.exe 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/prototype.js +149 -5
package/package.json
CHANGED
package/src/prototype.js
CHANGED
|
@@ -233,6 +233,7 @@ Define (Date, "io", class {
|
|
|
233
233
|
if (date instanceof Date) this.date = date;
|
|
234
234
|
else if (date) this.date = new Date (date);
|
|
235
235
|
else this.date = new Date ();
|
|
236
|
+
this.utc = new Date.io.utc (this.date);
|
|
236
237
|
}
|
|
237
238
|
iso () { return this.format ("iso"); }
|
|
238
239
|
format (format = "default") {
|
|
@@ -267,12 +268,51 @@ Define (Date, "io", class {
|
|
|
267
268
|
stamp () { return this.date; }
|
|
268
269
|
});
|
|
269
270
|
|
|
271
|
+
Define (Date.io, "utc", class {
|
|
272
|
+
constructor (datetime) {
|
|
273
|
+
this.datetime = datetime;
|
|
274
|
+
}
|
|
275
|
+
iso () {
|
|
276
|
+
return this.format ("iso");
|
|
277
|
+
}
|
|
278
|
+
format (format = "default") {
|
|
279
|
+
var date = {
|
|
280
|
+
"Y": this.year (),
|
|
281
|
+
"M": this.month (), "m": Date.month.name [this.month ()],
|
|
282
|
+
"D": this.day (), "d": Date.day.name [this.week ()], "W": this.week (),
|
|
283
|
+
"H": this.hour (), "h": this.hour ("meredian"),
|
|
284
|
+
"I": this.minute (),
|
|
285
|
+
"S": this.second (),
|
|
286
|
+
"A": this.meredian (),
|
|
287
|
+
}
|
|
288
|
+
format = Date.format [format] || format;
|
|
289
|
+
var formated = format.split ("");
|
|
290
|
+
var result = [];
|
|
291
|
+
for (var i in formated) {
|
|
292
|
+
result.push (date [formated [i]] || formated [i]);
|
|
293
|
+
}
|
|
294
|
+
return result.join ("");
|
|
295
|
+
}
|
|
296
|
+
year () { return this.datetime.getUTCFullYear (); }
|
|
297
|
+
month () { return (this.datetime.getUTCMonth () + 1).toString ().padStart (2, "0"); }
|
|
298
|
+
day () { return this.datetime.getUTCDate ().toString ().padStart (2, "0"); }
|
|
299
|
+
week () { return (this.datetime.getUTCDay () || 7).toString ().padStart (2, "0"); }
|
|
300
|
+
hour (meredian) { if (meredian) { var hour = this.datetime.getUTCHours (); 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.datetime.getUTCHours ().toString ().padStart (2, "0"); }
|
|
301
|
+
minute () { return this.datetime.getUTCMinutes ().toString ().padStart (2, "0"); }
|
|
302
|
+
second () { return this.datetime.getUTCSeconds ().toString ().padStart (2, "0"); }
|
|
303
|
+
mili () { return this.datetime.getMilliseconds ().toString ().padStart (3, "0"); }
|
|
304
|
+
meredian () { if (this.datetime.getHours () > 11) return "PM"; else return "AM"; }
|
|
305
|
+
time () { return this.datetime.getTime (); }
|
|
306
|
+
stamp () { return this.datetime; }
|
|
307
|
+
});
|
|
308
|
+
|
|
270
309
|
Define (Date, "format", function (format, date) { return new Date.io (date).format (format); });
|
|
271
310
|
Define (Date.format, "iso", "Y-M-D");
|
|
272
311
|
Define (Date.format, "number", "YMD");
|
|
273
312
|
Define (Date.format, "default", "m D, Y");
|
|
274
313
|
Define (Date.format, "full", "d, m D, Y - h:I:S A");
|
|
275
314
|
Define (Date.format, "monthly", "Y-M");
|
|
315
|
+
Define (Date.format, "time", "H:I:S");
|
|
276
316
|
|
|
277
317
|
Define (Date, "month", {
|
|
278
318
|
name: {
|
|
@@ -381,6 +421,16 @@ Define (Promise, "io", function (context) {
|
|
|
381
421
|
});
|
|
382
422
|
});
|
|
383
423
|
|
|
424
|
+
Define (Promise.prototype, "next", function (context) {
|
|
425
|
+
var fp = function () {}
|
|
426
|
+
if (context.success || context.error || context.end) return this.then (context.success || fp).catch (context.error || fp).finally (context.end || fp);
|
|
427
|
+
else return this.then (context || fp).catch (fp).finally (fp);
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
Define (Promise.prototype, "pipe", function (context) {
|
|
431
|
+
return this.next (context);
|
|
432
|
+
});
|
|
433
|
+
|
|
384
434
|
/**
|
|
385
435
|
* url
|
|
386
436
|
*
|
|
@@ -853,7 +903,7 @@ Define (Function, "html", class {
|
|
|
853
903
|
for (var i in this.var.link.style) this.markup.push (2, "link", {rel: "stylesheet", href: this.var.link.style [i]});
|
|
854
904
|
this.markup.push (2, "link", {rel: "stylesheet", href: "https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css"});
|
|
855
905
|
this.markup.push (2, "link", {rel: "stylesheet", href: "https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.min.css"});
|
|
856
|
-
if (this.var ["theme:style.css"]) this.markup.push (2, "link", {rel: "stylesheet", href: this.var ["theme:style.css"]});
|
|
906
|
+
if (false) if (this.var ["theme:style.css"]) this.markup.push (2, "link", {rel: "stylesheet", href: this.var ["theme:style.css"]});
|
|
857
907
|
this.markup.push (2, "link", {rel: "stylesheet", href: this.var ["vue.css:bundle"]});
|
|
858
908
|
if (this.var ["gtag:id"]) this.markup.push (2, `<script src="https://www.googletagmanager.com/gtag/js?id=${this.var ['gtag:id']}" async></script>`);
|
|
859
909
|
if (false) if (this.var ["google:auth"]) this.markup.push (2, `<script src="https://accounts.google.com/gsi/client" async></script>`);
|
|
@@ -865,12 +915,15 @@ Define (Function, "html", class {
|
|
|
865
915
|
this.markup.push (2, `<script type="application/ld+json">{"@context": "https://schema.org", "@graph": [{"@type": "website", "@id": "${this.var ['canonical']}", "name": "${this.var.site.name}", "url": "${this.var ['canonical']}", "description": "${this.var ['description']}"}]}</script>`);
|
|
866
916
|
this.markup.push (2, `<script>$.app = function () {}</script>`);
|
|
867
917
|
this.markup.push (2, `<script>$.app.id = "{{ $.app.id }}"</script>`);
|
|
918
|
+
this.markup.push (2, `<script>$.app.reference = {{ $.app.reference }}</script>`);
|
|
868
919
|
this.markup.push (2, `<script>$.app.var = {{ $.app.var }}</script>`);
|
|
920
|
+
this.markup.push (2, `<script>$.app.config = {{ $.app.config }}</script>`);
|
|
869
921
|
this.markup.push (2, `<script>$.app.document = {{ $.app.document }}</script>`);
|
|
870
922
|
this.markup.push (2, `<script>$.app.theme = {{ $.app.theme }}</script>`);
|
|
871
923
|
this.markup.push (2, `<script>$.app.router = {{ $.app.router }}</script>`);
|
|
872
924
|
this.markup.push (2, `<script>$.app.visitor = {{ $.app.visitor }}</script>`);
|
|
873
|
-
this.markup.push (2, `<script>$.app.cookie = {
|
|
925
|
+
this.markup.push (2, `<script>$.app.cookie = {{ $.app.cookie }}</script>`);
|
|
926
|
+
// this.markup.push (2, `<script>$.app.cookie = {name: "${this.var.cookie.name}", host: "${this.var.cookie.host}"}</script>`);
|
|
874
927
|
this.markup.push (2, `<script>$.app.error = {{ $.app.error }}</script>`);
|
|
875
928
|
this.markup.push (2, `<script>window.onload = function () {}</script>`);
|
|
876
929
|
if (this.var ["gtag:id"]) this.markup.push (2, `<script>window.dataLayer = window.dataLayer || []; function gtag () { dataLayer.push (arguments); gtag ("js", new Date ()); gtag ("config", "${this.var ['gtag:id']}"); }</script>`);
|
|
@@ -896,6 +949,35 @@ Define (Function, "html", class {
|
|
|
896
949
|
}
|
|
897
950
|
});
|
|
898
951
|
|
|
952
|
+
Define (Function.html, "error", function (error) {
|
|
953
|
+
var description = `The Status Code ${error.id} was an error on this server. That's all we know.`;
|
|
954
|
+
var markup = new Function.html.markup ("html");
|
|
955
|
+
markup.push (0, "html", {lang: "en", translate: "no", prefix: "og: http://ogp.me/ns#"});
|
|
956
|
+
markup.push (1, "head", {profile: "#"});
|
|
957
|
+
markup.push (2, `<title>Error</title>`);
|
|
958
|
+
markup.push (2, "meta", {"http-equiv": "X-UA-Compatible", content: "IE=edge"});
|
|
959
|
+
markup.push (2, "meta", {"http-equiv": "X-Cross-Origin", content: "*"});
|
|
960
|
+
markup.push (2, "meta", {charset: "UTF-8"});
|
|
961
|
+
markup.push (2, "meta", {name: "description", content: description});
|
|
962
|
+
markup.push (2, "meta", {name: "viewport", content: "width=device-width, initial-scale=1.0, maximum-scale=3.0, user-scalable=1"});
|
|
963
|
+
markup.push (2, "meta", {name: "robots", content: [Function.html.attribute.content (["noindex", "nofollow"]), "max-snippet:-1, max-video-preview:-1, max-image-preview:large"]});
|
|
964
|
+
markup.push (2, "meta", {name: "google", content: "notranslate"});
|
|
965
|
+
markup.push (2, "meta", {name: "googlebot", content: "notranslate"});
|
|
966
|
+
markup.push (2, "meta", {name: "googlebot-news", content: ["noindex", "nofollow"]});
|
|
967
|
+
markup.push (1, `</head>`);
|
|
968
|
+
markup.push (1, `<body>`);
|
|
969
|
+
markup.push (2, `<h1>Error</h1>`);
|
|
970
|
+
markup.push (2, `<hr>`);
|
|
971
|
+
markup.push (2, `<h3>Request ID : ${error.serial}</h3>`);
|
|
972
|
+
markup.push (2, `<h3>Request URL : ${error.url}</h3>`);
|
|
973
|
+
markup.push (2, `<h3>Message : ${error.message}</h3>`);
|
|
974
|
+
markup.push (2, `<hr>`);
|
|
975
|
+
markup.push (2, `<p><em>${description}</em></p>`);
|
|
976
|
+
markup.push (1, `</body>`);
|
|
977
|
+
markup.push (0, `</html>`);
|
|
978
|
+
return markup.render ();
|
|
979
|
+
});
|
|
980
|
+
|
|
899
981
|
Define (Function.html, "prop", function (prop) {
|
|
900
982
|
var attribute = "";
|
|
901
983
|
if (typeof prop === "string") attribute = " " + prop.trim ();
|
|
@@ -988,6 +1070,70 @@ Define (Function.help, "argument", function () {
|
|
|
988
1070
|
return result;
|
|
989
1071
|
});
|
|
990
1072
|
|
|
1073
|
+
Function.j_son = function () {}
|
|
1074
|
+
|
|
1075
|
+
Function.j_son.config = function (key, value) {
|
|
1076
|
+
return Function.j_son.config [key] = value;
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
Function.j_son.url = function (url) {
|
|
1080
|
+
if (Function.j_son) {
|
|
1081
|
+
if (url.startsWith ("/") === false) url = "/" + url;
|
|
1082
|
+
if (Function.j_son.config.host) return Function.j_son.config.host + url;
|
|
1083
|
+
else return url;
|
|
1084
|
+
}
|
|
1085
|
+
else {
|
|
1086
|
+
if (typeof url === "string") {}
|
|
1087
|
+
else {
|
|
1088
|
+
if (url.host) if (Function.j_son.config.host) url = Function.j_son.config.host + url.path;
|
|
1089
|
+
else url = url.url || url.path;
|
|
1090
|
+
else url = url.url || url.path;
|
|
1091
|
+
}
|
|
1092
|
+
return url;
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
Function.j_son.get = function (url, context) {
|
|
1097
|
+
url = Function.j_son.url (url);
|
|
1098
|
+
return $.ajax ({
|
|
1099
|
+
url,
|
|
1100
|
+
headers: {j_son: Function.j_son.id (), reference: URL.referer ()},
|
|
1101
|
+
success (j_son) {
|
|
1102
|
+
if (typeof j_son === "object") {}
|
|
1103
|
+
else j_son = {}
|
|
1104
|
+
if (context.success) context.success ({}, j_son);
|
|
1105
|
+
URL.referer (url);
|
|
1106
|
+
},
|
|
1107
|
+
error (error) {
|
|
1108
|
+
if (context.error) context.error (error.responseJSON || {});
|
|
1109
|
+
},
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
Function.j_son.post = function (url, data, context) {
|
|
1114
|
+
url = Function.j_son.url (url);
|
|
1115
|
+
return $.ajax ({
|
|
1116
|
+
url,
|
|
1117
|
+
headers: {j_son: Function.j_son.id (), reference: URL.referer ()},
|
|
1118
|
+
data: JSON.stringify (data),
|
|
1119
|
+
type: "POST",
|
|
1120
|
+
dataType: "json",
|
|
1121
|
+
success (j_son) {
|
|
1122
|
+
if (typeof j_son === "object") {}
|
|
1123
|
+
else j_son = {}
|
|
1124
|
+
if (context.success) context.success ({}, j_son);
|
|
1125
|
+
URL.referer (url);
|
|
1126
|
+
},
|
|
1127
|
+
error (error) {
|
|
1128
|
+
if (context.error) context.error (error.responseJSON || {});
|
|
1129
|
+
},
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
Function.j_son.id = function () {
|
|
1134
|
+
return (Function.unique.id () || Function.cookie.get ("j_son")).toUpperCase ();
|
|
1135
|
+
}
|
|
1136
|
+
|
|
991
1137
|
Function.ajax = function () {}
|
|
992
1138
|
|
|
993
1139
|
Function.ajax.config = function (key, value) {
|
|
@@ -1321,7 +1467,7 @@ Symbol.export = {
|
|
|
1321
1467
|
markup: Function.markup, html: Function.html, css: Function.css, js: Function.js, json: JSON, xml: Function.xml, serialize: Function.serialize,
|
|
1322
1468
|
help: Function.help, log: Function.log,
|
|
1323
1469
|
hash: Function.hash, unique: Function.unique,
|
|
1324
|
-
socket: Function.socket, ajax: Function.ajax,
|
|
1470
|
+
socket: Function.socket, ajax: Function.ajax, j_son: Function.j_son,
|
|
1325
1471
|
require: Function.require, base_dir: Function.base_dir,
|
|
1326
1472
|
layout: Function.layout, component: Function.component, element: Function.element,
|
|
1327
1473
|
google: Function.google,
|
|
@@ -1337,5 +1483,3 @@ Symbol.export = {
|
|
|
1337
1483
|
*
|
|
1338
1484
|
* xxx://xxx.xxx.xxx/xxx
|
|
1339
1485
|
*/
|
|
1340
|
-
|
|
1341
|
-
// module.exports = exports = Symbol.export;
|