0?t.substring(0,e):t).replace(/\s/g,"");r&&(u=c(window,r))}if(u&&s(u))try{a=u.apply(e,o(i)?[]:n(i)?i:[i])}catch(t){console.error("Error calling function:",u,",",t)}else console.error("Invalid function:",t);return a}function l(t,e){let r={},n="string"==typeof t?h(t):t,i=(t,e)=>{r.hasOwnProperty(t)?(Array.isArray(r[t])||(r[t]=r[t]?[r[t]]:[]),e&&r[t].push(e)):r[t]=e};return[].slice.call(n.elements).forEach(t=>{!t.name||t.disabled||t.matches("form fieldset[disabled] *")||("checkbox"!==t.type&&"radio"!==t.type||t.checked)&&("SELECT"===t.tagName?("select-multiple"===t.type&&t.selectedIndex>=0&&i(t.name,[]),g("option",t).forEach(e=>{e.selected&&i(t.name,e.value)})):i(t.name,t.value))}),e?f(r):r}function f(t){let e="";return Object.keys(t).forEach(r=>{Array.isArray(t[r])?t[r].forEach(t=>{e+="&"+r+"="+t}):e+="&"+r+"="+t[r]}),encodeURI(e)}function h(t,e){return d(t,e)[0]}function g(t,e){return d(t,e)}function d(t,e){return e="string"==typeof e&&B.querySelector(e)||e||B,Array.prototype.slice.call(e.querySelectorAll(t))}function p(t,e,r){t.setAttribute(r,t.getAttribute(e)),t.removeAttribute(e)}function b(t){let e=B.createElement("script");e.text=t.innerHTML;for(let r=t.attributes.length-1;r>=0;r--)e.setAttribute(t.attributes[r].name,t.attributes[r].value);return e}function m(t,e,r){let n,i,o,s,a,c=oldSrc=(t.getAttribute(e)||"").trim();2===arguments.length&&(r=t.closest("[x-src]")),c&&r&&!/^(\/\/|http:\/\/|https:\/\/)/i.test(c)&&(a=O(r.getAttribute("x-src")),n=(M||a).replace(/^\/+/,""),i=new RegExp("^((.){0,2}/)*"+n),i.test(c)?c=c.replace(i,M||a):"."===c[0]&&(o=r&&r.getAttribute("x-src")||"",s=o.substring(0,o.lastIndexOf("/")+1)||(M||a)+"/",c=(s+c).replace(/\/\.?\//,"/"))),c!==oldSrc&&t.setAttribute(e,c)}function A(t,e){d("script:not([processed])",t).forEach(t=>{t.setAttribute("processed",""),e&&t.setAttribute("await","");let r=b(t);if(r.hasAttribute("src")){m(r,"src",t.closest("[x-src]"));let n=r.getAttribute("src");!/\.js$/i.test(n)&&r.setAttribute("src",n+".js");let i=!r.hasAttribute("await");!e&&i?t.parentNode.replaceChild(r,t):(p(t,"src","x-src"),T(r))}else t.parentNode.replaceChild(r,t)})}function E(t){d('link[rel="stylesheet"][href]:not([processed])',t).forEach(t=>{m(t,"href"),t.setAttribute("processed","")}),d("img[src]:not([processed])",t).forEach(t=>{!/^data:/i.test(t.getAttribute("src"))&&m(t,"src"),t.setAttribute("processed","")})}function y(){let t,e=(B.body.getAttribute("hash-error")||"").toLowerCase(),r=K.origin+K.pathname+K.search;"url"==e?(t="Page_route["+z.substring(1)+"]_not_found!_Redirected_to_this_page_root.",r=K.origin+K.pathname+"?_error="+t+K.search.replace(/^\?/,"&")):(t="Page route[#"+z.substring(1)+"] not found! Redirecting to this page root.",alert(t)),K.href=r}function x(t,e){if(X)if(t=t||z,t){let r=d('[url-hash="'+t+'"][x-target^="#"],[href="'+t+'"]');if(r.length)e&&r[0].setAttribute("skip-hash-update","1"),(!e||J&&e==z)&&(z=""),H=V,C.call(r[0],!0,e);else if(!P)if(z.indexOf(Q)>0){let t=(W&&W.split(Q)||[]).length,e=q[t];e||t<=q.length?(W+=(W?Q:"")+e,J=d('[url-hash="'+W+'"][x-target^="#"]').length?0:250,setTimeout(()=>{x(W,z)},J)):y()}else if(!j().length){let t=h(z);t?(t.scrollIntoView(!0),z=""):y()}}else{let t=d("[skip-on-hash]");t.length&&(t.forEach(t=>{t.removeAttribute("skip-on-hash")}),N())}}function w(t,e){P--;let r=t.getAttribute("x-js");if(r&&(e+='',t.removeAttribute("x-js")),"SCRIPT"==t.tagName){if(e.trim()){let t=B.createElement("script");t.id=(new Date).getMilliseconds(),t.text=e,B.head.appendChild(t).parentNode.removeChild(t)}}else{let r=t.hasAttribute("replace")||t.tagName.indexOf("REPLACE")>=0,n=r?t.parentNode:t,i=r?"outerHTML":"innerHTML",o=t.hasAttribute("await");e=e||"",t[i]=e,E(n),A(n,o),N(n)}x()}function v(t,e,r){o(t)?(t="Could not "+r.method+" "+e.url,r.onError&&(t=u(r.onError,null,[t,e.status,e]))):r.onSuccess&&(t=u(r.onSuccess,null,[t,e.status,e])),o(t)||w(r.targetEl,t)}function O(t){let e="";if(t.indexOf("/")>=0){let r=t.indexOf("/"),n=t.indexOf("/",r+1);e=("/"===t[0]||"."===t[0])&&n>r?t.substring(0,n):t.substring(0,r)}return e}function S(t){"?"===M&&t.indexOf("/")>=0&&(M=O(t))}function k(t){let e,r,n=(t||"").trim(),i="";if(!/^(\/\/|http:\/\/|https:\/\/)/i.test(n)&&(i=/\+$/.test(n)?"+":"",i&&(n=n.substring(0,n.length-1)),S(n),M&&(/^[^a-z0-9_\.\/]/gi.test(n[0])?n=n.substring(1):(e=M.replace(/^\/+/,""),r=new RegExp("^((.){0,2}/)*"+e),n=r.test(n)?n.replace(r,M):(M+"/"+n).replace(/\/\.?\//,"/"))),G&&!new RegExp(G+"$").test(n)))if(/\/\/$/.test(t)){let t=n.split("/"),e=t[t.length-2];n=n+e+G}else"/"!==n[n.length-1]&&(n+=G);return n+i}function T(t,e,r){if(r=r||{method:"GET"},e=k(e||t.getAttribute("src")),t.setAttribute("x-src",e),t.removeAttribute("src"),e){P++,/\+$/.test(e)&&(t.setAttribute("x-js",e.replace(/\.[a-z]{3,4}\+$/,".js")),e=e.substring(0,e.length-1));let n=r.method||"GET",i=r.data,o={}.toString.call(i).slice(8,-1).toLowerCase(),s="string"==o?i:"";i&&("GET"==n?("object"===o&&(s=f(i)),e=e+(s&&e.indexOf("?")<0?"?":"")+s,e=e.replace(/\?\&/,"?").replace(/\&\&/g,"&")):"object"===o&&(i=JSON.stringify(i))),r.targetEl=t,r.method=n;let a={method:n};if(i&&(a.body=i),t.hasAttribute("await"))(async()=>{let t;const n=await fetch(e,a).catch(t=>null);n&&n.ok&&(t=await n.text()),v(t,n,r)})();else{let t;fetch(e,a).then(e=>{let r;return t=e,e&&e.ok&&(r=e.text()),r}).then(e=>{v(e,t,r)}).catch(t=>null)}}}function L(t){if(X){if(!t.getAttribute("skip-hash-update")){let e=t.getAttribute("url-hash");if("#"!=e&&H!=e){H=e;try{history.pushState(null,e,e)}catch(t){}}}t.removeAttribute("skip-hash-update")}}function C(t,e){let r=this,n="FORM"==r.tagName;if(t&&e&&!n)return void r.click();if(n&&!r.checkValidity())return r.reportValidity(),!1;let i=r.getAttribute("if");if(i){let t=u(i,r);if(!t)return!1}let o=h(r.getAttribute("x-target"));if(o){o[r.hasAttribute("replace")?"setAttribute":"removeAttribute"]("replace",""),r.hasAttribute("await")&&o.setAttribute("await",""),r.hasAttribute("async")&&o.removeAttribute("await",""),n||L(r);let t=r.getAttribute("x-href").substring(1);if(/^[! ]/.test(t)&&(t=t.substring(1).trim()),n){t=t||r.getAttribute("action");let e=r.getAttribute("method")||"GET",n=r.hasAttribute("form-data")?"FormData":"JSON",i="GET"==e?l(r,!0):/FormData/gi.test(n)?new FormData(r):l(r),s=r.onSuccess||r.getAttribute("onsuccess")||"",a=r.onError||r.getAttribute("onerror")||"",c={method:e,data:i,onSuccess:s,onError:a};r.onSuccess="",r.onError="",T(o,t,c)}else T(o,t)}else console.warn("Target element not found. Invalid target specified in element",r)}function j(t){return t=t||B,d("[src]"+"audio embed iframe img input script source track video [processed] [skip-on-hash]".split(" ").map(function(t){return":not("+t+")"}).join(""),t)}function N(t){t=t||B;let e=j(t);e.forEach(t=>{m(t,"src"),t.setAttribute("processed",""),T(t)}),d("form:not([onsubmit]):not([href])",t).forEach(t=>{!t.getAttribute("action")&&t.setAttribute("onsubmit","return false;")}),d('form[action][target^="#"]',t).forEach(t=>{let e=t.getAttribute("action");e&&(t.setAttribute("href","#"+e.replace(/^#+/,"")),!t.hasAttribute("onsubmit")&&t.setAttribute("onsubmit","return false;"))}),d('[href^="#"][target^="#"]',t).forEach(t=>{p(t,"target","x-target"),p(t,"href","x-href"),t.setAttribute("href","javascript:;");let e=t.getAttribute("url-hash")||t.getAttribute("x-href");!/^#/.test(e)&&(e="#"+e),/^#[! ]+/.test(e)&&(e="#"),e=e.replace(/[+ ]/g,"").replace(new RegExp("\\"+Q+"+$"),""),t.setAttribute("url-hash",e);let r="FORM"==t.tagName,n=r?"submit":"click",i=(t.getAttribute("on")||n).replace(/[^a-z]/gi,"_");r&&!t.getAttribute("onsubmit")&&t.setAttribute("onsubmit","return false;"),i.split("_").forEach(e=>{e=e.trim().toLowerCase(),e.length>2&&(e=e.replace(/^on/,""),t.addEventListener(e,C))})}),!e.length&&D()}function R(t,e){return fetch(t).then(e=>{let r=e.status;return e.ok&&(r>=200&&r<300||304==r)?e.json():{error:"Failed: [GET]"+t,status:r}}).then(t=>e(t)).catch(r=>e({error:"Failed: [GET]"+t,e:r}))}function _(t,e,r){let n=d(e)[0];n?("function"==typeof r&&Y.push(r),T(n,t)):console.error("Target container not found.",e)}function F(t,e){e=e||{method:"",url:"",target:"",onSuccess:"",onError:""};let r=h(t);if(r){e.method&&r.setAttribute("method",e.method),e.url&&r.setAttribute("x-href","#"+e.url.replace(/^#+/,"")),e.target&&r.setAttribute("x-target",e.target),e.onSuccess&&(r.onSuccess=e.onSuccess),e.onError&&(r.onError=e.onError);let t=document.createEvent("Event");t.initEvent("submit",!0,!0),r.dispatchEvent(t)}else console.error("Form NOT FOUND!",t)}function $(t,e){"function"==typeof t&&(Y.push({fn:t,delay:e||0}),D())}function D(t){P||j().length||!Y.length||void 0!==t&&!t||(U=Y.shift(),setTimeout(()=>{let e=U.fn(t);void 0!==e&&!e&&(Y=[]),D(e)},U.delay))}function I(){P=0,z=K.hash||"",q=X&&z&&z.split(Q)||[],M=(B.body.getAttribute("components-loc")||"").replace(/^\.\//,"").replace(/\/+$/g,"").trim(),G=(B.body.getAttribute("components-ext")||"").trim(),N(),setTimeout(function(){new MutationObserver(t=>{t&&t[0]&&"childList"===t[0].type&&t[0].target&&N(t[0].target)}).observe(B,{childList:!0,subtree:!0})})}let M,G,P,z,H,V,q,J,U,B=document,K=B.location,Q="/",W="",X="off"!=(B.body.getAttribute("url-hash")||"").toLowerCase(),Y=[];X&&(window.onhashchange=function(){V=K.hash||"",V?V!=H&&(z=V,x()):(K.href.indexOf("#")<0&&K.reload(),H="#")}),"complete"==B.readyState||"loading"!=B.readyState&&!B.documentElement.doScroll?I():B.addEventListener("DOMContentLoaded",I),t.alt=t.aif={load:_,onReady:$,getData:R,formData:l,submitForm:F}})(this);
--------------------------------------------------------------------------------
/example/html-files/footer.html:
--------------------------------------------------------------------------------
1 |
2 | © 2020 - OpenSource.
3 |
--------------------------------------------------------------------------------
/example/html-files/header.html:
--------------------------------------------------------------------------------
1 |
2 | Navbar
3 |
4 |
5 |
6 |
7 |
18 |
--------------------------------------------------------------------------------
/example/html-files/home.html:
--------------------------------------------------------------------------------
1 |
2 |
Hello, world!
3 |
This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.
4 |
5 |
It uses utility classes for typography and spacing to space content out within the larger container.
6 |
7 | Learn more
8 |
9 |
--------------------------------------------------------------------------------
/example/html-files/nav-menu.html:
--------------------------------------------------------------------------------
1 |
11 |
12 |
--------------------------------------------------------------------------------
/example/html-files/profile.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
Card title
5 |
Some quick example text to build on the card title and make up the bulk of the card's content.
6 |
Go somewhere
7 |
8 |
--------------------------------------------------------------------------------
/example/html-files/search-result.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Cras justo odio
4 | 14
5 |
6 |
7 | Dapibus ac facilisis in
8 | 2
9 |
10 |
11 | Morbi leo risus
12 | 1
13 |
14 |
--------------------------------------------------------------------------------
/example/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | alt-iframe
8 |
9 |
10 |
11 |
12 |
13 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/example2/components/footer.html:
--------------------------------------------------------------------------------
1 |
2 | © 2020 - OpenSource.
3 |
--------------------------------------------------------------------------------
/example2/components/header.html:
--------------------------------------------------------------------------------
1 |
2 | Navbar
3 |
4 |
5 |
6 |
7 |
18 |
--------------------------------------------------------------------------------
/example2/components/home.html:
--------------------------------------------------------------------------------
1 |
2 |
Hello, world!
3 |
This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.
4 |
5 |
It uses utility classes for typography and spacing to space content out within the larger container.
6 |
7 | Learn more
8 |
9 |
--------------------------------------------------------------------------------
/example2/components/home.js:
--------------------------------------------------------------------------------
1 | console.log('inside home.js');
--------------------------------------------------------------------------------
/example2/components/nav-menu.html:
--------------------------------------------------------------------------------
1 |
11 |
12 |
--------------------------------------------------------------------------------
/example2/components/profile/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
Card title
5 |
Some quick example text to build on the card title and make up the bulk of the card's content.
6 |
Go somewhere
7 |
8 |
9 |
19 |
20 |
--------------------------------------------------------------------------------
/example2/components/profile/index.js:
--------------------------------------------------------------------------------
1 | console.log('inside profile index.js');
--------------------------------------------------------------------------------
/example2/components/profile/section1.html:
--------------------------------------------------------------------------------
1 |
2 |
Section - 1
3 |
4 |
14 |
--------------------------------------------------------------------------------
/example2/components/profile/section2.html:
--------------------------------------------------------------------------------
1 |
2 |
Section - 2
3 |
--------------------------------------------------------------------------------
/example2/components/profile/section3.html:
--------------------------------------------------------------------------------
1 |
2 |
Section - 3
3 |
--------------------------------------------------------------------------------
/example2/components/profile/subSection1.1.html:
--------------------------------------------------------------------------------
1 |
2 |
Sub Section - 1
3 |
4 |
5 |
6 |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cum enim incidunt quos fugit officiis. Ad repellendus delectus ut optio quia quasi enim, nihil facilis quae voluptatum maiores harum sequi asperiores.
7 |
Praesentium eum, itaque dolor doloremque, magnam possimus eos fuga doloribus, sint sit est delectus distinctio eius recusandae enim nesciunt debitis dicta! Asperiores fugit sunt magni blanditiis illum, expedita distinctio dolorum?
8 |
Similique ut enim architecto provident quibusdam sed facere doloribus modi eligendi sint? Commodi aut provident ipsam aliquam ratione aperiam minima totam, fuga magnam sapiente, perferendis laboriosam voluptatum asperiores unde iste.
9 |
Commodi, magni fugit culpa iste quidem tempora mollitia consequuntur voluptas obcaecati, maiores veritatis consequatur dicta nesciunt quam ut repellendus eveniet doloremque eos non placeat officia accusamus? Nulla enim qui laborum.
10 |
Iusto perspiciatis ipsa fuga magnam dolore molestiae itaque nostrum officia at, adipisci eos nobis deserunt ullam ab nulla a fugiat pariatur voluptatum cumque, animi culpa assumenda et error? Ex, dolorum!
11 |
Possimus, nobis nisi tempore odio itaque quisquam repellendus repudiandae dignissimos adipisci porro consectetur vel quaerat necessitatibus facilis quae fugiat quibusdam aspernatur eum illo asperiores harum ipsa atque! In, natus tempore?
12 |
Fuga, odio rerum. Saepe vero consequatur nostrum facilis. Quam praesentium corrupti minus voluptas? Quo quisquam sed dolorem veniam, minima nulla facere unde consequuntur magnam incidunt saepe. Numquam dolor nulla mollitia?
13 |
Quaerat, velit similique odit magnam nulla non praesentium corrupti unde asperiores voluptas, sit atque. Deleniti, corporis omnis tempore et aspernatur perspiciatis qui voluptatum distinctio exercitationem. Culpa ex eum voluptates amet.
14 |
Totam, illo. Quae optio quisquam, provident numquam sit fuga quo neque tempora quia molestias, ad magni aspernatur suscipit eos explicabo nisi alias. Tempore distinctio sed, dignissimos quasi ad placeat fuga.
15 |
Perferendis placeat nisi eligendi nostrum accusantium quasi esse rerum asperiores. Placeat inventore ab eaque, harum eligendi mollitia? Aut reiciendis, earum velit maxime distinctio repellendus, aliquam voluptatibus praesentium qui, id magnam!
16 |
17 | TOP
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/example2/components/profile/subSection1.2.html:
--------------------------------------------------------------------------------
1 |
2 |
Sub Section - 2
3 |
4 |
--------------------------------------------------------------------------------
/example2/components/profile/subSection1.3.html:
--------------------------------------------------------------------------------
1 |
2 |
Sub Section - 3
3 |
4 |
--------------------------------------------------------------------------------
/example2/components/search-result.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Cras justo odio
4 | 14
5 |
6 |
7 | Dapibus ac facilisis in
8 | 2
9 |
10 |
11 | Morbi leo risus
12 | 1
13 |
14 |
--------------------------------------------------------------------------------
/example2/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | alt-iframe
8 |
9 |
10 |
11 |
12 |
13 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/example3/components/appRoot.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | © 2021. Open Source - MIT.
7 |
--------------------------------------------------------------------------------
/example3/components/asyncForm.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Async Form
4 |
5 |
103 |
104 |
105 |
106 |
Response:
107 |
108 |
109 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/example3/components/contacts.html:
--------------------------------------------------------------------------------
1 | Contacts
2 |
3 |
4 |
5 | Avatar
6 | First, Last Name
7 | email
8 | Action
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | {{#each data as |contact index| }}
17 |
18 |
19 |
21 |
22 | {{first_name}}, {{last_name}}
23 | {{email}}
24 |
25 | view/Edit
28 |
29 |
30 | {{/each}}
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/example3/components/home.html:
--------------------------------------------------------------------------------
1 |
2 |
Hello, world!
3 |
This is a simple Low-Code Single Page Application built using nano-javascript library (alt-iframe ).
4 |
You can use this library to build rapid prototypes with low-code. It's component based, so it's easy to port to other frameworks for production.
5 |
6 |
It is built on vanilla javascript and works on all modern browsers including IE11.
7 |
Learn more
8 |
9 |
10 |
--------------------------------------------------------------------------------
/example3/components/myProfile.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/example3/components/nav.html:
--------------------------------------------------------------------------------
1 |
2 | Demo App
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
14 |
17 |
20 |
23 |
24 | Async Form
25 |
26 |
27 |
28 |
29 |
30 | Search
31 |
32 |
33 |
--------------------------------------------------------------------------------
/example3/components/profileCard.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/example3/components/profileEdit.html:
--------------------------------------------------------------------------------
1 | Edit Profile
2 |
3 |
4 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/example3/components/search.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/example3/components/template-Handlebars.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Template
5 |
6 | Hi {{ member.firstName }} {{ member.lastName }},
7 |
8 | Welcome to Handlebars!
9 |
10 |
11 |
12 | Data (JSON)
13 |
14 | {
15 | "member" : {
16 | "firstName": "Yehuda",
17 | "lastName": "Katz"
18 | }
19 | }
20 |
21 |
22 |
23 |
Preview
24 |
cT: ms
25 |
rT: ms
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/example3/components/template-Mustache.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Template
5 |
6 | * {{name.first}} {{name.last}}
7 | * {{age}}
8 |
9 |
10 |
11 | Data (JSON)
12 |
13 | {
14 | "name": {
15 | "first": "Michael",
16 | "last": "Jackson"
17 | },
18 | "age": "RIP"
19 | }
20 |
21 |
22 |
23 |
Preview
24 |
cT: ms
25 |
rT: ms
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/example3/components/template-doT.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Template
5 |
6 | Hi {{=it.name}}!
7 | {{=it.age || ''}}
8 |
9 |
10 |
11 | Data (JSON)
12 |
13 | {
14 | "name":"Jake",
15 | "age":31
16 | }
17 |
18 |
19 |
20 |
Preview
21 |
cT: ms
22 |
rT: ms
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example3/components/template-dust.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Template
5 |
6 | Hello, {#friend}{name}{/friend}.
7 |
8 |
9 |
10 | Data (JSON)
11 |
12 | {
13 | "name": "John",
14 | "nickname": "Jingleheimer Schmidt",
15 | "friend": {
16 | "name": "Jacob"
17 | }
18 | }
19 |
20 |
21 |
22 |
Preview
23 |
cT: ms
24 |
rT: ms
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/example3/components/template-ejs.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Template
5 |
6 | <% if (user) { %>
7 | <%= user.name %>
8 | <% } %>
9 |
10 |
11 |
12 | Data (JSON)
13 |
14 | {
15 | "user" : {
16 | "name": "John",
17 | "nickname": "Jingleheimer Schmidt",
18 | "friend": {
19 | "name": "Jacob"
20 | }
21 | }
22 | }
23 |
24 |
25 |
26 |
Preview
27 |
cT: ms
28 |
rT: ms
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/example3/components/template-lodash.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Template
5 |
6 | Hello <%= name %>,
7 |
8 | Welcome to Underscore!
9 |
10 |
11 |
12 | Data (JSON)
13 |
14 | {
15 | "name": "moe"
16 | }
17 |
18 |
19 |
20 |
Preview
21 |
cT: ms
22 |
rT: ms
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example3/components/template-nunjucks.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Template
5 |
6 | {{ foo.bar }}
7 | {{ foo["version"] }}
8 |
9 |
10 |
11 | Data (JSON)
12 |
13 | {
14 | "foo": {
15 | "bar" : "nunjucks",
16 | "version": "3.2.3"
17 | }
18 | }
19 |
20 |
21 |
22 |
Preview
23 |
cT: ms
24 |
rT: ms
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/example3/components/template-nxT.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Template
5 |
6 | Hi {{ member.firstName }} {{ member.lastName }},
7 |
8 | Welcome to nxT!
9 |
10 |
11 |
12 | Data (JSON)
13 |
14 | {
15 | "member" : {
16 | "firstName": "Mark",
17 | "lastName": "Smith"
18 | }
19 | }
20 |
21 |
22 |
23 |
Preview
24 |
cT: ms
25 |
rT: ms
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/example3/components/template-template7.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Template
5 |
6 | Hello, my name is {{firstName}} {{lastName}}
7 |
8 |
9 |
10 | Data (JSON)
11 |
12 | {
13 | "firstName": "John",
14 | "lastName": "Doe"
15 | }
16 |
17 |
18 |
19 |
Preview
20 |
cT: ms
21 |
rT: ms
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/example3/components/templates.html:
--------------------------------------------------------------------------------
1 |
2 |
Templates Preview
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/example3/css/style.css:
--------------------------------------------------------------------------------
1 | .fixed-bottom {
2 | height: 50px;
3 | padding: 10px;
4 | color: #aaa;
5 | background-color: #eee;
6 | text-align: right;
7 | position: fixed;
8 | left:0;
9 | bottom:0;
10 | width: 100%;
11 | }
12 |
13 | .nav-item.active {
14 | border-top: 2px solid orange;
15 | }
--------------------------------------------------------------------------------
/example3/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | SPA - Ajax
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/example3/js/common.js:
--------------------------------------------------------------------------------
1 | function getProfile(pid) {
2 |
3 | $.ajax('https://reqres.in/api/users/' + pid)
4 | .done(function (apiData) {
5 | // console.log('🚀 ~ apiData', apiData);
6 |
7 | var profData = apiData.data;
8 | // console.log('🚀 ~ profData', profData);
9 |
10 | showProfile(profData);
11 | });
12 |
13 | }
14 |
15 | // bind without template
16 | function showProfile(profData) {
17 |
18 | var fullName = profData.first_name + ' ' + profData.last_name;
19 |
20 | $('#profImg').attr({
21 | src: profData.avatar,
22 | alt: fullName
23 | });
24 |
25 | $('#profFullName').html(fullName);
26 | $('#profEmail').html(profData.email);
27 |
28 | }
29 |
30 | // Highlight nav menu item
31 | function setMenu(menuLink) {
32 | $(menuLink).addClass('active').siblings().removeClass('active');
33 | }
34 |
35 | // Template Preview links click event listener
36 | $(document).on('click', '.btn-preview', function (e) {
37 | var btnPreview = e.target;
38 | var $section = $(btnPreview).closest('section');
39 | // var tmplType = $section.data('type');
40 | // var tmplContent = $section.find('textarea')[0].value;
41 | var tmplData = JSON.parse($section.find('textarea')[1].value.trim() || '{}');
42 | var previewTarget = $section.find('.preview')[0];
43 | var elTmplSrc = $section.find('textarea')[0];
44 |
45 | // nxT(tmplType+':'+tmplContent, tmplData, previewTarget); //tmpl: template-content with type: prefix; Handlebars: ...
46 | // nxT('#tmpl-'+tmplType, tmplData, previewTarget); //tmpl: template-element-ID; #templateXyz
47 | // nxT('#tmpl-'+tmplType+':'+tmplType, tmplData, previewTarget); //tmpl: template-elementID with :type suffix; #templateXyz:Handlebars
48 |
49 | //tmpl: template-element
50 | nxT(elTmplSrc, tmplData, previewTarget, function () {
51 | $pT = $section.find('.performance-time');
52 | $pT[0].innerHTML = (elTmplSrc.getAttribute('compile-time'));
53 | $pT[1].innerHTML = (previewTarget.getAttribute('render-time'));
54 | });
55 |
56 | });
57 |
--------------------------------------------------------------------------------