prototype.exe 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/prototype.js +84 -5
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "prototype.exe",
3
3
  "description": "JScript",
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "main": "src/prototype.js",
6
6
  "files": [
7
7
  "src/",
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,24 +903,26 @@ 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>`);
860
910
  this.markup.script (2, {src: "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"});
861
911
  this.markup.script (2, {src: "https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"});
862
- if (this.var ["prototype.js"]) this.markup.script (2, {src: this.var ["prototype.js"]});
912
+ if (false) if (this.var ["prototype.js"]) this.markup.script (2, {src: this.var ["prototype.js"]});
863
913
  this.markup.push (2, `<script type="module" src="${this.var ['vue.js:bundle']}" crossorigin></script>`);
864
914
  this.markup.push (2, `<script type="application/ld+json">{"@context": "https://schema.org", "@type": "WebPage", "name": "${this.var.site.name}", "alternateName": "${this.var ['site:alternate-name']}", "url": "${this.var ['canonical']}", "description": "${this.var ['description']}"}</script>`);
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>`);
869
920
  this.markup.push (2, `<script>$.app.document = {{ $.app.document }}</script>`);
870
921
  this.markup.push (2, `<script>$.app.theme = {{ $.app.theme }}</script>`);
871
922
  this.markup.push (2, `<script>$.app.router = {{ $.app.router }}</script>`);
872
923
  this.markup.push (2, `<script>$.app.visitor = {{ $.app.visitor }}</script>`);
873
- this.markup.push (2, `<script>$.app.cookie = {name: "${this.var.cookie.name}", host: "${this.var.cookie.host}"}</script>`);
924
+ this.markup.push (2, `<script>$.app.cookie = {{ $.app.cookie }}</script>`);
925
+ // this.markup.push (2, `<script>$.app.cookie = {name: "${this.var.cookie.name}", host: "${this.var.cookie.host}"}</script>`);
874
926
  this.markup.push (2, `<script>$.app.error = {{ $.app.error }}</script>`);
875
927
  this.markup.push (2, `<script>window.onload = function () {}</script>`);
876
928
  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 +948,35 @@ Define (Function, "html", class {
896
948
  }
897
949
  });
898
950
 
951
+ Define (Function.html, "error", function (error) {
952
+ var description = `The Status Code ${error.id} was an error on this server. That's all we know.`;
953
+ var markup = new Function.html.markup ("html");
954
+ markup.push (0, "html", {lang: "en", translate: "no", prefix: "og: http://ogp.me/ns#"});
955
+ markup.push (1, "head", {profile: "#"});
956
+ markup.push (2, `<title>Error</title>`);
957
+ markup.push (2, "meta", {"http-equiv": "X-UA-Compatible", content: "IE=edge"});
958
+ markup.push (2, "meta", {"http-equiv": "X-Cross-Origin", content: "*"});
959
+ markup.push (2, "meta", {charset: "UTF-8"});
960
+ markup.push (2, "meta", {name: "description", content: description});
961
+ markup.push (2, "meta", {name: "viewport", content: "width=device-width, initial-scale=1.0, maximum-scale=3.0, user-scalable=1"});
962
+ markup.push (2, "meta", {name: "robots", content: [Function.html.attribute.content (["noindex", "nofollow"]), "max-snippet:-1, max-video-preview:-1, max-image-preview:large"]});
963
+ markup.push (2, "meta", {name: "google", content: "notranslate"});
964
+ markup.push (2, "meta", {name: "googlebot", content: "notranslate"});
965
+ markup.push (2, "meta", {name: "googlebot-news", content: ["noindex", "nofollow"]});
966
+ markup.push (1, `</head>`);
967
+ markup.push (1, `<body>`);
968
+ markup.push (2, `<h1>Error</h1>`);
969
+ markup.push (2, `<hr>`);
970
+ markup.push (2, `<h3>Request ID : ${error.serial}</h3>`);
971
+ markup.push (2, `<h3>Request URL : ${error.url}</h3>`);
972
+ markup.push (2, `<h3>Message : ${error.message}</h3>`);
973
+ markup.push (2, `<hr>`);
974
+ markup.push (2, `<p><em>${description}</em></p>`);
975
+ markup.push (1, `</body>`);
976
+ markup.push (0, `</html>`);
977
+ return markup.render ();
978
+ });
979
+
899
980
  Define (Function.html, "prop", function (prop) {
900
981
  var attribute = "";
901
982
  if (typeof prop === "string") attribute = " " + prop.trim ();
@@ -1337,5 +1418,3 @@ Symbol.export = {
1337
1418
  *
1338
1419
  * xxx://xxx.xxx.xxx/xxx
1339
1420
  */
1340
-
1341
- // module.exports = exports = Symbol.export;