objs-core 1.0.8 → 1.0.9
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.
- package/LICENSE.md +2 -17
- package/README.md +0 -1
- package/objs.1.0.js +3 -1
- package/objs.1.0.min.js +1 -1
- package/objs.npm.1.0.js +1 -1
- package/package.json +1 -1
- package/objs.1.0.js.zip +0 -0
- package/objs.1.0.min.js.zip +0 -0
- package/tests.js +0 -1
package/LICENSE.md
CHANGED
|
@@ -175,24 +175,9 @@
|
|
|
175
175
|
|
|
176
176
|
END OF TERMS AND CONDITIONS
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
Copyright 2024 Objs-core, Roman Torshin
|
|
179
179
|
|
|
180
|
-
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright [yyyy] [name of copyright owner]
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License")
|
|
196
181
|
|
|
197
182
|
Unless required by applicable law or agreed to in writing, software
|
|
198
183
|
distributed under the License is distributed on an "AS IS" BASIS,
|
package/README.md
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
# Objs
|
|
2
|
-
 
|
|
3
2
|
> Fast and simple library to increase developing speed by samples and state control, auto-tests, cache and other. You can develop new features with Objs without rewriting anything. Examples and full documentation are here: [Full Documentation](https://fous.name/objs) (sandbox and free samples are coming soon)
|
|
4
3
|
|
|
5
4
|
|
package/objs.1.0.js
CHANGED
package/objs.1.0.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @author Roman Torshin, Apache 2.0 licence
|
|
2
|
-
const o=e=>{let t={els:[],ie:{}},n=0,i=1,s=2,l=3,r="object",a="function",c,d=document,f=-1,g=0,h=0,p=[],u=0,y=0,m=e=>typeof e,S=(e,t)=>{for(let n in e)Object.hasOwnProperty.call(e,n)&&t(n,e)},L=o.onError||(()=>{}),E=e=>(...r)=>{try{let a=e(r[n],r[i],r[s],r[l]);return a!==c?a:t}catch(d){L(d)}},C=e=>{for(u=g;u<=f;u++)e()},$=e=>(m(e)!==r&&(e=o.first(e).el),e),Z=(e=!0,s=t.els)=>{let l=s.length;t.length=l,f=l-i,g=n,t.el=l?s[n]:c,t.last=l?s[f]:c,e&&(S(p,(e,n)=>{delete t[n[e]]}),p=[],t.ie={})},F=(e="")=>Array.from(d.querySelectorAll(e));t.reset=o;let v=(e,t,i)=>{S(t,s=>{let l=t[s];m(l)===a&&(l=l(i)),"append"===s&&m(l)===r&&(l.els&&(l=[l]),l[n]&&l[n].els&&(valueBuff=[],S(l,e=>{valueBuff.push(...l[e].els)}),l=valueBuff)),l!==c&&(["tag","sample","state"].includes(s)||(["html","innerHTML"].includes(s)?e.innerHTML=l:"dataset"===s&&m(l)===r?S(l,t=>{e.dataset[t]=l[t]}):"toggleClass"===s?e.classList.toggle(l):"addClass"===s?m(l)===r?e.classList.add(...l):e.classList.add(l):"removeClass"===s?e.classList.remove(l):"style"===s&&m(l)===r?S(l,t=>{e.style[t]=l[t]}):"append"===s&&m(l)===r?S(l.length?l:[l],t=>{e.appendChild(l[t])}):e.setAttribute(s,l)))}),e.dataset.oState=t.state};return t.init=E(e=>{let s=t.initID||o.inits.length||n;t.initID=s,Z(),o.inits[t.initID]=t,(m(e)!==r||e.render===c)&&(e={render:e}),S(e,l=>{p.push(l),t[l]=E((h=[{}])=>{let p=e[l]||{tag:"div"},S=t.els.slice(g,f+i);m(p)===r&&(p.state=l,p["data-o-init"]=s);let L=(e,t={})=>m(p)===r?d.createElement(p.tag||"div"):((u=d.createElement("div")).innerHTML=m(p)===a?p(t):p,u.children.length>i||!u.firstElementChild)?(u.dataset.oInit=e,u):(u.firstElementChild.dataset.oInit=e,u.firstElementChild);h.length||(h=[h]);let E=!S[n]&&"render"===l;h=h.map((e,n)=>(e.self=t,e.o=o,e.i=e.i===c?n:e.i,E&&S.push(L(s,e)),e)),E&&(t.els=S,Z(!1)),S&&(y=S.length===h.length,S.map((e,t)=>{h[y?t:n].i=t+g;let i=m(p)===a?p(h[y?t:n]):p;m(i)===r&&v(e,i,h[y?t:n])}))})})}),t.initState=E((e,n)=>{t.init(e).render(n)}),t.sample=E((e="render")=>{let i=t.els[g].attributes,s=t.els[g].dataset,l={tag:t.els[g].tagName,html:t.els[g].innerHTML,dataset:{}};for(let r of i)"data-"!==r.nodeName.substring(n,5)&&(l[r.nodeName]=r.value);return S(s,e=>{l.dataset[e]=s[e]}),{[e]:l}}),t.select=E(e=>{e===c&&(e=t.length-i),f=e,g=e,t.el=t.els[e],h=i}),t.all=E(()=>{f=t.length-i,g=n,t.el=t.els[n],h=n}),t.remove=E(e=>{e===c&&h&&(e=g),e!==c?t.els[e].parentNode.removeChild(t.els[e]):C(()=>{t.els[u].parentNode.removeChild(t.els[u])}),Z(!1)}),t.skip=E(e=>{e===c&&(e=g),t.els.splice(u,i),Z()}),t.add=E((e,i)=>{"string"===m(e)&&""!==e?t.els.push(...F(e)):m(e)===r?e.tagName?t.els.push(e):e.els?t.els.push(...e.els):e.length&&e[n].tagName&&t.els.push(...e):"number"===m(e)&&o.inits[e]&&(t=o.inits[e]),Z(!1),t.initID!==c&&t.dataset({oInit:t.initID})}),t.appendInside=E(e=>{C(()=>{$(e).appendChild(t.els[u])})}),t.appendBefore=E(e=>{C(()=>{$(e).parentNode.insertBefore(t.els[u],$(e))})}),t.appendAfter=E(e=>{C(()=>{$(e).after(...t.els)})}),t.find=E((e="")=>{let n=[];C(()=>{n.push(...Array.from(t.els[u].querySelectorAll(":scope "+e)))}),t.els=n,Z()}),t.first=E((e="")=>{let n=c,i=[];C(()=>{(n=t.els[u].querySelector(e))&&i.push(n)}),t.els=i,Z()}),t.attr=E((e,i)=>{if(e){if(i===c){let s=[];return C(()=>{s[u]=t.els[u].getAttribute(e)}),h?s[n]:s}""!==i?C(()=>{t.els[u].setAttribute(e,i)}):C(()=>{t.els[u].removeAttribute(e)})}}),t.attrs=E(()=>{let e=[];return C(()=>{let n={};[...t.els[u].attributes].forEach(e=>{n[e.nodeName]=e.nodeValue}),e.push(n)}),h?e[n]:e}),t.dataset=E(e=>{if(typeof e===r)C(()=>{S(e,n=>{t.els[u].dataset[n]=e[n]})});else{let i=[];return C(()=>{i.push({...t.els[u].dataset})}),h?i[n]:i}}),t.style=E(e=>{t.attr("style",e)}),t.css=E((e={})=>{let n="";S(e,t=>{n+=t+":"+e[t].replace('"',"'")+";"}),t.style(n)}),t.setClass=E(e=>{C(()=>{t.els[u].setAttribute("class",e)})}),t.addClass=E(e=>{C(()=>{t.els[u].classList.add(e)})}),t.removeClass=E(e=>{C(()=>{t.els[u].classList.remove(e)})}),t.toggleClass=E((e,n)=>{C(()=>{t.els[u].classList.toggle(e,n)})}),t.haveClass=e=>{let n=!0;return C(()=>{t.els[u].classList.contains(e)||(n=!1)}),n},t.innerHTML=E(e=>{if(e!==c)C(()=>{t.els[u].innerHTML=e});else{let n="";return C(()=>{n+=t.els[u].innerHTML}),n}}),t.innerText=E((e="")=>{C(()=>{t.els[u].innerText=e})}),t.textContent=E((e="")=>{C(()=>{t.els[u].textContent=e})}),t.html=E(e=>{if(e)t.innerHTML(e);else{let n="";return C(()=>{n+=t.els[u].outerHTML}),n}}),t.forEach=E(e=>{t.initState(e)}),t.on=E((e,n,i,s)=>{e.split(", ").forEach(e=>{C(()=>{t.els[u].addEventListener(e,n,i,s)}),t.ie[e]||(t.ie[e]=[]),t.ie[e].push([n,i,s])})}),t.off=E((e,i,s)=>{e.split(", ").forEach(e=>{C(()=>{t.els[u].removeEventListener(e,i,s)}),t.ie[e]&&(t.ie[e]=t.ie[e].filter(e=>e[n]!==i))})}),t.onAll=E((e,l)=>{S(t.ie,(r,a)=>{e&&e!==r||a[r].forEach(e=>{C(()=>{l?t.els[u].removeEventListener(r,e[n]):t.els[u].addEventListener(r,e[n],e[i],e[s])})})})}),t.offAll=E(e=>{t.onAll(e,i)}),e&&t.add(e),t.take=e=>{if(t.add(e),t.el){let s=t.el.dataset.oInit;if(s!==c&&o.inits[s])return t.length===i?(y=t.els[n],Object.assign(t,o.inits[s]),t.els=[y]):t=o.inits[s],Z(!1,t.els),t}},t};o.first=e=>o(document.querySelector(e)||""),o.inits=[],o.errors=[],o.showErrors=!1,o.logErrors=()=>{o.errors.length?o.errors.forEach(e=>console.log(e)):console.log("No errors")},o.onError=e=>{o.showErrors?console.log(e):o.errors.push(e)},o.init=e=>o().init(e),o.initState=(e,t)=>o().init(e).render(t),o.take=e=>o().take(e),o.Z=0,o.N=1,o.W=2,o.H=100,o.F=!1,o.C=(e,t)=>Object.hasOwnProperty.call(e,t),o.ajax=(e,t={})=>{let n=new URLSearchParams;if(t.data&&"object"==typeof t.data){for(let i in t.data)o.C(t.data,i)&&("object"==typeof t.data[i]?n.set(i,encodeURIComponent(JSON.stringify(t.data[i]))):n.set(i,t.data[i]));"GET"===t.method||"get"===t.method?e+="?"+n.toString():t.body||(t.body=n),delete t.data}return fetch(e,t)},o.get=(e,t={})=>o.ajax(e,{...t,method:"GET"}),o.post=(e,t={})=>o.ajax(e,{...t,method:"POST"}),o.getParams=e=>{let t={},n=new URLSearchParams(window.location.search).entries();for(let i of n)t[i[o.Z]]=i[o.N];return e?t[e]:t},o.incCache=!0,o.incCacheExp=864e5,o.incTimeout=6e3,o.incSource="",o.incForce=o.F,o.incAsync=!0,o.incCors=o.F,o.incFns={},o.incSet=[o.Z],o.incReady=[o.Z],o.incN=o.Z,o.incCheck=(e=0,t,n=0)=>!n&&e&&t===o.U&&o.incReady[e]?o.incSet[e]===o.N:o.incReady[e]===o.U||o.incReady[e][t]===o.U?o.F:(o.incReady[e][t].loaded=n,o.incFns[o.incReady[e][t].name]=n,o.incReady[e][o.Z]+=n,e&&o.incReady[e].length===o.incReady[e][o.Z]&&("function"==typeof o.incSet[e]&&o.incSet[e](e),o.incSet[e]=o.N),o.incSet[e]===o.N),o.incCacheClear=(e=o.F)=>{for(let t in o.incFns)o.C(o.incFns,t)&&(localStorage.removeItem("inc-"+t),localStorage.removeItem("inc-"+t+"Expires"));return e&&(o.incReady.forEach((e,t)=>{t&&e.forEach((e,n)=>{n&&o("#oInc-"+t+"-"+n).remove()})}),o.incN=o.Z,o.incFns={},o.incSet=[o.Z],o.incReady=[o.Z]),!0},o.inc=(e,t,n)=>{let i=o.Z,s=o.Z,l="function";if("object"!=typeof e||!e)return o.incSet[o.Z];o.incSet[o.Z]++;let r=o.incSet[o.Z];o.incSet[r]=t||o.Z,o.incReady[r]=[];let a=o.incReady[r];a[o.Z]=o.N;let c={};for(let d in e)if(o.C(e,d)){i++,o.incN++;let f=e[d].indexOf(".css")>-1?"style":"script";if(e[d]=(o.incSource?o.incSource+"/":"")+e[d],isNaN(d)&&o.C(o.incFns,d)&&o.incFns[d]&&!o.incForce){a[i]={name:d,loaded:o.N},s++;continue}if(a[i]={name:d,loaded:o.Z},isNaN(d)&&(o.incFns[d]=o.Z),isNaN(d)&&o.incCache&&"http"!==e[d].substring(o.Z,4)&&"file:"!==window.location.protocol&&(e[d].indexOf(".css")>-1||e[d].indexOf(".js")>-1)){let g=localStorage,h=g.getItem("inc-"+d),p=g.getItem("inc-"+d+"Expires");h&&p&&new Date().getTime()<p?(o.initState({tag:f,id:"oInc-"+r+"-"+i,innerHTML:h,"data-o-inc":r}).appendInside("head"),a[i].loaded=o.N,o.incFns[d]=o.N,s++):(c[d]=i,o.get(e[d],{mode:o.incCors?"cors":"same-origin"}).then(t=>{if(200!==t.status){o.onError&&o.onError({message:o.incSource+e[d]+" was not loaded"});return}t.text().then(e=>{g.setItem("inc-"+d,e),g.setItem("inc-"+d+"Expires",new Date().getTime()+o.incCacheExp),o.initState({tag:f,id:"oInc-"+r+"-"+c[d],innerHTML:e,"data-o-inc":r}).appendInside("head"),o.incCheck(r,c[d],o.N)})}))}else{let u={tag:f,id:"oInc-"+r+"-"+i,"data-o-inc":r,async:o.incAsync,onload:"o.incCheck("+r+","+i+",1)"};e[d].indexOf(".css")>-1?(u.tag="link",u.rel="stylesheet",u.href=e[d]):(e[d].indexOf(".js")>-1||(u.tag="img",u.style="display:none;"),u.src=e[d]),o.initState(u).appendInside(u.style?"body":"head")}}return a[o.Z]+=s,i!==o.Z&&(s===i?typeof t===l&&t(r):setTimeout(e=>{o.incReady[e]&&o.incReady[e].length<o.incReady[e][o.Z]&&(o.incSet[e]=o.Z,typeof n===l&&n(r))},o.incTimeout,r)),o.incSet[o.Z]},o.tLog=[],o.tRes=[],o.tStatus=[],o.tFns=[],o.tShowOk=o.F,o.tStyled=o.F,o.tTime=2e3,o.tPre='<div style="font-family:monospace;text-align:left;">',o.tOk='<span style="background:#cfc;padding: 0 15px;">OK</span> ',o.tXx='<div style="background:#fcc;padding:3px;">',o.tDc="</div>",o.test=(e="",...t)=>{let n=o.tLog.length,i=0,s="├ OK: ",l="├ ✘ ",r="\n",a="\n",c=t.length,d=o.Z;"function"==typeof t[c-o.N]&&(o.tFns[n]=t[c-o.N],c--),o.tStyled?(o.tLog[n]="<div><b>"+e+" #"+n+"</b></div>",s=o.tPre+o.tOk,l=o.tPre+o.tXx,a=(r=o.tDc)+r):o.tLog[n]=e+" #"+n+"\n",o.tRes[n]=o.F,o.tStatus[n]=[];for(let f=o.Z;f<c;f++){let g={n:n,i:f,title:t[f][o.Z],tShowOk:o.tShowOk,tStyled:o.tStyled},h=t[f][o.N];if("function"==typeof h)try{h=h(g)}catch(p){h=p.message,o.onError&&o.onError(p)}o.tStatus[n][f]="string"==typeof h?o.F:h,!0===h?(d++,o.tShowOk&&(o.tLog[n]+=s+t[f][o.Z]+r)):h!==o.U?o.tLog[n]+=l+t[f][o.Z]+(h!==o.F?": <i>"+h+"</i>":"")+a:(i++,setTimeout(e=>{e.title+=" (timeout)",o.testUpdate(e)},o.tTime,g))}return o.tRes[n]=d===c,o.tStyled?o.tLog[n]+=o.tPre+'<div style="color:'+(d+i!==c?"red":"green")+';"><b>':o.tLog[n]+=i?"├":"└ ",o.tLog[n]+="DONE "+d+"/"+(c-i),i&&(o.tLog[n]+=", waiting: "+i),o.tStyled?o.tLog[n]+="</b>"+o.tDc+o.tDc:o.tLog[n]+="\n",i||"function"!=typeof o.tFns[n]||o.tFns[n](n),n},o.testUpdate=(e,t=o.F,n="")=>{if(o.tStatus[e.n][e.i]===o.U){o.tStatus[e.n][e.i]=!0===t,!0===t?e.tShowOk&&(e.tStyled?o.tLog[e.n]+=o.tPre+o.tOk+e.title+n+o.tDc:o.tLog[e.n]+="└ OK: "+e.title+n+"\n"):(o.tRes[e.n]=o.F,e.tStyled?o.tLog[e.n]+=o.tPre+o.tXx+e.title+n+(t?": "+t:"")+o.tDc+o.tDc:o.tLog[e.n]+="└ ✘ "+e.title+(t?": "+t:"")+n+"\n");let i=o.Z,s=i;for(let l of o.tStatus[e.n]){if(l===o.U)return;!l&&i++,s++}o.tRes[e.n]=!i;let r=i?"FAILED "+i+"/"+s:"DONE "+s+"/"+s;e.tStyled?o.tLog[e.n]+=o.tPre+'<b style="color:'+(i?"red":"green")+';">'+r+"</b>"+o.tDc:o.tLog[e.n]+="└ "+r,"function"==typeof o.tFns[e.n]&&o.tFns[e.n](e.n)}};
|
|
2
|
+
const o=e=>{let t={els:[],ie:{}},n=0,i=1,s=2,l=3,r="object",a="function",c,d=document,f=-1,g=0,h=0,p=[],u=0,y=0,m=e=>typeof e,S=(e,t)=>{for(let n in e)Object.hasOwnProperty.call(e,n)&&t(n,e)},L=o.onError||(()=>{}),E=e=>(...r)=>{try{let a=e(r[n],r[i],r[s],r[l]);return a!==c?a:t}catch(d){L(d)}},C=e=>{for(u=g;u<=f;u++)e()},$=e=>(m(e)!==r&&(e=o.first(e).el),e),Z=(e=!0,s=t.els)=>{let l=s.length;t.length=l,f=l-i,g=n,t.el=l?s[n]:c,t.last=l?s[f]:c,e&&(S(p,(e,n)=>{delete t[n[e]]}),p=[],t.ie={})},F=(e="")=>Array.from(d.querySelectorAll(e));t.reset=o;let v=(e,t,i)=>{S(t,s=>{let l=t[s];m(l)===a&&(l=l(i)),"append"===s&&m(l)===r&&(l.els&&(l=[l]),l[n]&&l[n].els&&(valueBuff=[],S(l,e=>{valueBuff.push(...l[e].els)}),l=valueBuff)),l!==c&&(["tag","sample","state"].includes(s)||(["html","innerHTML"].includes(s)?e.innerHTML=l:"dataset"===s&&m(l)===r?S(l,t=>{e.dataset[t]=l[t]}):"toggleClass"===s?e.classList.toggle(l):"addClass"===s?m(l)===r?e.classList.add(...l):e.classList.add(l):"removeClass"===s?e.classList.remove(l):"style"===s&&m(l)===r?S(l,t=>{e.style[t]=l[t]}):"append"===s&&m(l)===r?S(l.length?l:[l],t=>{e.appendChild(l[t])}):e.setAttribute(s,l)))}),e.dataset.oState=t.state};return t.init=E(e=>{let s=t.initID||o.inits.length||n;t.initID=s,Z(),o.inits[t.initID]=t,(m(e)!==r||e.render===c)&&(e={render:e}),S(e,l=>{p.push(l),t[l]=E((h=[{}])=>{let p=e[l]||{tag:"div"},S=t.els.slice(g,f+i);m(p)===r&&(p.state=l,p["data-o-init"]=s);let L=(e,t={})=>m(p)===r?d.createElement(p.tag||"div"):((u=d.createElement("div")).innerHTML=m(p)===a?p(t):p,u.children.length>i||!u.firstElementChild)?(u.dataset.oInit=e,u):(u.firstElementChild.dataset.oInit=e,u.firstElementChild);h.length||(h=[h]);let E=!S[n]&&"render"===l;h=h.map((e,n)=>(e.self=t,e.o=o,e.i=e.i===c?n:e.i,E&&S.push(L(s,e)),e)),E&&(t.els=S,Z(!1)),S&&(y=S.length===h.length,S.map((e,t)=>{h[y?t:n].i=t+g;let i=m(p)===a?p(h[y?t:n]):p;m(i)===r&&v(e,i,h[y?t:n])}))})})}),t.initState=E((e,n)=>{t.init(e).render(n)}),t.sample=E((e="render")=>{let i=t.els[g].attributes,s=t.els[g].dataset,l={tag:t.els[g].tagName,html:t.els[g].innerHTML,dataset:{}};for(let r of i)"data-"!==r.nodeName.substring(n,5)&&(l[r.nodeName]=r.value);return S(s,e=>{l.dataset[e]=s[e]}),{[e]:l}}),t.select=E(e=>{e===c&&(e=t.length-i),f=e,g=e,t.el=t.els[e],h=i}),t.all=E(()=>{f=t.length-i,g=n,t.el=t.els[n],h=n}),t.remove=E(e=>{e===c&&h&&(e=g),e!==c?t.els[e].parentNode.removeChild(t.els[e]):C(()=>{t.els[u].parentNode.removeChild(t.els[u])}),Z(!1)}),t.skip=E(e=>{e===c&&(e=g),t.els.splice(u,i),Z()}),t.add=E((e,i)=>{"string"===m(e)&&""!==e?t.els.push(...F(e)):m(e)===r?e.tagName?t.els.push(e):e.els?t.els.push(...e.els):e.length&&e[n].tagName&&t.els.push(...e):"number"===m(e)&&o.inits[e]&&(t=o.inits[e]),Z(!1),t.initID!==c&&t.dataset({oInit:t.initID})}),t.appendInside=E(e=>{C(()=>{$(e).appendChild(t.els[u])})}),t.appendBefore=E(e=>{C(()=>{$(e).parentNode.insertBefore(t.els[u],$(e))})}),t.appendAfter=E(e=>{C(()=>{$(e).after(...t.els)})}),t.find=E((e="")=>{let n=[];C(()=>{n.push(...Array.from(t.els[u].querySelectorAll(":scope "+e)))}),t.els=n,Z()}),t.first=E((e="")=>{let n=c,i=[];C(()=>{(n=t.els[u].querySelector(e))&&i.push(n)}),t.els=i,Z()}),t.attr=E((e,i)=>{if(e){if(i===c){let s=[];return C(()=>{s[u]=t.els[u].getAttribute(e)}),h?s[n]:s}""!==i?C(()=>{t.els[u].setAttribute(e,i)}):C(()=>{t.els[u].removeAttribute(e)})}}),t.attrs=E(()=>{let e=[];return C(()=>{let n={};[...t.els[u].attributes].forEach(e=>{n[e.nodeName]=e.nodeValue}),e.push(n)}),h?e[n]:e}),t.dataset=E(e=>{if(typeof e===r)C(()=>{S(e,n=>{t.els[u].dataset[n]=e[n]})});else{let i=[];return C(()=>{i.push({...t.els[u].dataset})}),h?i[n]:i}}),t.style=E(e=>{t.attr("style",e)}),t.css=E((e={})=>{let n="";S(e,t=>{n+=t+":"+e[t].replace('"',"'")+";"}),t.style(n)}),t.setClass=E(e=>{C(()=>{t.els[u].setAttribute("class",e)})}),t.addClass=E(e=>{C(()=>{t.els[u].classList.add(e)})}),t.removeClass=E(e=>{C(()=>{t.els[u].classList.remove(e)})}),t.toggleClass=E((e,n)=>{C(()=>{t.els[u].classList.toggle(e,n)})}),t.haveClass=e=>{let n=!0;return C(()=>{t.els[u].classList.contains(e)||(n=!1)}),n},t.innerHTML=E(e=>{if(e!==c)C(()=>{t.els[u].innerHTML=e});else{let n="";return C(()=>{n+=t.els[u].innerHTML}),n}}),t.innerText=E((e="")=>{C(()=>{t.els[u].innerText=e})}),t.textContent=E((e="")=>{C(()=>{t.els[u].textContent=e})}),t.html=E(e=>{if(e)t.innerHTML(e);else{let n="";return C(()=>{n+=t.els[u].outerHTML}),n}}),t.forEach=E(e=>{C(()=>{e({self:o(t.els[u]).select(),i:u})})}),t.on=E((e,n,i,s)=>{e.split(", ").forEach(e=>{C(()=>{t.els[u].addEventListener(e,n,i,s)}),t.ie[e]||(t.ie[e]=[]),t.ie[e].push([n,i,s])})}),t.off=E((e,i,s)=>{e.split(", ").forEach(e=>{C(()=>{t.els[u].removeEventListener(e,i,s)}),t.ie[e]&&(t.ie[e]=t.ie[e].filter(e=>e[n]!==i))})}),t.onAll=E((e,l)=>{S(t.ie,(r,a)=>{e&&e!==r||a[r].forEach(e=>{C(()=>{l?t.els[u].removeEventListener(r,e[n]):t.els[u].addEventListener(r,e[n],e[i],e[s])})})})}),t.offAll=E(e=>{t.onAll(e,i)}),e&&t.add(e),t.take=e=>{if(t.add(e),t.el){let s=t.el.dataset.oInit;if(s!==c&&o.inits[s])return t.length===i?(y=t.els[n],Object.assign(t,o.inits[s]),t.els=[y]):t=o.inits[s],Z(!1,t.els),t}},t};o.first=e=>o(document.querySelector(e)||""),o.inits=[],o.errors=[],o.showErrors=!1,o.logErrors=()=>{o.errors.length?o.errors.forEach(e=>console.log(e)):console.log("No errors")},o.onError=e=>{o.showErrors?console.log(e):o.errors.push(e)},o.init=e=>o().init(e),o.initState=(e,t)=>o().init(e).render(t),o.take=e=>o().take(e),o.Z=0,o.N=1,o.W=2,o.H=100,o.F=!1,o.C=(e,t)=>Object.hasOwnProperty.call(e,t),o.ajax=(e,t={})=>{let n=new URLSearchParams;if(t.data&&"object"==typeof t.data){for(let i in t.data)o.C(t.data,i)&&("object"==typeof t.data[i]?n.set(i,encodeURIComponent(JSON.stringify(t.data[i]))):n.set(i,t.data[i]));"GET"===t.method||"get"===t.method?e+="?"+n.toString():t.body||(t.body=n),delete t.data}return fetch(e,t)},o.get=(e,t={})=>o.ajax(e,{...t,method:"GET"}),o.post=(e,t={})=>o.ajax(e,{...t,method:"POST"}),o.getParams=e=>{let t={},n=new URLSearchParams(window.location.search).entries();for(let i of n)t[i[o.Z]]=i[o.N];return e?t[e]:t},o.incCache=!0,o.incCacheExp=864e5,o.incTimeout=6e3,o.incSource="",o.incForce=o.F,o.incAsync=!0,o.incCors=o.F,o.incFns={},o.incSet=[o.Z],o.incReady=[o.Z],o.incN=o.Z,o.incCheck=(e=0,t,n=0)=>!n&&e&&t===o.U&&o.incReady[e]?o.incSet[e]===o.N:o.incReady[e]===o.U||o.incReady[e][t]===o.U?o.F:(o.incReady[e][t].loaded=n,o.incFns[o.incReady[e][t].name]=n,o.incReady[e][o.Z]+=n,e&&o.incReady[e].length===o.incReady[e][o.Z]&&("function"==typeof o.incSet[e]&&o.incSet[e](e),o.incSet[e]=o.N),o.incSet[e]===o.N),o.incCacheClear=(e=o.F)=>{for(let t in o.incFns)o.C(o.incFns,t)&&(localStorage.removeItem("inc-"+t),localStorage.removeItem("inc-"+t+"Expires"));return e&&(o.incReady.forEach((e,t)=>{t&&e.forEach((e,n)=>{n&&o("#oInc-"+t+"-"+n).remove()})}),o.incN=o.Z,o.incFns={},o.incSet=[o.Z],o.incReady=[o.Z]),!0},o.inc=(e,t,n)=>{let i=o.Z,s=o.Z,l="function";if("object"!=typeof e||!e)return o.incSet[o.Z];o.incSet[o.Z]++;let r=o.incSet[o.Z];o.incSet[r]=t||o.Z,o.incReady[r]=[];let a=o.incReady[r];a[o.Z]=o.N;let c={};for(let d in e)if(o.C(e,d)){i++,o.incN++;let f=e[d].indexOf(".css")>-1?"style":"script";if(e[d]=(o.incSource?o.incSource+"/":"")+e[d],isNaN(d)&&o.C(o.incFns,d)&&o.incFns[d]&&!o.incForce){a[i]={name:d,loaded:o.N},s++;continue}if(a[i]={name:d,loaded:o.Z},isNaN(d)&&(o.incFns[d]=o.Z),isNaN(d)&&o.incCache&&"http"!==e[d].substring(o.Z,4)&&"file:"!==window.location.protocol&&(e[d].indexOf(".css")>-1||e[d].indexOf(".js")>-1)){let g=localStorage,h=g.getItem("inc-"+d),p=g.getItem("inc-"+d+"Expires");h&&p&&new Date().getTime()<p?(o.initState({tag:f,id:"oInc-"+r+"-"+i,innerHTML:h,"data-o-inc":r}).appendInside("head"),a[i].loaded=o.N,o.incFns[d]=o.N,s++):(c[d]=i,o.get(e[d],{mode:o.incCors?"cors":"same-origin"}).then(t=>{if(200!==t.status){o.onError&&o.onError({message:o.incSource+e[d]+" was not loaded"});return}t.text().then(e=>{g.setItem("inc-"+d,e),g.setItem("inc-"+d+"Expires",new Date().getTime()+o.incCacheExp),o.initState({tag:f,id:"oInc-"+r+"-"+c[d],innerHTML:e,"data-o-inc":r}).appendInside("head"),o.incCheck(r,c[d],o.N)})}))}else{let u={tag:f,id:"oInc-"+r+"-"+i,"data-o-inc":r,async:o.incAsync,onload:"o.incCheck("+r+","+i+",1)"};e[d].indexOf(".css")>-1?(u.tag="link",u.rel="stylesheet",u.href=e[d]):(e[d].indexOf(".js")>-1||(u.tag="img",u.style="display:none;"),u.src=e[d]),o.initState(u).appendInside(u.style?"body":"head")}}return a[o.Z]+=s,i!==o.Z&&(s===i?typeof t===l&&t(r):setTimeout(e=>{o.incReady[e]&&o.incReady[e].length<o.incReady[e][o.Z]&&(o.incSet[e]=o.Z,typeof n===l&&n(r))},o.incTimeout,r)),o.incSet[o.Z]},o.tLog=[],o.tRes=[],o.tStatus=[],o.tFns=[],o.tShowOk=o.F,o.tStyled=o.F,o.tTime=2e3,o.tPre='<div style="font-family:monospace;text-align:left;">',o.tOk='<span style="background:#cfc;padding: 0 15px;">OK</span> ',o.tXx='<div style="background:#fcc;padding:3px;">',o.tDc="</div>",o.test=(e="",...t)=>{let n=o.tLog.length,i=0,s="├ OK: ",l="├ ✘ ",r="\n",a="\n",c=t.length,d=o.Z;"function"==typeof t[c-o.N]&&(o.tFns[n]=t[c-o.N],c--),o.tStyled?(o.tLog[n]="<div><b>"+e+" #"+n+"</b></div>",s=o.tPre+o.tOk,l=o.tPre+o.tXx,a=(r=o.tDc)+r):o.tLog[n]=e+" #"+n+"\n",o.tRes[n]=o.F,o.tStatus[n]=[];for(let f=o.Z;f<c;f++){let g={n:n,i:f,title:t[f][o.Z],tShowOk:o.tShowOk,tStyled:o.tStyled},h=t[f][o.N];if("function"==typeof h)try{h=h(g)}catch(p){h=p.message,o.onError&&o.onError(p)}o.tStatus[n][f]="string"==typeof h?o.F:h,!0===h?(d++,o.tShowOk&&(o.tLog[n]+=s+t[f][o.Z]+r)):h!==o.U?o.tLog[n]+=l+t[f][o.Z]+(h!==o.F?": <i>"+h+"</i>":"")+a:(i++,setTimeout(e=>{e.title+=" (timeout)",o.testUpdate(e)},o.tTime,g))}return o.tRes[n]=d===c,o.tStyled?o.tLog[n]+=o.tPre+'<div style="color:'+(d+i!==c?"red":"green")+';"><b>':o.tLog[n]+=i?"├":"└ ",o.tLog[n]+="DONE "+d+"/"+(c-i),i&&(o.tLog[n]+=", waiting: "+i),o.tStyled?o.tLog[n]+="</b>"+o.tDc+o.tDc:o.tLog[n]+="\n",i||"function"!=typeof o.tFns[n]||o.tFns[n](n),n},o.testUpdate=(e,t=o.F,n="")=>{if(o.tStatus[e.n][e.i]===o.U){o.tStatus[e.n][e.i]=!0===t,!0===t?e.tShowOk&&(e.tStyled?o.tLog[e.n]+=o.tPre+o.tOk+e.title+n+o.tDc:o.tLog[e.n]+="└ OK: "+e.title+n+"\n"):(o.tRes[e.n]=o.F,e.tStyled?o.tLog[e.n]+=o.tPre+o.tXx+e.title+n+(t?": "+t:"")+o.tDc+o.tDc:o.tLog[e.n]+="└ ✘ "+e.title+(t?": "+t:"")+n+"\n");let i=o.Z,s=i;for(let l of o.tStatus[e.n]){if(l===o.U)return;!l&&i++,s++}o.tRes[e.n]=!i;let r=i?"FAILED "+i+"/"+s:"DONE "+s+"/"+s;e.tStyled?o.tLog[e.n]+=o.tPre+'<b style="color:'+(i?"red":"green")+';">'+r+"</b>"+o.tDc:o.tLog[e.n]+="└ "+r,"function"==typeof o.tFns[e.n]&&o.tFns[e.n](e.n)}};
|
package/objs.npm.1.0.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @author Roman Torshin, Apache 2.0 licence
|
|
2
2
|
(function(globals) {
|
|
3
3
|
'use strict';
|
|
4
|
-
function ownKeys(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(n),!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _defineProperty(t,e,n){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(t,e){if("object"!==_typeof(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!==_typeof(r))return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}function _createForOfIteratorHelper(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=_unsupportedIterableToArray(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function t(){};return{s:i,n:function e(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function t(e){throw e},f:i}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,c=!0,s=!1;return{s:function e(){n=n.call(t)},n:function t(){var e=n.next();return c=e.done,e},e:function t(e){s=!0,a=e},f:function t(){try{c||null==n.return||n.return()}finally{if(s)throw a}}}}function _toConsumableArray(t){return _arrayWithoutHoles(t)||_iterableToArray(t)||_unsupportedIterableToArray(t)||_nonIterableSpread()}function _nonIterableSpread(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(t,e)}}function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var o=function t(e){var n={els:[],ie:{}},r="object",i="function",a=void 0,c=document,s=-1,l=0,u=0,f=[],d=0,p=0,y=function t(e){return _typeof(e)},v=function t(e,n){for(var r in e)Object.hasOwnProperty.call(e,r)&&n(r,e)},g=t.onError||function(){},h=function t(e){return function(){try{var t=e(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3]);return t!==a?t:n}catch(r){g(r)}}},$=function t(e){for(d=l;d<=s;d++)e()},m=function e(n){return y(n)!==r&&(n=t.first(n).el),n},b=function t(){var e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.els,i=r.length;n.length=i,s=i-1,l=0,n.el=i?r[0]:a,n.last=i?r[s]:a,e&&(v(f,function(t,e){delete n[e[t]]}),f=[],n.ie={})},S=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return Array.from(c.querySelectorAll(e))};n.reset=t;var _=function t(e,n,c){v(n,function(t){var s,l=n[t];y(l)===i&&(l=l(c)),"append"===t&&y(l)===r&&(l.els&&(l=[l]),l[0]&&l[0].els&&(valueBuff=[],v(l,function(t){var e;(e=valueBuff).push.apply(e,_toConsumableArray(l[t].els))}),l=valueBuff)),l!==a&&(["tag","sample","state"].includes(t)||(["html","innerHTML"].includes(t)?e.innerHTML=l:"dataset"===t&&y(l)===r?v(l,function(t){e.dataset[t]=l[t]}):"toggleClass"===t?e.classList.toggle(l):"addClass"===t?y(l)===r?(s=e.classList).add.apply(s,_toConsumableArray(l)):e.classList.add(l):"removeClass"===t?e.classList.remove(l):"style"===t&&y(l)===r?v(l,function(t){e.style[t]=l[t]}):"append"===t&&y(l)===r?v(l.length?l:[l],function(t){e.appendChild(l[t])}):e.setAttribute(t,l)))}),e.dataset.oState=n.state};return n.init=h(function(e){var u=n.initID||t.inits.length||0;n.initID=u,b(),t.inits[n.initID]=n,(y(e)!==r||e.render===a)&&(e={render:e}),v(e,function(v){f.push(v),n[v]=h(function(){var f=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[{}],g=e[v]||{tag:"div"},h=n.els.slice(l,s+1);y(g)===r&&(g.state=v,g["data-o-init"]=u);var $=function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return y(g)===r?c.createElement(g.tag||"div"):((d=c.createElement("div")).innerHTML=y(g)===i?g(n):g,d.children.length>1||!d.firstElementChild)?(d.dataset.oInit=e,d):(d.firstElementChild.dataset.oInit=e,d.firstElementChild)};f.length||(f=[f]);var m=!h[0]&&"render"===v;f=f.map(function(e,r){return e.self=n,e.o=t,e.i=e.i===a?r:e.i,m&&h.push($(u,e)),e}),m&&(n.els=h,b(!1)),h&&(p=h.length===f.length,h.map(function(t,e){f[p?e:0].i=e+l;var n=y(g)===i?g(f[p?e:0]):g;y(n)===r&&_(t,n,f[p?e:0])}))})})}),n.initState=h(function(t,e){n.init(t).render(e)}),n.sample=h(function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"render",r=n.els[l].attributes,i=n.els[l].dataset,a={tag:n.els[l].tagName,html:n.els[l].innerHTML,dataset:{}},c=_createForOfIteratorHelper(r);try{for(c.s();!(t=c.n()).done;){var s=t.value;"data-"!==s.nodeName.substring(0,5)&&(a[s.nodeName]=s.value)}}catch(u){c.e(u)}finally{c.f()}return v(i,function(t){a.dataset[t]=i[t]}),_defineProperty({},e,a)}),n.select=h(function(t){t===a&&(t=n.length-1),s=t,l=t,n.el=n.els[t],u=1}),n.all=h(function(){s=n.length-1,l=0,n.el=n.els[0],u=0}),n.remove=h(function(t){t===a&&u&&(t=l),t!==a?n.els[t].parentNode.removeChild(n.els[t]):$(function(){n.els[d].parentNode.removeChild(n.els[d])}),b(!1)}),n.skip=h(function(t){t===a&&(t=l),n.els.splice(d,1),b()}),n.add=h(function(e,i){var c,s,l;"string"===y(e)&&""!==e?(c=n.els).push.apply(c,_toConsumableArray(S(e))):y(e)===r?e.tagName?n.els.push(e):e.els?(s=n.els).push.apply(s,_toConsumableArray(e.els)):e.length&&e[0].tagName&&(l=n.els).push.apply(l,_toConsumableArray(e)):"number"===y(e)&&t.inits[e]&&(n=t.inits[e]),b(!1),n.initID!==a&&n.dataset({oInit:n.initID})}),n.appendInside=h(function(t){$(function(){m(t).appendChild(n.els[d])})}),n.appendBefore=h(function(t){$(function(){m(t).parentNode.insertBefore(n.els[d],m(t))})}),n.appendAfter=h(function(t){$(function(){var e;(e=m(t)).after.apply(e,_toConsumableArray(n.els))})}),n.find=h(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=[];$(function(){e.push.apply(e,_toConsumableArray(Array.from(n.els[d].querySelectorAll(":scope "+t))))}),n.els=e,b()}),n.first=h(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=a,r=[];$(function(){(e=n.els[d].querySelector(t))&&r.push(e)}),n.els=r,b()}),n.attr=h(function(t,e){if(t){if(e===a){var r=[];return $(function(){r[d]=n.els[d].getAttribute(t)}),u?r[0]:r}""!==e?$(function(){n.els[d].setAttribute(t,e)}):$(function(){n.els[d].removeAttribute(t)})}}),n.attrs=h(function(){var t=[];return $(function(){var e={};_toConsumableArray(n.els[d].attributes).forEach(function(t){e[t.nodeName]=t.nodeValue}),t.push(e)}),u?t[0]:t}),n.dataset=h(function(t){if(_typeof(t)===r)$(function(){v(t,function(e){n.els[d].dataset[e]=t[e]})});else{var e=[];return $(function(){e.push(_objectSpread({},n.els[d].dataset))}),u?e[0]:e}}),n.style=h(function(t){n.attr("style",t)}),n.css=h(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e="";v(t,function(n){e+=n+":"+t[n].replace('"',"'")+";"}),n.style(e)}),n.setClass=h(function(t){$(function(){n.els[d].setAttribute("class",t)})}),n.addClass=h(function(t){$(function(){n.els[d].classList.add(t)})}),n.removeClass=h(function(t){$(function(){n.els[d].classList.remove(t)})}),n.toggleClass=h(function(t,e){$(function(){n.els[d].classList.toggle(t,e)})}),n.haveClass=function(t){var e=!0;return $(function(){n.els[d].classList.contains(t)||(e=!1)}),e},n.innerHTML=h(function(t){if(t!==a)$(function(){n.els[d].innerHTML=t});else{var e="";return $(function(){e+=n.els[d].innerHTML}),e}}),n.innerText=h(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";$(function(){n.els[d].innerText=t})}),n.textContent=h(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";$(function(){n.els[d].textContent=t})}),n.html=h(function(t){if(t)n.innerHTML(t);else{var e="";return $(function(){e+=n.els[d].outerHTML}),e}}),n.forEach=h(function(t){n.initState(t)}),n.on=h(function(t,e,r,i){t.split(", ").forEach(function(t){$(function(){n.els[d].addEventListener(t,e,r,i)}),n.ie[t]||(n.ie[t]=[]),n.ie[t].push([e,r,i])})}),n.off=h(function(t,e,r){t.split(", ").forEach(function(t){$(function(){n.els[d].removeEventListener(t,e,r)}),n.ie[t]&&(n.ie[t]=n.ie[t].filter(function(t){return t[0]!==e}))})}),n.onAll=h(function(t,e){v(n.ie,function(r,i){t&&t!==r||i[r].forEach(function(t){$(function(){e?n.els[d].removeEventListener(r,t[0]):n.els[d].addEventListener(r,t[0],t[1],t[2])})})})}),n.offAll=h(function(t){n.onAll(t,1)}),e&&n.add(e),n.take=function(e){if(n.add(e),n.el){var r=n.el.dataset.oInit;if(r!==a&&t.inits[r])return 1===n.length?(p=n.els[0],Object.assign(n,t.inits[r]),n.els=[p]):n=t.inits[r],b(!1,n.els),n}},n};o.first=function(t){return o(document.querySelector(t)||"")},o.inits=[],o.errors=[],o.showErrors=!1,o.logErrors=function(){o.errors.length?o.errors.forEach(function(t){return console.log(t)}):console.log("No errors")},o.onError=function(t){o.showErrors?console.log(t):o.errors.push(t)},o.init=function(t){return o().init(t)},o.initState=function(t,e){return o().init(t).render(e)},o.take=function(t){return o().take(t)},o.Z=0,o.N=1,o.W=2,o.H=100,o.F=!1,o.C=function(t,e){return Object.hasOwnProperty.call(t,e)},o.ajax=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new URLSearchParams;if(e.data&&"object"===_typeof(e.data)){for(var r in e.data)o.C(e.data,r)&&("object"===_typeof(e.data[r])?n.set(r,encodeURIComponent(JSON.stringify(e.data[r]))):n.set(r,e.data[r]));"GET"===e.method||"get"===e.method?t+="?"+n.toString():e.body||(e.body=n),delete e.data}return fetch(t,e)},o.get=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return o.ajax(t,_objectSpread(_objectSpread({},e),{},{method:"GET"}))},o.post=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return o.ajax(t,_objectSpread(_objectSpread({},e),{},{method:"POST"}))},o.getParams=function(t){var e,n={},r=new URLSearchParams(window.location.search).entries(),i=_createForOfIteratorHelper(r);try{for(i.s();!(e=i.n()).done;){var a=e.value;n[a[o.Z]]=a[o.N]}}catch(c){i.e(c)}finally{i.f()}return t?n[t]:n},o.incCache=!0,o.incCacheExp=864e5,o.incTimeout=6e3,o.incSource="",o.incForce=o.F,o.incAsync=!0,o.incCors=o.F,o.incFns={},o.incSet=[o.Z],o.incReady=[o.Z],o.incN=o.Z,o.incCheck=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return!n&&t&&e===o.U&&o.incReady[t]?o.incSet[t]===o.N:o.incReady[t]===o.U||o.incReady[t][e]===o.U?o.F:(o.incReady[t][e].loaded=n,o.incFns[o.incReady[t][e].name]=n,o.incReady[t][o.Z]+=n,t&&o.incReady[t].length===o.incReady[t][o.Z]&&("function"==typeof o.incSet[t]&&o.incSet[t](t),o.incSet[t]=o.N),o.incSet[t]===o.N)},o.incCacheClear=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o.F;for(var e in o.incFns)o.C(o.incFns,e)&&(localStorage.removeItem("inc-"+e),localStorage.removeItem("inc-"+e+"Expires"));return t&&(o.incReady.forEach(function(t,e){e&&t.forEach(function(t,n){n&&o("#oInc-"+e+"-"+n).remove()})}),o.incN=o.Z,o.incFns={},o.incSet=[o.Z],o.incReady=[o.Z]),!0},o.inc=function(t,e,n){var r=o.Z,i=o.Z,a="function";if("object"!==_typeof(t)||!t)return o.incSet[o.Z];o.incSet[o.Z]++;var c=o.incSet[o.Z];o.incSet[c]=e||o.Z,o.incReady[c]=[];var s=o.incReady[c];s[o.Z]=o.N;var l={},u=function e(n){if(o.C(t,n)){r++,o.incN++;var a=t[n].indexOf(".css")>-1?"style":"script";if(t[n]=(o.incSource?o.incSource+"/":"")+t[n],isNaN(n)&&o.C(o.incFns,n)&&o.incFns[n]&&!o.incForce)return s[r]={name:n,loaded:o.N},i++,1;if(s[r]={name:n,loaded:o.Z},isNaN(n)&&(o.incFns[n]=o.Z),isNaN(n)&&o.incCache&&"http"!==t[n].substring(o.Z,4)&&"file:"!==window.location.protocol&&(t[n].indexOf(".css")>-1||t[n].indexOf(".js")>-1)){var u=localStorage,f=u.getItem("inc-"+n),d=u.getItem("inc-"+n+"Expires");f&&d&&new Date().getTime()<d?(o.initState({tag:a,id:"oInc-"+c+"-"+r,innerHTML:f,"data-o-inc":c}).appendInside("head"),s[r].loaded=o.N,o.incFns[n]=o.N,i++):(l[n]=r,o.get(t[n],{mode:o.incCors?"cors":"same-origin"}).then(function(e){if(200!==e.status){o.onError&&o.onError({message:o.incSource+t[n]+" was not loaded"});return}e.text().then(function(t){u.setItem("inc-"+n,t),u.setItem("inc-"+n+"Expires",new Date().getTime()+o.incCacheExp),o.initState({tag:a,id:"oInc-"+c+"-"+l[n],innerHTML:t,"data-o-inc":c}).appendInside("head"),o.incCheck(c,l[n],o.N)})}))}else{var p={tag:a,id:"oInc-"+c+"-"+r,"data-o-inc":c,async:o.incAsync,onload:"o.incCheck("+c+","+r+",1)"};t[n].indexOf(".css")>-1?(p.tag="link",p.rel="stylesheet",p.href=t[n]):(t[n].indexOf(".js")>-1||(p.tag="img",p.style="display:none;"),p.src=t[n]),o.initState(p).appendInside(p.style?"body":"head")}}};for(var f in t)if(u(f))continue;return s[o.Z]+=i,r!==o.Z&&(i===r?_typeof(e)===a&&e(c):setTimeout(function(t){o.incReady[t]&&o.incReady[t].length<o.incReady[t][o.Z]&&(o.incSet[t]=o.Z,_typeof(n)===a&&n(c))},o.incTimeout,c)),o.incSet[o.Z]},o.tLog=[],o.tRes=[],o.tStatus=[],o.tFns=[],o.tShowOk=o.F,o.tStyled=o.F,o.tTime=2e3,o.tPre='<div style="font-family:monospace;text-align:left;">',o.tOk='<span style="background:#cfc;padding: 0 15px;">OK</span> ',o.tXx='<div style="background:#fcc;padding:3px;">',o.tDc="</div>",o.test=function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=o.tLog.length,n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];var a=0,c="├ OK: ",s="├ ✘ ",l="\n",u="\n",f=r.length,d=o.Z;"function"==typeof r[f-o.N]&&(o.tFns[e]=r[f-o.N],f--),o.tStyled?(o.tLog[e]="<div><b>"+t+" #"+e+"</b></div>",c=o.tPre+o.tOk,s=o.tPre+o.tXx,u=(l=o.tDc)+l):o.tLog[e]=t+" #"+e+"\n",o.tRes[e]=o.F,o.tStatus[e]=[];for(var p=o.Z;p<f;p++){var y={n:e,i:p,title:r[p][o.Z],tShowOk:o.tShowOk,tStyled:o.tStyled},v=r[p][o.N];if("function"==typeof v)try{v=v(y)}catch(g){v=g.message,o.onError&&o.onError(g)}o.tStatus[e][p]="string"==typeof v?o.F:v,!0===v?(d++,o.tShowOk&&(o.tLog[e]+=c+r[p][o.Z]+l)):v!==o.U?o.tLog[e]+=s+r[p][o.Z]+(v!==o.F?": <i>"+v+"</i>":"")+u:(a++,setTimeout(function(t){t.title+=" (timeout)",o.testUpdate(t)},o.tTime,y))}return o.tRes[e]=d===f,o.tStyled?o.tLog[e]+=o.tPre+'<div style="color:'+(d+a!==f?"red":"green")+';"><b>':o.tLog[e]+=a?"├":"└ ",o.tLog[e]+="DONE "+d+"/"+(f-a),a&&(o.tLog[e]+=", waiting: "+a),o.tStyled?o.tLog[e]+="</b>"+o.tDc+o.tDc:o.tLog[e]+="\n",a||"function"!=typeof o.tFns[e]||o.tFns[e](e),e},o.testUpdate=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.F,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(o.tStatus[t.n][t.i]===o.U){o.tStatus[t.n][t.i]=!0===e,!0===e?t.tShowOk&&(t.tStyled?o.tLog[t.n]+=o.tPre+o.tOk+t.title+n+o.tDc:o.tLog[t.n]+="└ OK: "+t.title+n+"\n"):(o.tRes[t.n]=o.F,t.tStyled?o.tLog[t.n]+=o.tPre+o.tXx+t.title+n+(e?": "+e:"")+o.tDc+o.tDc:o.tLog[t.n]+="└ ✘ "+t.title+(e?": "+e:"")+n+"\n");var r,i=o.Z,a=i,c=_createForOfIteratorHelper(o.tStatus[t.n]);try{for(c.s();!(r=c.n()).done;){var s=r.value;if(s===o.U)return;!s&&i++,a++}}catch(l){c.e(l)}finally{c.f()}o.tRes[t.n]=!i;var u=i?"FAILED "+i+"/"+a:"DONE "+a+"/"+a;t.tStyled?o.tLog[t.n]+=o.tPre+'<b style="color:'+(i?"red":"green")+';">'+u+"</b>"+o.tDc:o.tLog[t.n]+="└ "+u,"function"==typeof o.tFns[t.n]&&o.tFns[t.n](t.n)}};
|
|
4
|
+
function ownKeys(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(n),!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _defineProperty(t,e,n){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(t,e){if("object"!==_typeof(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!==_typeof(r))return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}function _createForOfIteratorHelper(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=_unsupportedIterableToArray(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function t(){};return{s:i,n:function e(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function t(e){throw e},f:i}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,c=!0,s=!1;return{s:function e(){n=n.call(t)},n:function t(){var e=n.next();return c=e.done,e},e:function t(e){s=!0,a=e},f:function t(){try{c||null==n.return||n.return()}finally{if(s)throw a}}}}function _toConsumableArray(t){return _arrayWithoutHoles(t)||_iterableToArray(t)||_unsupportedIterableToArray(t)||_nonIterableSpread()}function _nonIterableSpread(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(t,e)}}function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var o=function t(e){var n,r={els:[],ie:{}},i="object",a="function",c=document,s=-1,l=0,u=0,f=[],d=0,p=0,y=function t(e){return _typeof(e)},v=function t(e,n){for(var r in e)Object.hasOwnProperty.call(e,r)&&n(r,e)},g=t.onError||function(){},h=function t(e){return function(){try{var t=e(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3]);return t!==n?t:r}catch(i){g(i)}}},$=function t(e){for(d=l;d<=s;d++)e()},m=function e(n){return y(n)!==i&&(n=t.first(n).el),n},b=function t(){var e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r.els,a=i.length;r.length=a,s=a-1,l=0,r.el=a?i[0]:n,r.last=a?i[s]:n,e&&(v(f,function(t,e){delete r[e[t]]}),f=[],r.ie={})},S=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return Array.from(c.querySelectorAll(e))};r.reset=t;var _=function t(e,r,c){v(r,function(t){var s,l=r[t];y(l)===a&&(l=l(c)),"append"===t&&y(l)===i&&(l.els&&(l=[l]),l[0]&&l[0].els&&(valueBuff=[],v(l,function(t){var e;(e=valueBuff).push.apply(e,_toConsumableArray(l[t].els))}),l=valueBuff)),l!==n&&(["tag","sample","state"].includes(t)||(["html","innerHTML"].includes(t)?e.innerHTML=l:"dataset"===t&&y(l)===i?v(l,function(t){e.dataset[t]=l[t]}):"toggleClass"===t?e.classList.toggle(l):"addClass"===t?y(l)===i?(s=e.classList).add.apply(s,_toConsumableArray(l)):e.classList.add(l):"removeClass"===t?e.classList.remove(l):"style"===t&&y(l)===i?v(l,function(t){e.style[t]=l[t]}):"append"===t&&y(l)===i?v(l.length?l:[l],function(t){e.appendChild(l[t])}):e.setAttribute(t,l)))}),e.dataset.oState=r.state};return r.init=h(function(e){var u=r.initID||t.inits.length||0;r.initID=u,b(),t.inits[r.initID]=r,(y(e)!==i||e.render===n)&&(e={render:e}),v(e,function(v){f.push(v),r[v]=h(function(){var f=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[{}],g=e[v]||{tag:"div"},h=r.els.slice(l,s+1);y(g)===i&&(g.state=v,g["data-o-init"]=u);var $=function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return y(g)===i?c.createElement(g.tag||"div"):((d=c.createElement("div")).innerHTML=y(g)===a?g(n):g,d.children.length>1||!d.firstElementChild)?(d.dataset.oInit=e,d):(d.firstElementChild.dataset.oInit=e,d.firstElementChild)};f.length||(f=[f]);var m=!h[0]&&"render"===v;f=f.map(function(e,i){return e.self=r,e.o=t,e.i=e.i===n?i:e.i,m&&h.push($(u,e)),e}),m&&(r.els=h,b(!1)),h&&(p=h.length===f.length,h.map(function(t,e){f[p?e:0].i=e+l;var n=y(g)===a?g(f[p?e:0]):g;y(n)===i&&_(t,n,f[p?e:0])}))})})}),r.initState=h(function(t,e){r.init(t).render(e)}),r.sample=h(function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"render",n=r.els[l].attributes,i=r.els[l].dataset,a={tag:r.els[l].tagName,html:r.els[l].innerHTML,dataset:{}},c=_createForOfIteratorHelper(n);try{for(c.s();!(t=c.n()).done;){var s=t.value;"data-"!==s.nodeName.substring(0,5)&&(a[s.nodeName]=s.value)}}catch(u){c.e(u)}finally{c.f()}return v(i,function(t){a.dataset[t]=i[t]}),_defineProperty({},e,a)}),r.select=h(function(t){t===n&&(t=r.length-1),s=t,l=t,r.el=r.els[t],u=1}),r.all=h(function(){s=r.length-1,l=0,r.el=r.els[0],u=0}),r.remove=h(function(t){t===n&&u&&(t=l),t!==n?r.els[t].parentNode.removeChild(r.els[t]):$(function(){r.els[d].parentNode.removeChild(r.els[d])}),b(!1)}),r.skip=h(function(t){t===n&&(t=l),r.els.splice(d,1),b()}),r.add=h(function(e,a){var c,s,l;"string"===y(e)&&""!==e?(c=r.els).push.apply(c,_toConsumableArray(S(e))):y(e)===i?e.tagName?r.els.push(e):e.els?(s=r.els).push.apply(s,_toConsumableArray(e.els)):e.length&&e[0].tagName&&(l=r.els).push.apply(l,_toConsumableArray(e)):"number"===y(e)&&t.inits[e]&&(r=t.inits[e]),b(!1),r.initID!==n&&r.dataset({oInit:r.initID})}),r.appendInside=h(function(t){$(function(){m(t).appendChild(r.els[d])})}),r.appendBefore=h(function(t){$(function(){m(t).parentNode.insertBefore(r.els[d],m(t))})}),r.appendAfter=h(function(t){$(function(){var e;(e=m(t)).after.apply(e,_toConsumableArray(r.els))})}),r.find=h(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=[];$(function(){e.push.apply(e,_toConsumableArray(Array.from(r.els[d].querySelectorAll(":scope "+t))))}),r.els=e,b()}),r.first=h(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=n,i=[];$(function(){(e=r.els[d].querySelector(t))&&i.push(e)}),r.els=i,b()}),r.attr=h(function(t,e){if(t){if(e===n){var i=[];return $(function(){i[d]=r.els[d].getAttribute(t)}),u?i[0]:i}""!==e?$(function(){r.els[d].setAttribute(t,e)}):$(function(){r.els[d].removeAttribute(t)})}}),r.attrs=h(function(){var t=[];return $(function(){var e={};_toConsumableArray(r.els[d].attributes).forEach(function(t){e[t.nodeName]=t.nodeValue}),t.push(e)}),u?t[0]:t}),r.dataset=h(function(t){if(_typeof(t)===i)$(function(){v(t,function(e){r.els[d].dataset[e]=t[e]})});else{var e=[];return $(function(){e.push(_objectSpread({},r.els[d].dataset))}),u?e[0]:e}}),r.style=h(function(t){r.attr("style",t)}),r.css=h(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e="";v(t,function(n){e+=n+":"+t[n].replace('"',"'")+";"}),r.style(e)}),r.setClass=h(function(t){$(function(){r.els[d].setAttribute("class",t)})}),r.addClass=h(function(t){$(function(){r.els[d].classList.add(t)})}),r.removeClass=h(function(t){$(function(){r.els[d].classList.remove(t)})}),r.toggleClass=h(function(t,e){$(function(){r.els[d].classList.toggle(t,e)})}),r.haveClass=function(t){var e=!0;return $(function(){r.els[d].classList.contains(t)||(e=!1)}),e},r.innerHTML=h(function(t){if(t!==n)$(function(){r.els[d].innerHTML=t});else{var e="";return $(function(){e+=r.els[d].innerHTML}),e}}),r.innerText=h(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";$(function(){r.els[d].innerText=t})}),r.textContent=h(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";$(function(){r.els[d].textContent=t})}),r.html=h(function(t){if(t)r.innerHTML(t);else{var e="";return $(function(){e+=r.els[d].outerHTML}),e}}),r.forEach=h(function(e){$(function(){e({self:t(r.els[d]).select(),i:d})})}),r.on=h(function(t,e,n,i){t.split(", ").forEach(function(t){$(function(){r.els[d].addEventListener(t,e,n,i)}),r.ie[t]||(r.ie[t]=[]),r.ie[t].push([e,n,i])})}),r.off=h(function(t,e,n){t.split(", ").forEach(function(t){$(function(){r.els[d].removeEventListener(t,e,n)}),r.ie[t]&&(r.ie[t]=r.ie[t].filter(function(t){return t[0]!==e}))})}),r.onAll=h(function(t,e){v(r.ie,function(n,i){t&&t!==n||i[n].forEach(function(t){$(function(){e?r.els[d].removeEventListener(n,t[0]):r.els[d].addEventListener(n,t[0],t[1],t[2])})})})}),r.offAll=h(function(t){r.onAll(t,1)}),e&&r.add(e),r.take=function(e){if(r.add(e),r.el){var i=r.el.dataset.oInit;if(i!==n&&t.inits[i])return 1===r.length?(p=r.els[0],Object.assign(r,t.inits[i]),r.els=[p]):r=t.inits[i],b(!1,r.els),r}},r};o.first=function(t){return o(document.querySelector(t)||"")},o.inits=[],o.errors=[],o.showErrors=!1,o.logErrors=function(){o.errors.length?o.errors.forEach(function(t){return console.log(t)}):console.log("No errors")},o.onError=function(t){o.showErrors?console.log(t):o.errors.push(t)},o.init=function(t){return o().init(t)},o.initState=function(t,e){return o().init(t).render(e)},o.take=function(t){return o().take(t)},o.Z=0,o.N=1,o.W=2,o.H=100,o.F=!1,o.C=function(t,e){return Object.hasOwnProperty.call(t,e)},o.ajax=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new URLSearchParams;if(e.data&&"object"==_typeof(e.data)){for(var r in e.data)o.C(e.data,r)&&("object"==_typeof(e.data[r])?n.set(r,encodeURIComponent(JSON.stringify(e.data[r]))):n.set(r,e.data[r]));"GET"===e.method||"get"===e.method?t+="?"+n.toString():e.body||(e.body=n),delete e.data}return fetch(t,e)},o.get=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return o.ajax(t,_objectSpread(_objectSpread({},e),{},{method:"GET"}))},o.post=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return o.ajax(t,_objectSpread(_objectSpread({},e),{},{method:"POST"}))},o.getParams=function(t){var e,n={},r=new URLSearchParams(window.location.search).entries(),i=_createForOfIteratorHelper(r);try{for(i.s();!(e=i.n()).done;){var a=e.value;n[a[o.Z]]=a[o.N]}}catch(c){i.e(c)}finally{i.f()}return t?n[t]:n},o.incCache=!0,o.incCacheExp=864e5,o.incTimeout=6e3,o.incSource="",o.incForce=o.F,o.incAsync=!0,o.incCors=o.F,o.incFns={},o.incSet=[o.Z],o.incReady=[o.Z],o.incN=o.Z,o.incCheck=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return!n&&t&&e===o.U&&o.incReady[t]?o.incSet[t]===o.N:o.incReady[t]===o.U||o.incReady[t][e]===o.U?o.F:(o.incReady[t][e].loaded=n,o.incFns[o.incReady[t][e].name]=n,o.incReady[t][o.Z]+=n,t&&o.incReady[t].length===o.incReady[t][o.Z]&&("function"==typeof o.incSet[t]&&o.incSet[t](t),o.incSet[t]=o.N),o.incSet[t]===o.N)},o.incCacheClear=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o.F;for(var e in o.incFns)o.C(o.incFns,e)&&(localStorage.removeItem("inc-"+e),localStorage.removeItem("inc-"+e+"Expires"));return t&&(o.incReady.forEach(function(t,e){e&&t.forEach(function(t,n){n&&o("#oInc-"+e+"-"+n).remove()})}),o.incN=o.Z,o.incFns={},o.incSet=[o.Z],o.incReady=[o.Z]),!0},o.inc=function(t,e,n){var r=o.Z,i=o.Z,a="function";if("object"!=_typeof(t)||!t)return o.incSet[o.Z];o.incSet[o.Z]++;var c=o.incSet[o.Z];o.incSet[c]=e||o.Z,o.incReady[c]=[];var s=o.incReady[c];s[o.Z]=o.N;var l={},u=function e(n){if(o.C(t,n)){r++,o.incN++;var a=t[n].indexOf(".css")>-1?"style":"script";if(t[n]=(o.incSource?o.incSource+"/":"")+t[n],isNaN(n)&&o.C(o.incFns,n)&&o.incFns[n]&&!o.incForce)return s[r]={name:n,loaded:o.N},i++,1;if(s[r]={name:n,loaded:o.Z},isNaN(n)&&(o.incFns[n]=o.Z),isNaN(n)&&o.incCache&&"http"!==t[n].substring(o.Z,4)&&"file:"!==window.location.protocol&&(t[n].indexOf(".css")>-1||t[n].indexOf(".js")>-1)){var u=localStorage,f=u.getItem("inc-"+n),d=u.getItem("inc-"+n+"Expires");f&&d&&new Date().getTime()<d?(o.initState({tag:a,id:"oInc-"+c+"-"+r,innerHTML:f,"data-o-inc":c}).appendInside("head"),s[r].loaded=o.N,o.incFns[n]=o.N,i++):(l[n]=r,o.get(t[n],{mode:o.incCors?"cors":"same-origin"}).then(function(e){if(200!==e.status){o.onError&&o.onError({message:o.incSource+t[n]+" was not loaded"});return}e.text().then(function(t){u.setItem("inc-"+n,t),u.setItem("inc-"+n+"Expires",new Date().getTime()+o.incCacheExp),o.initState({tag:a,id:"oInc-"+c+"-"+l[n],innerHTML:t,"data-o-inc":c}).appendInside("head"),o.incCheck(c,l[n],o.N)})}))}else{var p={tag:a,id:"oInc-"+c+"-"+r,"data-o-inc":c,async:o.incAsync,onload:"o.incCheck("+c+","+r+",1)"};t[n].indexOf(".css")>-1?(p.tag="link",p.rel="stylesheet",p.href=t[n]):(t[n].indexOf(".js")>-1||(p.tag="img",p.style="display:none;"),p.src=t[n]),o.initState(p).appendInside(p.style?"body":"head")}}};for(var f in t)if(u(f))continue;return s[o.Z]+=i,r!==o.Z&&(i===r?_typeof(e)===a&&e(c):setTimeout(function(t){o.incReady[t]&&o.incReady[t].length<o.incReady[t][o.Z]&&(o.incSet[t]=o.Z,_typeof(n)===a&&n(c))},o.incTimeout,c)),o.incSet[o.Z]},o.tLog=[],o.tRes=[],o.tStatus=[],o.tFns=[],o.tShowOk=o.F,o.tStyled=o.F,o.tTime=2e3,o.tPre='<div style="font-family:monospace;text-align:left;">',o.tOk='<span style="background:#cfc;padding: 0 15px;">OK</span> ',o.tXx='<div style="background:#fcc;padding:3px;">',o.tDc="</div>",o.test=function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length,n=Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];var i=o.tLog.length,a=0,c="├ OK: ",s="├ ✘ ",l="\n",u="\n",f=n.length,d=o.Z;"function"==typeof n[f-o.N]&&(o.tFns[i]=n[f-o.N],f--),o.tStyled?(o.tLog[i]="<div><b>"+t+" #"+i+"</b></div>",c=o.tPre+o.tOk,s=o.tPre+o.tXx,u=(l=o.tDc)+l):o.tLog[i]=t+" #"+i+"\n",o.tRes[i]=o.F,o.tStatus[i]=[];for(var p=o.Z;p<f;p++){var y={n:i,i:p,title:n[p][o.Z],tShowOk:o.tShowOk,tStyled:o.tStyled},v=n[p][o.N];if("function"==typeof v)try{v=v(y)}catch(g){v=g.message,o.onError&&o.onError(g)}o.tStatus[i][p]="string"==typeof v?o.F:v,!0===v?(d++,o.tShowOk&&(o.tLog[i]+=c+n[p][o.Z]+l)):v!==o.U?o.tLog[i]+=s+n[p][o.Z]+(v!==o.F?": <i>"+v+"</i>":"")+u:(a++,setTimeout(function(t){t.title+=" (timeout)",o.testUpdate(t)},o.tTime,y))}return o.tRes[i]=d===f,o.tStyled?o.tLog[i]+=o.tPre+'<div style="color:'+(d+a!==f?"red":"green")+';"><b>':o.tLog[i]+=a?"├":"└ ",o.tLog[i]+="DONE "+d+"/"+(f-a),a&&(o.tLog[i]+=", waiting: "+a),o.tStyled?o.tLog[i]+="</b>"+o.tDc+o.tDc:o.tLog[i]+="\n",a||"function"!=typeof o.tFns[i]||o.tFns[i](i),i},o.testUpdate=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.F,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(o.tStatus[t.n][t.i]===o.U){o.tStatus[t.n][t.i]=!0===e,!0===e?t.tShowOk&&(t.tStyled?o.tLog[t.n]+=o.tPre+o.tOk+t.title+n+o.tDc:o.tLog[t.n]+="└ OK: "+t.title+n+"\n"):(o.tRes[t.n]=o.F,t.tStyled?o.tLog[t.n]+=o.tPre+o.tXx+t.title+n+(e?": "+e:"")+o.tDc+o.tDc:o.tLog[t.n]+="└ ✘ "+t.title+(e?": "+e:"")+n+"\n");var r,i=o.Z,a=i,c=_createForOfIteratorHelper(o.tStatus[t.n]);try{for(c.s();!(r=c.n()).done;){var s=r.value;if(s===o.U)return;!s&&i++,a++}}catch(l){c.e(l)}finally{c.f()}o.tRes[t.n]=!i;var u=i?"FAILED "+i+"/"+a:"DONE "+a+"/"+a;t.tStyled?o.tLog[t.n]+=o.tPre+'<b style="color:'+(i?"red":"green")+';">'+u+"</b>"+o.tDc:o.tLog[t.n]+="└ "+u,"function"==typeof o.tFns[t.n]&&o.tFns[t.n](t.n)}};
|
|
5
5
|
|
|
6
6
|
if (typeof module !== 'undefined' && module.exports) {
|
|
7
7
|
o.default = o;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "objs-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Encrease coding speed, by lightweight samples, states control, caching and auto tests. Easy to use: just split design into samples and give them data to render and action. Also Objs-core can create samples from server rendered DOM and more.",
|
|
5
5
|
"homepage": "https://fous.name/objs/",
|
|
6
6
|
"repository": {
|
package/objs.1.0.js.zip
DELETED
|
Binary file
|
package/objs.1.0.min.js.zip
DELETED
|
Binary file
|
package/tests.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
console.log("It's a DOM dependent library, all tests are here: https://fous.name/objs/documentation/");
|