prototype.exe 0.0.3 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/prototype.js +67 -2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "prototype.exe",
3
3
  "description": "JScript",
4
- "version": "0.0.3",
4
+ "version": "0.0.4",
5
5
  "main": "src/prototype.js",
6
6
  "files": [
7
7
  "src/",
package/src/prototype.js CHANGED
@@ -909,7 +909,7 @@ Define (Function, "html", class {
909
909
  if (false) if (this.var ["google:auth"]) this.markup.push (2, `<script src="https://accounts.google.com/gsi/client" async></script>`);
910
910
  this.markup.script (2, {src: "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"});
911
911
  this.markup.script (2, {src: "https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"});
912
- if (false) if (this.var ["prototype.js"]) this.markup.script (2, {src: this.var ["prototype.js"]});
912
+ if (this.var ["prototype.js"]) this.markup.script (2, {src: this.var ["prototype.js"]});
913
913
  this.markup.push (2, `<script type="module" src="${this.var ['vue.js:bundle']}" crossorigin></script>`);
914
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>`);
915
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>`);
@@ -917,6 +917,7 @@ Define (Function, "html", class {
917
917
  this.markup.push (2, `<script>$.app.id = "{{ $.app.id }}"</script>`);
918
918
  this.markup.push (2, `<script>$.app.reference = {{ $.app.reference }}</script>`);
919
919
  this.markup.push (2, `<script>$.app.var = {{ $.app.var }}</script>`);
920
+ this.markup.push (2, `<script>$.app.config = {{ $.app.config }}</script>`);
920
921
  this.markup.push (2, `<script>$.app.document = {{ $.app.document }}</script>`);
921
922
  this.markup.push (2, `<script>$.app.theme = {{ $.app.theme }}</script>`);
922
923
  this.markup.push (2, `<script>$.app.router = {{ $.app.router }}</script>`);
@@ -1069,6 +1070,70 @@ Define (Function.help, "argument", function () {
1069
1070
  return result;
1070
1071
  });
1071
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
+
1072
1137
  Function.ajax = function () {}
1073
1138
 
1074
1139
  Function.ajax.config = function (key, value) {
@@ -1402,7 +1467,7 @@ Symbol.export = {
1402
1467
  markup: Function.markup, html: Function.html, css: Function.css, js: Function.js, json: JSON, xml: Function.xml, serialize: Function.serialize,
1403
1468
  help: Function.help, log: Function.log,
1404
1469
  hash: Function.hash, unique: Function.unique,
1405
- socket: Function.socket, ajax: Function.ajax,
1470
+ socket: Function.socket, ajax: Function.ajax, j_son: Function.j_son,
1406
1471
  require: Function.require, base_dir: Function.base_dir,
1407
1472
  layout: Function.layout, component: Function.component, element: Function.element,
1408
1473
  google: Function.google,