prototype.exe 0.0.12 → 0.0.14

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 +34 -3
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "prototype.exe",
3
3
  "description": "JScript",
4
- "version": "0.0.12",
4
+ "version": "0.0.14",
5
5
  "main": "src/prototype.js",
6
6
  "files": [
7
7
  "src/",
package/src/prototype.js CHANGED
@@ -183,6 +183,19 @@ Define (String.prototype, "exist", function (input, offset) { return this.includ
183
183
  Define (String.prototype, "reverse", function () { return this.split ("").reverse ().join (""); });
184
184
  Define (String.prototype, "join", function (string) { return this + string; });
185
185
  Define (String.prototype, "shuffle", function () { return this.split ("").shuffle ().join (""); });
186
+ Define (String.prototype, "to_normalize", function () { return this.normalize ("NFD").replace (/[\u0300-\u036f]/g, ""); });
187
+ Define (String.prototype, "slugify", function () {
188
+ var slug = [];
189
+ var char = String.char.alpha.numeric.split ("");
190
+ var normalize = this.to_normalize ();
191
+ for (var i in normalize) {
192
+ if (char.includes (normalize [i])) slug.push (normalize [i]);
193
+ else slug.push ("-");
194
+ }
195
+ var slugify = slug.join ("").toLowerCase ().split ("--").join ("-").split ("--").join ("-").split ("--").join ("-");
196
+ if (slugify.endsWith ("-")) return slugify.slice (0, (- 1));
197
+ else return slugify;
198
+ });
186
199
 
187
200
  Define (String, "char", function () {});
188
201
  Define (String.char, "small", "abcdefghijklmnopqrstuvwxyz");
@@ -828,6 +841,7 @@ Define (Function, "html", class {
828
841
  this.markup = new Function.html.markup ("html");
829
842
  this.context = {}
830
843
  this.var = {
844
+ render: {},
831
845
  title: "Untitled",
832
846
  viewport: "width=device-width, initial-scale=1.0, maximum-scale=3.0, user-scalable=1",
833
847
  robot: ["index", "follow"],
@@ -841,6 +855,7 @@ Define (Function, "html", class {
841
855
  title (title, context) { if (["function", "object"].includes (typeof title) && ! this.context.title && ["context", "format"].includes (title.name)) this.context.title = title; else if (arguments.length > 1 && this.context.title) return this.var.title = this.context.title (title, context); else if (Object.is.set (title)) this.var.title = title; return this.var.title; }
842
856
  description (description, context) { if (["function", "object"].includes (typeof description) && ! this.context.description && ["context", "format"].includes (description.name)) this.context.description = description; else if (arguments.length > 1 && this.context.description) return this.var.description = this.context.description (description, context); else if (Object.is.set (description)) this.var.description = description; return this.var.description; }
843
857
  error (error) { if (error) this.var.error = error; return this.var.error; }
858
+ on (key, value) { if (key === "set") this.context.set = value; }
844
859
  get (key) { return this.var [key]; }
845
860
  set (key, value) {
846
861
  if (typeof key === "object") for (var i in key) if (key [i] === undefined) {}
@@ -849,6 +864,7 @@ Define (Function, "html", class {
849
864
  else if (value === undefined) {}
850
865
  else if (value === null) {}
851
866
  else this.var [key] = value;
867
+ if (this.context.set) this.context.set (key, value, this);
852
868
  return this;
853
869
  }
854
870
  delete (key) {
@@ -931,7 +947,7 @@ Define (Function, "html", class {
931
947
  this.markup.push (2, `<script>window.onload = function () {}</script>`);
932
948
  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>`);
933
949
  this.markup.push (2, `<style>img:is([sizes="auto" i], [sizes^="auto," i]) { contain-intrinsic-size: 3000px 1500px }</style>`);
934
- this.markup.push (2, `<style>[application] { opacity: 0; }</style>`);
950
+ this.markup.push (2, `<style>[application] { opacity: 0 }</style>`);
935
951
  this.markup.push (1, `</head>`);
936
952
  this.markup.push (1, `<body>`);
937
953
  this.markup.push (2, `<div id="app">`);
@@ -941,8 +957,23 @@ Define (Function, "html", class {
941
957
  this.markup.push (4, `<h${h}>${this.heading [i]}</h${h}>`);
942
958
  }
943
959
  this.markup.push (4, `<date>{{ content:date }}</date>`);
944
- this.markup.push (4, `<p>${this.var ["content:paragraph"] || ""}</p>`);
945
- this.markup.push (4, `<article>${this.var ["content:article"] || this.var ["content:description"] || this.var.content || ""}</article>`);
960
+ if (this.var ["content:paragraph"]) this.markup.push (4, `<p>${this.var ["content:paragraph"]}</p>`);
961
+ var article = this.var ["content:article"] || this.var ["content:description"] || this.var.content;
962
+ if (article) this.markup.push (4, `<article>${article}</article>`);
963
+ if (this.var.render.keyword) {
964
+ this.markup.push (4, `<ul id="keyword">`);
965
+ for (var i in this.var.render.keyword) {
966
+ this.markup.push (5, `<li><a href="${this.var.render.keyword [i].url}">${this.var.render.keyword [i].name}</a></li>`);
967
+ }
968
+ this.markup.push (4, `</ul>`);
969
+ }
970
+ if (this.var.render.tag) {
971
+ this.markup.push (4, `<ul id="tag">`);
972
+ for (var i in this.var.render.tag) {
973
+ this.markup.push (5, `<li><a href="${this.var.render.tag [i].url}">${this.var.render.tag [i].name}</a></li>`);
974
+ }
975
+ this.markup.push (4, `</ul>`);
976
+ }
946
977
  if (this.var.anchor) for (var i in this.var.anchor) this.markup.push (4, `<a href="${this.var.anchor [i].url}" title="${this.var.anchor [i].info}">${this.var.anchor [i].name}</a>`);
947
978
  this.markup.push (3, `</div>`);
948
979
  this.markup.push (2, `</div>`);