-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.min.js
More file actions
1 lines (1 loc) · 3.56 KB
/
app.min.js
File metadata and controls
1 lines (1 loc) · 3.56 KB
1
(()=>{const e=[],t={},n="DOMContentLoaded",i="addEventListener",l=(e,t)=>e.removeAttribute(t),a=e=>document.querySelectorAll(e),r={data:t=>(Rem_Data=new Proxy(t,{get:(e,t)=>Reflect.get(e,t),set(t,n,i){let l=t[n];t[n]=i,e.forEach((e=>{n!==e.var&&!0!==e.var||e.func(l,i)})),s(n,l,i,n)}}),Rem_Data),watch(t,n){e.push({var:t,func:n})},mounted(e){window[i](n,e)}};function o(e){if(t="do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,super,throw,while,yield,delete,export,import,return,switch,default,extends,finally,continue,debugger,function,arguments,typeof,void",n=String(e),!Boolean(t.split(",").filter((e=>n.includes(e))).length))return Object.keys(Rem_Data).forEach((t=>{e.includes(t)&&!e.includes("Rem_Data."+t)&&(e=e.replaceAll(t,"Rem_Data."+t))})),new Function(`return ${e}`)();var t,n}function c(e){const t=[],n=(e,n)=>t.push({prop:e,value:n}),i=e=>e.slice(0,e.indexOf(":")).trim(),l=e=>e.slice(e.indexOf(":")+1).trim(),a=t=>i(t||e).split("&").forEach((i=>{n(i.trim(),l(t||e))}));return e.includes(";")?e.split(";").forEach((e=>e.includes("&")?a(e):n(i(e),l(e)))):e.includes("&")?a():n(i(e),l(e)),t}function s(e,n,i,a){t[e]?.forEach((t=>{if(t.bind)for(const i of c(t.bind))"class"==i.prop&&(i.prop="className"),"text"==i.prop&&(i.prop="innerText"),"this"==i.prop?Rem_Data[i.value]!=t.el&&(Rem_Data[i.value]=t.el):"className"==i.prop?void 0!==n?(n="string"==typeof n?`"${n}"`:n,t.el.classList.remove(o(i.value.replaceAll(e,n))),t.el.classList.add(o(i.value))):t.el.className.includes(o(i.value))||(t.el.className+=" "+o(i.value)):"innerText"==i.prop?Rem_Data[i.value]!=t.el[i.prop]&&(Rem_Data[i.value]=t.el[i.prop]):t.el[i.prop]=o(i.value);if(t.if&&(o(t.if)?t.el.append(...t.html):t.el.innerHTML=""),t.css)for(const e of c(t.css))t.el.style[e.prop]=o(e.value);if(t.each){t.el.innerHTML="";for(const e in Rem_Data[t.each]){let n=f(t.html)[0]?.cloneNode(!0);if(!n)break;let i=n.innerHTML.replaceAll("$$",`${t.each}[${e}]`),a=i,r=i.match(/\{([^}]+)\}/g),c=r?.map((e=>e.slice(1,e.length-1).trim()));for(let e in c)i=i.replaceAll(r[e],o(c[e]));l(n,"in"),n.innerHTML=i,t.el.append(n),u(n,"in",a,e)}}if(t.in){let e=t.in,n=e.match(/\{([^}]+)\}/g),i=n.map((e=>e.slice(1,e.length-1).trim()));for(let t in n)e=e.replaceAll(n[t],o(i[t]));t.el.innerHTML=e}}))}function f(e){var t=document.createElement("div");return t.innerHTML=e,t.childNodes}function u(e,n,i,l){if("in"===n){let a=i||e.innerText,r=a.match(/\{([^}]+)\}/g)?.map((e=>e.slice(1,e.length-1).trim()));for(const i in t)if(r?.filter((e=>e.includes(i))).length)if(l){let r=t[i].filter((e=>e.k==l));r.length?r[0].el=e:t[i].push({el:e,[n]:a,k:l})}else t[i].push({el:e,[n]:a})}else for(const i in t)if(e.getAttribute(n).includes(i)){let l={};"if"===n&&(l.html=Array.from(e.children)),"each"===n&&(l.html=e.innerHTML.trim(),e.innerHTML=""),l[n]=e.getAttribute(n),l.el=e,t[i].push(l)}}window.Rem_Data=void 0,window.RemJs=r,document[i](n,(()=>{if(Rem_Data)for(const e of Object.keys(Rem_Data))"function"!=typeof Rem_Data[e]&&(t[e]=[]);const e="on,in,if,bind,css".split(",").map((e=>`[${e}]`)).join();for(const e of a("[each]"))u(e,"each"),l(e,"each");for(const e of a("[in]"))u(e,"in"),l(e,"in");for(const t of a(e)){if(t.hasAttribute("if")&&(u(t,"if"),l(t,"if")),t.hasAttribute("css")&&(u(t,"css"),l(t,"css")),t.hasAttribute("bind")){let e="change",n=t.getAttribute("bind");(n.includes("value")||n.includes("checked"))&&c(n).forEach((n=>{"value"==n.prop&&(e="input"),t[i](e,(()=>{Rem_Data[n.value]=t[n.prop]}))})),u(t,"bind"),l(t,"bind")}t.hasAttribute("on")&&(c(t.getAttribute("on")).forEach((e=>{t[i](e.prop,(function(){o(e.value)}))})),l(t,"on"))}for(const e in t)s(e)}))})();