From fe6ec9101595d62aa44368fbf0c0e98b9bd23752 Mon Sep 17 00:00:00 2001 From: Raza Balbale Date: Sat, 7 Sep 2024 21:50:09 -0500 Subject: [PATCH] Changed views.json to use viewFile attribute. --- README.md | 2 +- Wirup.js | 2 +- Wirup.min.js | 2 +- example/js/Wirup.js | 2 +- example/js/Wirup.min.js | 2 +- example/views/views.json | 6 +++--- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5c5b2b1..1da0c57 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ Once you have created the textfile for your view (in the **views** folder), upda { "viewName": "listView", "url": "/", - "HTML": "listView.txt" + "viewFile": "listView.html" } ] } diff --git a/Wirup.js b/Wirup.js index 5bac611..0c5b1ba 100644 --- a/Wirup.js +++ b/Wirup.js @@ -68,7 +68,7 @@ wirup.prototype = (function () { _fillView = (index, target) => { return _wijax( "GET", - "views/" + _views[index]["HTML"], + "views/" + _views[index]["viewFile"], "text/plain; charset=UTF-8", (data) => { _getElement(target).innerHTML = data; diff --git a/Wirup.min.js b/Wirup.min.js index 2d18bc9..5ed0610 100644 --- a/Wirup.min.js +++ b/Wirup.min.js @@ -1 +1 @@ -"use strict";var wirup=function(){};wirup.prototype=function(){var e,t=function(e){return document.getElementById(e)},n=(e,t,n,r)=>new Promise((a,o)=>{var i=new XMLHttpRequest;return i.open(e,t,!0),i.setRequestHeader("Content-Type",n),i.setRequestHeader("cache-control","no-cache"),i.setRequestHeader("expires","0"),i.setRequestHeader("expires","Tue, 01 Jan 1980 1:00:00 GMT"),i.setRequestHeader("pragma","no-cache"),i.onreadystatechange=()=>{if(4===i.readyState){if(200===i.status)a(r(i.responseText));else{let e=i.statusText||"Your ajax request threw an error.";o(e)}}},i.send(),i.responseText}),r=window.location.pathname,a=()=>n("GET","views/views.json","application/json; charset=UTF-8",o),o=t=>{e=JSON.parse(t).views},i=t=>new Promise((n,a)=>{let o;var i=r;if(void 0===r&&(window.location="/"),e){for(var c=0;c<=e.length-1;c++)e[c].url==i&&(o=c);void 0===o&&(o=0),s(o,t).then(()=>{n()})}}),s=(r,a)=>n("GET","views/"+e[r].HTML,"text/plain; charset=UTF-8",e=>{t(a).innerHTML=e}),c=()=>{window.onpopstate=e=>{r=window.location.pathname,T()}},u={},p={},d={},l=()=>new Promise(function(e,n){var r=t("contentBody").querySelectorAll("[datasource]");[].forEach.call(r,e=>{e.innerHTML=g(e.tagName.toLowerCase(),e.getAttribute("datasource"))}),y("Switched View","Content Body","No Comment."),e()}),h=e=>{t("contentBody").querySelectorAll('[datasource="'+e+'"]').forEach(t=>{t.innerHTML=g(t.tagName.toLowerCase(),e),y("Updated Data.",t.tagName.toLowerCase(),"No Comment.")})},g=(e,t)=>{let n="";var r=typeof u[t];switch(r){case"object":n=u[t].map((t,n)=>p[e](t));break;case"string":n=p[e](u[t])}return n.join("")},m=function(e){for(var t in e)"object"==typeof e[t]&&null!==e[t]&&m(e[t]),_key_list.push(e[t])},f=function(e){return new Promise((t,n)=>{var r=document.createElement("script");r.type="text/javascript",r.src=e+"?"+new Date().getTime(),document.getElementsByTagName("head")[0].appendChild(r),r.onload=()=>{t()},r.onabort=()=>{n()}})},w="",y=(e,t,n)=>{let r=new Date().getTime(),a={name:e,element:t,comment:n,profile:w,timestamp:r},o=localStorage.getItem("wuActions");localStorage.setItem("wuActions",o+","+JSON.stringify(a))},v=e=>window[e](),$=e=>new Promise(function(t,n){f("components/components.js").then(()=>{a().then(()=>{i("contentBody").then(()=>{l().then(()=>{c(),void 0!==e&&v(e)})})})})}),T=e=>{$(e)};return{wu:t,wijax:n,jsonize:function(e){try{return JSON.parse(window[e])}catch(t){return window[e]}},loadScript:f,registerComponent(e,t){p[e]=t},registerProfile(e){w=e},registerAction:y,buildComponent:g,buildComponents(e,t){let n="";return e.forEach((e,r)=>{switch(dataSourceType=typeof u[t[r]]){case"object":n=u[t[r]].map((t,n)=>p[e](t));break;case"string":n=p[e](u[t[r]])}}),n.join("")},navigateTo(e){history.pushState(null,null,e),r=e,i("contentBody").then(()=>{l()})},registerData(e,t){Object.defineProperty(u,e,{get:function(){return this["_"+e]},set:function(t){this["_"+e],this["_"+e]=t,h(e)}}),u[e]=t},addData(e,t){var n=[];(n=u[e]).push(t),u[e]=n,n=[]},findIndexByKey:(e,t,n)=>wuObject.dataStore[e].findIndex(function(e){return e[t]==n}),updateData(e,t,n){var r=[];(r=u[e])[t=t-1<0?0:t-1]=n,u[e]=r,r=[]},removeData(e,t){var n=[];n=u[e],t=t-1<0?0:t-1,n.splice(t,1),u[e]=n,n=[]},dataStore:u,onLoad(e){Object.defineProperty(d,"trigger",{get:function(){return this._trigger},set:function(e){this._trigger,this._trigger=e,window[e]()}}),d.trigger=e},components:p,init:T}}(),window.wuObject=new wirup; \ No newline at end of file +"use strict";var wirup=function(){};wirup.prototype=function(){var e,t=function(e){return document.getElementById(e)},n=(e,t,n,r)=>new Promise((a,o)=>{var i=new XMLHttpRequest;return i.open(e,t,!0),i.setRequestHeader("Content-Type",n),i.setRequestHeader("cache-control","no-cache"),i.setRequestHeader("expires","0"),i.setRequestHeader("expires","Tue, 01 Jan 1980 1:00:00 GMT"),i.setRequestHeader("pragma","no-cache"),i.onreadystatechange=()=>{if(4===i.readyState){if(200===i.status)a(r(i.responseText));else{let e=i.statusText||"Your ajax request threw an error.";o(e)}}},i.send(),i.responseText}),r=window.location.pathname,a=()=>n("GET","views/views.json","application/json; charset=UTF-8",o),o=t=>{e=JSON.parse(t).views},i=t=>new Promise((n,a)=>{let o;var i=r;if(void 0===r&&(window.location="/"),e){for(var c=0;c<=e.length-1;c++)e[c].url==i&&(o=c);void 0===o&&(o=0),s(o,t).then(()=>{n()})}}),s=(r,a)=>n("GET","views/"+e[r].viewFile,"text/plain; charset=UTF-8",e=>{t(a).innerHTML=e}),c=()=>{window.onpopstate=e=>{r=window.location.pathname,T()}},u={},p={},d={},l=()=>new Promise(function(e,n){var r=t("contentBody").querySelectorAll("[datasource]");[].forEach.call(r,e=>{e.innerHTML=g(e.tagName.toLowerCase(),e.getAttribute("datasource"))}),v("Switched View","Content Body","No Comment."),e()}),h=e=>{t("contentBody").querySelectorAll('[datasource="'+e+'"]').forEach(t=>{t.innerHTML=g(t.tagName.toLowerCase(),e),v("Updated Data.",t.tagName.toLowerCase(),"No Comment.")})},g=(e,t)=>{let n="";var r=typeof u[t];switch(r){case"object":n=u[t].map((t,n)=>p[e](t));break;case"string":n=p[e](u[t])}return n.join("")},m=function(e){for(var t in e)"object"==typeof e[t]&&null!==e[t]&&m(e[t]),_key_list.push(e[t])},f=function(e){return new Promise((t,n)=>{var r=document.createElement("script");r.type="text/javascript",r.src=e+"?"+new Date().getTime(),document.getElementsByTagName("head")[0].appendChild(r),r.onload=()=>{t()},r.onabort=()=>{n()}})},w="",v=(e,t,n)=>{let r=new Date().getTime(),a={name:e,element:t,comment:n,profile:w,timestamp:r},o=localStorage.getItem("wuActions");localStorage.setItem("wuActions",o+","+JSON.stringify(a))},y=e=>window[e](),$=e=>new Promise(function(t,n){f("components/components.js").then(()=>{a().then(()=>{i("contentBody").then(()=>{l().then(()=>{c(),void 0!==e&&y(e)})})})})}),T=e=>{$(e)};return{wu:t,wijax:n,jsonize:function(e){try{return JSON.parse(window[e])}catch(t){return window[e]}},loadScript:f,registerComponent(e,t){p[e]=t},registerProfile(e){w=e},registerAction:v,buildComponent:g,buildComponents(e,t){let n="";return e.forEach((e,r)=>{switch(dataSourceType=typeof u[t[r]]){case"object":n=u[t[r]].map((t,n)=>p[e](t));break;case"string":n=p[e](u[t[r]])}}),n.join("")},navigateTo(e){history.pushState(null,null,e),r=e,i("contentBody").then(()=>{l()})},registerData(e,t){Object.defineProperty(u,e,{get:function(){return this["_"+e]},set:function(t){this["_"+e],this["_"+e]=t,h(e)}}),u[e]=t},addData(e,t){var n=[];(n=u[e]).push(t),u[e]=n,n=[]},findIndexByKey:(e,t,n)=>wuObject.dataStore[e].findIndex(function(e){return e[t]==n}),updateData(e,t,n){var r=[];(r=u[e])[t=t-1<0?0:t-1]=n,u[e]=r,r=[]},removeData(e,t){var n=[];n=u[e],t=t-1<0?0:t-1,n.splice(t,1),u[e]=n,n=[]},dataStore:u,onLoad(e){Object.defineProperty(d,"trigger",{get:function(){return this._trigger},set:function(e){this._trigger,this._trigger=e,window[e]()}}),d.trigger=e},components:p,init:T}}(),window.wuObject=new wirup; \ No newline at end of file diff --git a/example/js/Wirup.js b/example/js/Wirup.js index 5bac611..0c5b1ba 100644 --- a/example/js/Wirup.js +++ b/example/js/Wirup.js @@ -68,7 +68,7 @@ wirup.prototype = (function () { _fillView = (index, target) => { return _wijax( "GET", - "views/" + _views[index]["HTML"], + "views/" + _views[index]["viewFile"], "text/plain; charset=UTF-8", (data) => { _getElement(target).innerHTML = data; diff --git a/example/js/Wirup.min.js b/example/js/Wirup.min.js index 2d18bc9..5ed0610 100644 --- a/example/js/Wirup.min.js +++ b/example/js/Wirup.min.js @@ -1 +1 @@ -"use strict";var wirup=function(){};wirup.prototype=function(){var e,t=function(e){return document.getElementById(e)},n=(e,t,n,r)=>new Promise((a,o)=>{var i=new XMLHttpRequest;return i.open(e,t,!0),i.setRequestHeader("Content-Type",n),i.setRequestHeader("cache-control","no-cache"),i.setRequestHeader("expires","0"),i.setRequestHeader("expires","Tue, 01 Jan 1980 1:00:00 GMT"),i.setRequestHeader("pragma","no-cache"),i.onreadystatechange=()=>{if(4===i.readyState){if(200===i.status)a(r(i.responseText));else{let e=i.statusText||"Your ajax request threw an error.";o(e)}}},i.send(),i.responseText}),r=window.location.pathname,a=()=>n("GET","views/views.json","application/json; charset=UTF-8",o),o=t=>{e=JSON.parse(t).views},i=t=>new Promise((n,a)=>{let o;var i=r;if(void 0===r&&(window.location="/"),e){for(var c=0;c<=e.length-1;c++)e[c].url==i&&(o=c);void 0===o&&(o=0),s(o,t).then(()=>{n()})}}),s=(r,a)=>n("GET","views/"+e[r].HTML,"text/plain; charset=UTF-8",e=>{t(a).innerHTML=e}),c=()=>{window.onpopstate=e=>{r=window.location.pathname,T()}},u={},p={},d={},l=()=>new Promise(function(e,n){var r=t("contentBody").querySelectorAll("[datasource]");[].forEach.call(r,e=>{e.innerHTML=g(e.tagName.toLowerCase(),e.getAttribute("datasource"))}),y("Switched View","Content Body","No Comment."),e()}),h=e=>{t("contentBody").querySelectorAll('[datasource="'+e+'"]').forEach(t=>{t.innerHTML=g(t.tagName.toLowerCase(),e),y("Updated Data.",t.tagName.toLowerCase(),"No Comment.")})},g=(e,t)=>{let n="";var r=typeof u[t];switch(r){case"object":n=u[t].map((t,n)=>p[e](t));break;case"string":n=p[e](u[t])}return n.join("")},m=function(e){for(var t in e)"object"==typeof e[t]&&null!==e[t]&&m(e[t]),_key_list.push(e[t])},f=function(e){return new Promise((t,n)=>{var r=document.createElement("script");r.type="text/javascript",r.src=e+"?"+new Date().getTime(),document.getElementsByTagName("head")[0].appendChild(r),r.onload=()=>{t()},r.onabort=()=>{n()}})},w="",y=(e,t,n)=>{let r=new Date().getTime(),a={name:e,element:t,comment:n,profile:w,timestamp:r},o=localStorage.getItem("wuActions");localStorage.setItem("wuActions",o+","+JSON.stringify(a))},v=e=>window[e](),$=e=>new Promise(function(t,n){f("components/components.js").then(()=>{a().then(()=>{i("contentBody").then(()=>{l().then(()=>{c(),void 0!==e&&v(e)})})})})}),T=e=>{$(e)};return{wu:t,wijax:n,jsonize:function(e){try{return JSON.parse(window[e])}catch(t){return window[e]}},loadScript:f,registerComponent(e,t){p[e]=t},registerProfile(e){w=e},registerAction:y,buildComponent:g,buildComponents(e,t){let n="";return e.forEach((e,r)=>{switch(dataSourceType=typeof u[t[r]]){case"object":n=u[t[r]].map((t,n)=>p[e](t));break;case"string":n=p[e](u[t[r]])}}),n.join("")},navigateTo(e){history.pushState(null,null,e),r=e,i("contentBody").then(()=>{l()})},registerData(e,t){Object.defineProperty(u,e,{get:function(){return this["_"+e]},set:function(t){this["_"+e],this["_"+e]=t,h(e)}}),u[e]=t},addData(e,t){var n=[];(n=u[e]).push(t),u[e]=n,n=[]},findIndexByKey:(e,t,n)=>wuObject.dataStore[e].findIndex(function(e){return e[t]==n}),updateData(e,t,n){var r=[];(r=u[e])[t=t-1<0?0:t-1]=n,u[e]=r,r=[]},removeData(e,t){var n=[];n=u[e],t=t-1<0?0:t-1,n.splice(t,1),u[e]=n,n=[]},dataStore:u,onLoad(e){Object.defineProperty(d,"trigger",{get:function(){return this._trigger},set:function(e){this._trigger,this._trigger=e,window[e]()}}),d.trigger=e},components:p,init:T}}(),window.wuObject=new wirup; \ No newline at end of file +"use strict";var wirup=function(){};wirup.prototype=function(){var e,t=function(e){return document.getElementById(e)},n=(e,t,n,r)=>new Promise((a,o)=>{var i=new XMLHttpRequest;return i.open(e,t,!0),i.setRequestHeader("Content-Type",n),i.setRequestHeader("cache-control","no-cache"),i.setRequestHeader("expires","0"),i.setRequestHeader("expires","Tue, 01 Jan 1980 1:00:00 GMT"),i.setRequestHeader("pragma","no-cache"),i.onreadystatechange=()=>{if(4===i.readyState){if(200===i.status)a(r(i.responseText));else{let e=i.statusText||"Your ajax request threw an error.";o(e)}}},i.send(),i.responseText}),r=window.location.pathname,a=()=>n("GET","views/views.json","application/json; charset=UTF-8",o),o=t=>{e=JSON.parse(t).views},i=t=>new Promise((n,a)=>{let o;var i=r;if(void 0===r&&(window.location="/"),e){for(var c=0;c<=e.length-1;c++)e[c].url==i&&(o=c);void 0===o&&(o=0),s(o,t).then(()=>{n()})}}),s=(r,a)=>n("GET","views/"+e[r].viewFile,"text/plain; charset=UTF-8",e=>{t(a).innerHTML=e}),c=()=>{window.onpopstate=e=>{r=window.location.pathname,T()}},u={},p={},d={},l=()=>new Promise(function(e,n){var r=t("contentBody").querySelectorAll("[datasource]");[].forEach.call(r,e=>{e.innerHTML=g(e.tagName.toLowerCase(),e.getAttribute("datasource"))}),v("Switched View","Content Body","No Comment."),e()}),h=e=>{t("contentBody").querySelectorAll('[datasource="'+e+'"]').forEach(t=>{t.innerHTML=g(t.tagName.toLowerCase(),e),v("Updated Data.",t.tagName.toLowerCase(),"No Comment.")})},g=(e,t)=>{let n="";var r=typeof u[t];switch(r){case"object":n=u[t].map((t,n)=>p[e](t));break;case"string":n=p[e](u[t])}return n.join("")},m=function(e){for(var t in e)"object"==typeof e[t]&&null!==e[t]&&m(e[t]),_key_list.push(e[t])},f=function(e){return new Promise((t,n)=>{var r=document.createElement("script");r.type="text/javascript",r.src=e+"?"+new Date().getTime(),document.getElementsByTagName("head")[0].appendChild(r),r.onload=()=>{t()},r.onabort=()=>{n()}})},w="",v=(e,t,n)=>{let r=new Date().getTime(),a={name:e,element:t,comment:n,profile:w,timestamp:r},o=localStorage.getItem("wuActions");localStorage.setItem("wuActions",o+","+JSON.stringify(a))},y=e=>window[e](),$=e=>new Promise(function(t,n){f("components/components.js").then(()=>{a().then(()=>{i("contentBody").then(()=>{l().then(()=>{c(),void 0!==e&&y(e)})})})})}),T=e=>{$(e)};return{wu:t,wijax:n,jsonize:function(e){try{return JSON.parse(window[e])}catch(t){return window[e]}},loadScript:f,registerComponent(e,t){p[e]=t},registerProfile(e){w=e},registerAction:v,buildComponent:g,buildComponents(e,t){let n="";return e.forEach((e,r)=>{switch(dataSourceType=typeof u[t[r]]){case"object":n=u[t[r]].map((t,n)=>p[e](t));break;case"string":n=p[e](u[t[r]])}}),n.join("")},navigateTo(e){history.pushState(null,null,e),r=e,i("contentBody").then(()=>{l()})},registerData(e,t){Object.defineProperty(u,e,{get:function(){return this["_"+e]},set:function(t){this["_"+e],this["_"+e]=t,h(e)}}),u[e]=t},addData(e,t){var n=[];(n=u[e]).push(t),u[e]=n,n=[]},findIndexByKey:(e,t,n)=>wuObject.dataStore[e].findIndex(function(e){return e[t]==n}),updateData(e,t,n){var r=[];(r=u[e])[t=t-1<0?0:t-1]=n,u[e]=r,r=[]},removeData(e,t){var n=[];n=u[e],t=t-1<0?0:t-1,n.splice(t,1),u[e]=n,n=[]},dataStore:u,onLoad(e){Object.defineProperty(d,"trigger",{get:function(){return this._trigger},set:function(e){this._trigger,this._trigger=e,window[e]()}}),d.trigger=e},components:p,init:T}}(),window.wuObject=new wirup; \ No newline at end of file diff --git a/example/views/views.json b/example/views/views.json index 3e61845..d3dc204 100644 --- a/example/views/views.json +++ b/example/views/views.json @@ -3,17 +3,17 @@ { "viewName": "listView", "url": "/", - "HTML": "listView.html" + "viewFile": "listView.html" }, { "viewName": "rocketsView", "url": "/rockets", - "HTML": "rocketsView.html" + "viewFile": "rocketsView.html" }, { "viewName": "priceView", "url": "/prices", - "HTML": "priceView.html" + "viewFile": "priceView.html" } ] } \ No newline at end of file