-
Notifications
You must be signed in to change notification settings - Fork 0
/
micro.min.js
6 lines (6 loc) · 29.1 KB
/
micro.min.js
1
2
3
4
5
6
/* ********************************************************* *\
| Micro.js framework made by PDKnight. All rights reserved. |
| For more information please visit |
| https://github.com/PDKnight/Micro.js. |
\* ********************************************************* */
"use strict";/*@cc_on @*/Function.prototype.bind||(Function.prototype.bind=function(t){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var e=Array.prototype.slice.call(arguments,1),s=this,i=function(){},n=function(){return s.apply(this instanceof i?this:t,e.concat(Array.prototype.slice.call(arguments)))};return this.prototype&&(i.prototype=this.prototype),n.prototype=new i,n}),"object"!=typeof window.console&&(window.console={log:function(){}}),String.prototype.startsWith||(String.prototype.startsWith=function(t){return 0==this.indexOf(t)}),String.prototype.endsWith||(String.prototype.endsWith=function(t){return this.indexOf(t)==this.length-1-t.length}),String.prototype.escape||(String.prototype.escape=function(){return this.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}),String.prototype.tr||(String.prototype.tr=function(){return this.replace(/^\s*|\s*$/g,"")}),Object.keys||(Object.keys=function(t){var e=[];for(var s in t)t.hasOwnProperty(s)&&e.push(s);return e}),Array.prototype.indexOf||(Array.prototype.indexOf=function(t,e){for(var s=e||0,i=this.length;i>s;s++)if(this[s]===t)return s;return-1});var Micro=new function(){this.e,this.version="1.4.5",this.tooltip={added:!1,html:'if(!Micro.tooltip.added){var e=document.createElement("div");e.id="ttDiv",e.style.position="fixed",e.style.color="white",e.style.fontSize="14px",e.style.background="rgba(25, 25, 25, 0.75)",e.style.padding="5px 12px",e.style.fontFamily="helvetica",e.style.borderRadius="2px",e.style.display="none",document.body.appendChild(e),Micro.addEvent(document,"mousemove",function(t){var i=t.target;if(e.style.display="none",i.hasAttribute("tooltip")){var n=i.getAttribute("tooltip");if(0!=n.length){var d={x:t.pageX+15,y:t.pageY+15,w:window.innerWidth-this.x,h:window.innerHeight-this.y};e.style.top=d.y+"px",e.style.left=d.x+"px",e.style.maxWidth=d.w+"px",e.style.maxHeight=d.h+"px",e.innerHTML=n,e.style.display=""}}},!1),Micro.addEvent(document,"mouseout",function(t){t=t?t:window.event;var i=t.relatedTarget||t.toElement;i&&"HTML"!=i.nodeName||(e.style.display="none")},!1),Micro.tooltip.added=!0}'},this.addEvent=function(t,e,s){t.addEventListener?t.addEventListener(e,s,!1):t.attachEvent?t.attachEvent("on"+e,s):t["on"+e]=s};var d=document,sel=function(t,e){return e?d.querySelectorAll(t):d.querySelector(t)},NO_XHR_MSG,XHR_FAILED_MSG,c=sel("*",!0),cs=[],p;for(p=0;p<c.length;p++)c[p].hasAttribute("m-enable")&&cs.push(c[p]);if(cs.length>1)throw new Error("Please use only one element with 'm-enable' attribute!");1==cs.length&&(this.e=cs[0]),NO_XHR_MSG="Error: Your browser can't create an AJAX request. ",XHR_FAILED_MSG="Error: The AJAX failed. Check your console for more information. ";var createXHR=function(){if("undefined"!=typeof XMLHttpRequest)return new XMLHttpRequest;if("undefined"!=typeof ActiveXObject){if("string"!=typeof arguments.callee.activeXString)for(var t=["MSXML2.XMLHttp.6.0","MSXML2.XMLHttp.3.0","MSXML2.XMLHttp"],e=0,s=t.length;s>e;e++)try{var i=new ActiveXObject(t[e]);return arguments.callee.activeXString=t[e],i}catch(n){}return new ActiveXObject(arguments.callee.activeXString)}err(NO_XHR_MSG)};this.getResponse=function(t,e,s,i){var n=createXHR(s),r="undefined"==typeof i?!0:i;n.onreadystatechange=function(){if(4==n.readyState)if(n.status>=200&&n.status<300||304==n.status){var i=n.responseText;if("undefined"==typeof e)return i;e(i,t)}else s(XHR_FAILED_MSG+" [status:"+n.status+"]")}.bind(this),n.open("get",t,r),n.send(null)}.bind(this);var Core=function(){var i,j;this.CSSprops=["all","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-shadow","text-shadow","caption-side","clear","clip","color","content","counter-increment","counter-reset","cursor","direction","display","empty-cells","float","font","font-family","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-weight","height","left","letter-spacing","line-height","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","max-height","max-width","min-height","min-width","opacity","orphans","outline","outline-color","outline-style","outline-width","overflow","padding","padding-bottom","padding-left","padding-right","padding-top","page-break-after","page-break-before","page-break-inside","position","quotes","right","table-layout","text-align","text-decoration","text-indent","text-transform","top","transform","transform-origin","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","white-space","widows","width","word-spacing","z-index"],this.C={createElement:function(t){return d.createElement(t)}.bind(this),arrToEl:function(t,e){return el=this.createElement(t[0].replace(/\s+$/,"")),el.innerHTML=t[2],el.innerHTML=el.innerHTML.replace(/(^\n|\n$)/gm,""),e?el.outerHTML:el},error:function(t,e,s){s.innerHTML="Error at line "+t+": "+e}.bind(this)},this.R={ln:1,lns:[],tagRe:/^\s*[a-zA-Z0-9-]+[\s\n]*$/,properties:{remove_spaces_at_start:"on",console_output:"off"},togglable:["remove_spaces_at_start","console_output"],isTogglable:function(t){if("number"!=typeof t)return!1;var e=Object.keys(this.properties);return 0>t||t>=e.length?!1:this.togglable.indexOf(e[t])>-1},check:function(t){var e=this.isTogglable(t);if("number"!=typeof t)return e?!1:"";var s=Object.keys(this.properties);if(0>t||t>=s.length)return!1;var i=this.properties[s[t]];return e?"on"==i||"true"==i:i},gl:function(){return this.R.lns[this.R.ln-1]}.bind(this),lnl:function(){return this.lns.length},hasNext:function(){return this.ln-1<this.lnl()},lineToElement:function(t){var e=this.gl(!0).replace(/\s+[\s\S]*/,"");return t?C.createElement(e):e},read:function(t,e,s,n){if(0==t.length)return[[1,"text",""]];this.R.lns=t.split(/\n/);for(var r,o,a,l,h,p="";this.R.hasNext();){if(r=this.R.gl(),/^@.+/.test(r)){var c=/^@import\s+([^\s\n]+)\s*$/,d=/^@title\s+(.+)\s*$/,u=/^@favicon\s+(.+)\.(.+)\s*$/;if(u.test(r)){var f=r.match(u),g=f[1],m=f[2],b=sel("link#favicon");b&&(b.hasAttribute("href")?b.getAttribute("href")!=g+"."+m:!0)&&b.remove();var A=document.createElement("link");A.id="favicon",A.rel="icon",A.type="image/"+m,A.href=g+"."+m,document.head&&document.head.appendChild(A),this.R.ln++;continue}if(c.test(r)){var v=r.match(c)[1];if(!/.+(.css|.js)$/.test(v))return void e("Please import only .css or .js file(s).",this.R.ln);this.A.responses[v.indexOf(".css")==v.length-4?"styles":"scripts"].push(v),this.R.ln++;continue}if(d.test(r)){var k=r.match(d)[1];document.title&&(document.title=k),this.R.ln++;continue}if(/^@[^:]+:\s*.+/.test(r)){if(a=r.split(/:\s*/),l=a[0].replace(/^@/,""),!this.R.properties.hasOwnProperty(l))return void e("Unknown property: "+l+".",this.R.ln);h=a[1].replace(/\s+$/,""),this.R.properties[l]=h,this.R.ln++;continue}}this.A.arr.length>0&&this.A.tag_level>0&&this.R.check(0)&&(r=r.replace(/^(\t| {4})/,"")),(0==r.length||13!=r.charCodeAt(r.length-1))&&(r+=this.R.ln!=this.R.lns.length?String.fromCharCode(13):this.A.brackets.started()?String.fromCharCode(10):"");var y="";for(i=0;i<r.length&&(o=r[i],"#"!=o||(i>0?"\\"==r[i-1]:0)||this.A.brackets.started());i++){var R=("%c- "+this.R.ln+", '"+o+"', "+o.charCodeAt(0),this.A.arr);if("{"==o&&0==this.A.commands.level||"}"==o&&1==this.A.commands.level||this.A.commands.started()||0==R.length&&this.R.tagRe.test(p)&&"{"==o)if(p&&!this.A.commands.started()&&(this.A.brackets.started()?y=p:this.A.New(["text",p]),p=""),this.A.commands.started())if("}"==o||i==r.length-1&&this.R.ln==this.R.lns.length)if(this.A.commands.level--,!this.A.commands.level||i==r.length-1&&this.R.ln==this.R.lns.length){var w=p+(this.A.commands.level||"}"!=o?o:"");if(this.A.brackets.started()){var x=this.A.print();this.A.arr=[[1,"command",w,!0]],this.A.together(function(t){e(t)},s,function(t){p=y+t,this.A.arr=x}.bind(this))}else this.A.New(["command",w,!this.A.commands.level&&"}"==o]),p=""}else p+="}";else"{"==o?(this.A.commands.level++,p+="{"):p+=13==o.charCodeAt(0)?"\n":o;else"{"==o&&(this.A.commands.level++,i==r.length-1&&this.R.ln==this.R.lns.length&&(p+="{"));else{if("("==o&&0==this.A.brackets.level||")"==o&&1==this.A.brackets.level||this.A.brackets.started()||0==R.length&&this.R.tagRe.test(p)&&"("==o){p&&!this.A.brackets.started()&&(this.A.New(["text",p]),p="");var $,L,_="";for($=R.length-1;$>=0;$--)if(L=R[$],"text"==L[1]){if(this.R.tagRe.test(L[2])){_=L[2];break}if(!/^\s*$/.test(L[2]))break}if(_){this.A.brackets.started()?")"==o||i==r.length-1&&this.R.ln==this.R.lns.length?(this.A.brackets.level--,!this.A.brackets.level||i==r.length-1&&this.R.ln==this.R.lns.length?(this.A.brackets.state=-1,this.A.New(["properties",p+(this.A.brackets.level||")"!=o?o:""),!this.A.brackets.level&&")"==o]),p=""):p+=")"):"("==o?(this.A.brackets.level++,p+="("):p+=13==o.charCodeAt(0)?"\n":o:"("==o&&(this.A.brackets.state=0,this.A.brackets.level++,i==r.length-1&&this.R.ln==this.R.lns.length&&(p+="("));continue}if(this.A.isSpace(p)){this.A.New(["text","("]),p="";continue}}if("]"!=o)if(/^[^\s\n]+[\s\n]+$/.test(p))/[\s\n]/.test(o)?p+=o:"["==o?(this.A.New(["element_start",p.replace(/^\s+|\s+$/g,"")]),p=""):(this.A.New(["text",p]),p=o);else if(this.A.isSpace(p)&&/[a-zA-Z0-9-]/.test(o))this.A.New(["text",p]),p=o;else if(/[a-zA-Z0-9-\s\n]/.test(o))p+=o,i==r.length-1&&(this.A.New(["text",p]),p="",this.A.New(["EOL",""]));else if("\\"==o)p.length>0&&p.endsWith("\\")?p+=o:(this.A.New(["text",p]),p=o);else if("["==o)if(this.R.tagRe.test(p)){var R=this.A.arr;if(/^\s+[a-zA-Z0-9-]+[\s\n]*$/.test(p)){var E=p.match(/^(\s+)/)[1];this.A.New(["text",E]),p=p.replace(/^\s+/,"")}this.A.New(["element_start",p.endsWith("\\")?p.replace(/\\?$|^\s+|\s+$/g,""):p.replace(/^\s+|\s+$/g,"")]),p=""}else{var R=this.A.arr;if(/^\s*$/.test(p)&&(R.length>1?"properties"!=R[R.length-1][1]:1))if(R.length>1){var $,S,C,M,L="",_="";for($=R.length-1;$>=0;$--)if(L=R[$],"EOL"!=L[1])if("properties"!=L[1]){if("text"!=L[1])break;if(!this.A.isSBracket(L[2])){if(M=!1,this.A.isSpace(L[2])&&$>0){var O,N;for(O=$-1;O>=0;O--)if(N=R[O],"EOL"!=N[1]){if("text"!=N[1])break;if(this.A.isSBracket(N[2])){M=!0;break}if(!this.A.isSpace(N[2])&&!this.R.tagRe.test(N[2]))break}}if(M)break;if(this.R.tagRe.test(L[2])){_=L[2],this.A.arr.splice($),this.A.properties=C,this.A.New(["element_start",_.replace(/^\s+|\s+$/g,"")]),S=!0;break}}}else C=L[2];S||this.A.New(["text","["])}else this.A.New(["text","["]);else if(R.length>1&&"properties"==R[R.length-1][1]){var $,L,_="";for($=R.length-1;$>=0;$--)L=R[$],"text"==L[1]&&(this.R.tagRe.test(L[2])?(_=L[2],$=0):$=0);this.A.New(["element_start",""]),p=""}else this.A.New(["text",p]),p="",this.A.New(["element_start",""])}else p?(this.A.New(["text",(p.endsWith("\\")?p.replace(/\\?$/,""):p)+o]),p=""):p+=o;else"\\"!=p?(this.A.New(["text",p]),this.A.New(["element_end",""]),p=""):(this.A.New(["text",o]),p="")}}this.R.ln++;var H=this.A.arr;this.A.brackets.started()||this.A.commands.started()||(H.length>1?"EOL"==H[H.length-1][1]:0)||(this.A.New(["text",p]),p="",this.A.New(["EOL",""]))}return this.R.ln--,/^[\s\n]*$/.test(p)||this.A.New(["text",p]),this.A.arr}.bind(this)},this.A={tv:{els:[],inner:"",append:function(t,e,s){this.inner+=((e.length>0?RegExp("<"+e[e.length-1]+"\\s*(\\s*[a-zA-Z0-9-]+\\s*=\\s*(\"[^\"]*\"|'[^']*'))*$").test(s):"")?">":"")+t},tags:[],startedBrackets:!1,reset:function(){this.A.tv.els=this.A.print(),this.A.tv.inner="",this.A.tv.tags=[],this.A.tv.startedBrackets=!1}.bind(this),variables:{}},isSpace:function(t){return/^[\s\n]*$/.test(t)},tag:"",isTag:function(t){return/^\s*[a-zA-Z0-9-]+[\s\n]*$/.test(t)},isSBracket:function(t){return/^\s*\[[\s\n]*$/.test(t)},banned_tags:["style","script"],components:{container:["div",""],menu:["div",'class="menu"'],"menu-brand":["img",'class="menu-brand"'],"menu-item":["a",'class="menu-item"'],clear:["div",'class="clear"'],dark:["div",'class="dark"'],grand:["div",'class="grand"'],"grand-content":["div",'class="grand-content"'],title:["div",'class="title"'],"sub-title":["div",'class="sub-title"'],code:["div",'class="code"'],middle:["div",'class="middle"'],sh:["span",'class="sh"'],"upbar-container":["div",'class="upbar-container"'],upbar:["div",'class="upbar" onclick="this.remove();"']},responses:{styles:[],scripts:[]},properties:"",closedProperties:!1,pReset:function(){this.properties="",this.closedProperties=!1},propsLine:0,tag_level:0,arr:[],brackets:{started:!1,text:"",state:-1,level:0,append:function(t){this.text+=t},started:function(){return this.state>-1}},commands:{started:!1,text:"",level:0,append:function(t){this.text+=t},started:function(){return this.level>0}},tg_level:function(t){return t.length},New:function(t){t.unshift(this.R.ln),this.A.arr.push(t),"element_start"==t[1]&&(this.A.tag_level+=1),this.A.tag_level>0&&"element_end"==t[1]&&(this.A.tag_level-=1)}.bind(this),print:function(t){return"string"==typeof t?"inner: "+t+", tag: "+this.A.tag+", properties: "+this.A.properties+", propsLine: "+this.A.propsLine:this.A.arr}.bind(this),hasNextElementWithVal:function(t,e,s,i){if(t.length<2||e>=t.length-2)return!1;var n;for(n=e+1;kk=t[n];n++)if(!("EOL"==kk[1]||"text"==kk[1]&&/^[\s\n]*$/.test(kk[2]))&&new RegExp(i).test(kk[s]))return!0;return!1},isNearElement:function(t,e,s){if(t.length<2||e>=t.length-2)return!1;var i,n;for(i=e+1;n=t[i];i++)if("EOL"!=n[1]&&(s?"properties"!=n[1]:1)){if("text"==n[1]){if(/^[^\\]*\]$/.test(n[2]))break;if(/^[\s\n]*$/.test(n[2]))continue;if(/^\s*\[$/.test(n[2]))return!0;break}if("element_start"==n[1]){if(this.isSpace(n[2]))return!0;break}if("element_end"==n[1])break}return!1},isBeforeElement:function(t,e){if(t.length<2&&2>e)return!1;var s,i;for(s=e-1;s>=0;s--)if(i=t[s],"EOL"!=i[1]&&"properties"!=i[1]){if("text"==i[1]){if(this.isTag(i[2]))return!0;if(this.isSpace(i[2]))continue;break}break}return!1},readProperties:function(t,e,s,i){if(/^[\s\n]*$/.test(t))return null;var n,r,o,a,l,h,p={},c={},d=t.split("\n");for(n=0;n<d.length;n++)if(r=d[n],!/^[\s\n]*$/.test(r)){if(!/^\s*[^:]+\s*:\s*.+\s*$/.test(r))return s("Wrong syntax. Use pattern -> property: value.",e-d.length+n+1),"err";if(a=r.split(/\s*:\s*/),h=a[1],a.length>2)for(var u=2;u<a.length;u++)h+=":"+a[u];if(l=a[0].replace(/^\s+|\s+$/,"").toLowerCase(),h=h.replace(/^\s+|\s+$/,""),!/^\!?[a-zA-Z0-9-]+$/.test(l))return s("Unsupported property syntax: "+l+".",e-d.length+n+1),"err";!l.startsWith("!")&&this.CSSprops.indexOf(l)>-1?c[l]=h:p[l.replace(/^\!/,"")]=h}if(!i)return p;var f=Object.keys(p),g=Object.keys(c),m="",b="";if(g.length>0)for(n=0;n<g.length;n++)r=g[n],o=c[r],b+=r+":"+o+(n==g.length-1?"":";");for(m+=0==b.length?"":' style="'+b+'"',n=0;n<f.length;n++)r=f[n],o=p[r],m+=" "+r+'="'+o+'"';return m}.bind(this),cmdLineLoop:function(k,cmds,tags,inner,repeat,cond,err,micro,fn){if(k>=cmds.length)return void fn(inner);var kk=cmds[k].tr(),mtch,mtch2,cmd,argz,endCmdLoop=!1,oneLineCommands=["end-repeat","newline","end-if"],Continue=function(){this.A.cmdLineLoop(++k,cmds,tags,inner,repeat,cond,err,micro,fn)}.bind(this),append=function(t){this.A.tv.append(t,tags,inner),inner=this.A.tv.inner}.bind(this),getVariables=function(t){var e,s=t.split("@"),i=[];if(s.length<2)return[];for(e=1;e<s.length;e++){var n=s[e].split(/[^a-zA-Z0-9-]/)[0];(s[e-1].length>0?s[e-1].indexOf("\\")!=s[e-1].length-1:!0)&&n.length>0&&this.A.tv.variables.hasOwnProperty(n)&&i.push(n)}return i}.bind(this),replaceVariables=function(t){for(var e,s=getVariables(t),i=0;i<s.length;i++)e=s[i],t=t.replace(new RegExp("@"+e,"g"),this.A.tv.variables[e]);return t}.bind(this),parse=function(t){for(var e,s=0,n="",r="",o=0,a=function(){return o>0};s<t.length;s++){if(e=t[s],"{"==e&&0==o||"}"==e&&1==o||a())if(n&&!a()&&(r+=n,n=""),a())if("}"==e||i==t.length-1)if(o--,o&&i!=t.length-1)n+="}";else{var l=n+(o||"}"!=e?e:""),h=this.A.print(),p=this.R.properties.console_output,c=this.A.tv.inner;this.R.properties.console_output="off",this.A.arr=[[1,"command",l,!0]],this.A.together(function(t){err(t)},micro,function(t){r+=t,n="",this.A.arr=h,this.R.properties.console_output=p,this.A.tv.inner=c}.bind(this))}else"{"==e?(o++,n+="{"):n+=13==e.charCodeAt(0)?"\n":e;else"{"==e&&(o++,i==t.length-1&&(n+="{"));else r+=e;if(s==t.length-1)return r}}.bind(this),getCookie=function(t){for(var e,s=t+"=",i=document.cookie.split(";"),n=0;n<i.length;n++){for(e=i[n];" "==e.charAt(0);)e=e.substring(1,e.length);if(0==e.indexOf(s))return e.substring(s.length,e.length)}return""};return this.A.isSpace(kk)?void Continue():(mtch=kk.match(/^(\S+)\s+(.+)$/),mtch2=kk.match(/^(\S+)$/),null!=mtch&&"undefined"!=typeof mtch[2]&&!this.A.isSpace(mtch[2])||null!=mtch2&&-1!=oneLineCommands.indexOf(mtch2[1])?(mtch?(cmd=mtch[1],argz=parse(replaceVariables(mtch[2]))):(cmd=mtch2[1],argz=""),repeat.is&&"end-repeat"!=cmd?(repeat.text+=kk+"\n",void Continue()):cond.is&&"end-if"!=cmd?(cond.text+=kk+"\n",void Continue()):void Micro.read(function(args){switch(args=args.replace(/</g,"<").replace(/>/g,">"),cmd){case"echo":append(args);break;case"get":endCmdLoop=!0,micro.getResponse(args,function(t){append(t),this.A.loopElements(i+1,err,micro,function(t){fn(t)})}.bind(this),function(t){err(t+": File named '"+args+"' doesn't exist.",this.R.ln),this.A.loopElements(i+1,err,micro,function(t){fn(t)})}.bind(this),!0);break;case"rand":var spl=args.split(/\s/g);if(1==spl.length){err("Correct syntax: rand a b ... n",this.R.ln);break}var ri=spl[Math.floor(Math.random()*spl.length)];append(ri);break;case"def":var mtchh=args.match(/(\S+)\s*(.+)/);if(null==mtchh){err("Correct syntax: def a b",this.R.ln);break}if(!/^[a-zA-Z0-9-]+$/.test(mtchh[1])){err("Only alphanumeric words (with optional hyphen) are supported.",this.R.ln);break}this.A.tv.variables[mtchh[1]]=mtchh[2];break;case"set-cookie":var mtchh=args.match(/(\S+)\s*(.+)/);if(null==mtchh){err("Correct syntax: set-cookie name value.",this.R.ln);break}if(!/^[a-zA-Z0-9-]+$/.test(mtchh[1])){err("Only alphanumeric name (with optional hyphen) is supported.",this.R.ln);break}document.cookie=mtchh[1]+"="+mtchh[2]+"; Path=/;";break;case"get-cookie":if(!/^[a-zA-Z0-9-]+$/.test(args)){err("Only alphanumeric name (with optional hyphen) is supported.",this.R.ln);break}append(getCookie(args));break;case"eval":var evalResult="";try{evalResult=eval("(function(){"+(~args.indexOf("return")?"":"return ")+"'"+eval(args)+"'})")()}catch(e){evalResult=e}append(evalResult);break;case"exec":eval(args);break;case"upper":append(args.toUpperCase());break;case"lower":append(args.toLowerCase());break;case"reverse":for(var t="",u=args.length;u>0;)t+=args.substring(u-1,u),u--;append(t);break;case"capitalize":append(args.toLowerCase().replace(/\b\w/g,function(t){return t.toUpperCase()}));break;case"repeat":if(repeat.is){err("You can't start a repeat inside a repeat.",this.R.ln);break}var mtchh=args.match(/(\S+)\s*(.*)/);if(!/^\d+$/.test(mtchh[1])){err("Count must be an integer.",this.R.ln);break}if(this.A.isSpace(mtchh[2])){repeat.is=!0,repeat.count=parseInt(mtchh[1]);break}for(var h=0,hh=parseInt(mtchh[1]);hh>h;h++){var property=this.R.properties.console_output,inner2=this.A.tv.inner;this.R.properties.console_output="off",this.A.arr=[[1,"command",mtchh[2],!0]],this.A.together(function(t){err(t)},micro,function(t){this.R.properties.console_output=property,this.A.tv.inner=inner2,append(t)}.bind(this))}break;case"end-repeat":if(repeat.is){repeat.is=!1;for(var h=0;h<repeat.count;h++){var property=this.R.properties.console_output,inner2=this.A.tv.inner;this.R.properties.console_output="off",this.A.arr=[[1,"command",repeat.text,!0]],this.A.together(function(t){err(t)},micro,function(t){this.R.properties.console_output=property,this.A.tv.inner=inner2,append(t),this.A.cmdLineLoop(++k,cmds,tags,inner,repeat,cond,err,micro,fn)}.bind(this))}endCmdLoop=!0}else err("You can't end a repeat without starting it.",this.R.ln);break;case"newline":append("<br>");break;case"if":if(cond.is){err("You can't start a condition inside a condition.",this.R.ln);break}if(!/^((?!(==|!=|<|<=|>|>=)).)+(==|!=|<|<=|>|>=).+/.test(args)){err("Condition must contain one of operators (==, !=, >, >=, <, <=).",this.R.ln);break}cond.is=!0,cond.condition=args;break;case"end-if":if(cond.is){cond.is=!1;var resultCondition=!1,q=cond.condition,splits=[q.split("=="),q.split("!="),q.split(/<(?!=)/),q.split("<="),q.split(/>(?!=)/),q.split(">=")];if(splits[0].length>1)resultCondition=splits[0][0]==splits[0][1];else if(splits[1].length>1)resultCondition=splits[1][0]!=splits[1][1];else if(splits[2].length>1){if(splits[2][0]=splits[2][0].tr(),splits[2][1]=splits[2][1].tr(),!/^[+-]?\d+$/.test(splits[2][0])||!/^[+-]?\d+$/.test(splits[2][1])){err("You can compare only integers with < operator.",this.R.ln);break}resultCondition=parseInt(splits[2][0])<parseInt(splits[2][1])}else if(splits[3].length>1){if(splits[3][0]=splits[3][0].tr(),splits[3][1]=splits[3][1].tr(),!/^[+-]?\d+$/.test(splits[3][0])||!/^[+-]?\d+$/.test(splits[3][1])){err("You can compare only integers with <= operator.",this.R.ln);break}resultCondition=parseInt(splits[3][0])<=parseInt(splits[3][1])}else if(splits[4].length>1){if(splits[4][0]=splits[4][0].tr(),splits[4][1]=splits[4][1].tr(),!/^[+-]?\d+$/.test(splits[4][0])||!/^[+-]?\d+$/.test(splits[4][1])){err("You can compare only integers with > operator.",this.R.ln);break}resultCondition=parseInt(splits[4][0])>parseInt(splits[4][1])}else if(splits[5].length>1){if(splits[5][0]=splits[5][0].tr(),splits[5][1]=splits[5][1].tr(),!/^[+-]?\d+$/.test(splits[5][0])||!/^[+-]?\d+$/.test(splits[5][1])){err("You can compare only integers with >= operator.",this.R.ln);break}resultCondition=parseInt(splits[5][0])>=parseInt(splits[5][1])}if(resultCondition){var property=this.R.properties.console_output,inner2=this.A.tv.inner;this.R.properties.console_output="off",this.A.arr=[[1,"command",cond.text,!0]],this.A.together(function(t){err(t)},micro,function(t){this.R.properties.console_output=property,this.A.tv.inner=inner2,append(t),this.A.cmdLineLoop(++k,cmds,tags,inner,repeat,cond,err,micro,fn)}.bind(this)),endCmdLoop=!0}}else err("You can't end a condition without starting it.",this.R.ln);break;default:err("Unknown command: "+cmd,this.R.ln)}endCmdLoop||this.A.cmdLineLoop(++k,cmds,tags,inner,repeat,cond,err,micro,fn)}.bind(this),argz,!1,!1,function(t,e){e=e||"unknown",failed="Error at line "+e+": "+t})):void err("Unknown command statement: "+kk,this.R.ln))}.bind(this),loopElements:function(t,e,s,i){for(var n,r=this.A.tv.els,o=this.A.tv.inner,a=this.A.tv.tags,l=this.A.tv.startedBrackets,h=!1;t<r.length;t++){n=r[t];var p=n[1],c=n[2];switch("text"==p&&!/(^\s*\[$|^[\s\n]*$)/.test(c)&&/^\s*[a-zA-Z0-9-]+\s*$/.test(c)||"element_start"==p&&!/^[\s\n]*$/.test(c)?this.A.tag=c:"properties"==p||/(^\s*\[$|^[\s\n]*$)/.test(c)||(this.A.tag=""),"properties"==p?(this.A.properties=c,this.A.closedProperties=n[3],this.A.propsLine=n[0]):"text"!=p||/[^\[]*\[$/.test(c)||/[\s\n]*/.test(c)||this.A.pReset(),p){case"element_start":var d=this.A.tag,u=d.tr(),f=RegExp("("+d+")((<br>|\\s|\\n)*)$"),g=this.A.components,m="",b=this.A.properties;if((a.length>0?RegExp("<"+a[a.length-1]+"\\s*(\\s*[a-zA-Z0-9-]+\\s*=\\s*(\"[^\"]*\"|'[^']*'))*$").test(o):!1)&&(o+=">"),this.A.banned_tags.indexOf(u)>-1)return void e("Unsupported element: "+u+".",n[0]);if(g.hasOwnProperty(u)&&(m=" "+g[u][1],u=g[u][0]),/^[\s\n]*$/.test(c)||b||a.push(u),!d)break;if(!this.A.isTag(u)){o+=f.test(o)?"":d+"[",this.A.tag="",this.A.pReset();break}if(t>0&&"element_start"==r[t-1][1]&&/^\s*$/.test(r[t-1][2])&&(o+="["),b){var A=o.replace(f,"");o=A,o+="<"+u+m,a.push(u);var v=this.A.readProperties(b,this.A.propsLine,e,!0);if("err"==v)return void i("");o+=null==v?"":v,this.A.pReset();continue}0==c.length?RegExp("<"+a[a.length-1]+"\\s*(\\s*[a-zA-Z0-9-]+\\s*=\\s*(\"[^\"]*\"|'[^']*'))*>$").test(o)||(o+="<"+u+m,a.push(u)):o+="<"+u+m,this.A.tag=u;break;case"properties":if(t<r.length-1){var k,y;for(k=t+1;k<r.length;k++)if(y=r[k],!("EOL"==y[1]||"text"==y[1]&&/^\s*$/.test(y[2]))){if("properties"==y[1]){var R=n[3],w=!1;Micro.read(function(t){return o+="("+t+(R?")":""),w?w:void 0},c,!1,!1,function(t,e){e=e||"unknown",w="Error at line "+e+": "+t});break}break}}break;case"text":var x=/(^\s*\[$|^[\s\n]*$)/,$=this.A.isNearElement(r,t,!0);if(c=c.replace(/[<>]/g,function(t){switch(t){case"<":return"<";case">":return">"}}),t>1&&(this.A.properties||(t>0?"properties"==r[t-1][1]:!1))){var b=this.A.properties;if(this.A.isNearElement(r,t)&&/^(<br>|\s|\n)*$/.test(c))continue;var w=!1;s.read(function(t){var e="("+t+(this.A.closedProperties?")":"");return w?w:((a.length>0?RegExp("<"+a[a.length-1]+"\\s*(\\s*[a-zA-Z0-9-]+\\s*=\\s*(\"[^\"]*\"|'[^']*'))*$").test(o):!1)&&(o+=">"),o+=e,void this.A.pReset())}.bind(this),b+(b.split("\n").length>1,""),!1,!1,function(t,e){e=e||"unknown",w="Error at line "+e+": "+t})}else!this.A.isBeforeElement(r,t)&&(t>0&&a.length>0?"element_start"==r[t-1][1]||"text"==r[t-1][1]&&/^\s*\[[\s\n]*$/.test(r[t-1][2]):!0)&&((a.length>0?RegExp("<"+a[a.length-1]+"\\s*(\\s*[a-zA-Z0-9-]+\\s*=\\s*(\"[^\"]*\"|'[^']*'))*$").test(o):!1)?(o+=">"+(/^\s*\[[\s\n]*$/.test(c)?"[":""),this.A.tag="",this.A.pReset()):(/^\s*\[[\s\n]*$/.test(c)||(t>0?"element_start"==r[t-1][1]&&/^\s*$/.test(r[t-1][2]):!1))&&(o+="[",this.A.tag="",this.A.pReset()));o+=t<r.length-1&&!c.endsWith("\\")&&"]"!=r[t+1][2]&&r.length>1?this.A.isSpace(c)?c:$&&this.R.tagRe.test(c)?"":a.length>0?!RegExp("<"+a[a.length-1]+"\\s*(\\s*[a-zA-Z0-9-]+\\s*=\\s*(\"[^\"]*\"|'[^']*'))*>$").test(o)&&x.test(c)?"":c:t>0?/^\s*\[[\s\n]*$/.test(c)?"element_start"==r[t-1][1]?c:"":c:/^\s*\[[\s\n]*$/.test(c)?"":c:/\\+/.test(c)?c:c.replace(/\\+$/,"");break;case"EOL":var L=this.A.isNearElement(r,t);if(L&&this.A.tag)break;(t>0?"element_start"==r[t-1][1]||"element_end"==r[t-1][1]:0)||(t>1&&a.length>0?"element_end"!=r[t-2][1]&&"element_start"!=r[t-2][1]?L:1:0)||t==r.length-1||(o+="<br>");break;case"element_end":if(0==a.length)return void e("There's an unwanted closing parenthesis in your .mi file.",this.R.ln);o+="</"+a[a.length-1]+">",a.pop(),this.A.tag="";break;case"command":var _=c.tr().split("\n"),E={text:"",is:!1,count:0},S={text:"",is:!1,condition:""};this.A.cmdLineLoop(0,_,a,o,E,S,e,s,function(t){this.A.tv.inner=t,o=t}.bind(this))}if(this.A.tv.els=r,this.A.tv.inner=o,this.A.tv.tags=a,this.A.tv.startedBrackets=l,t==r.length-1&&i(o),h)break}}.bind(this),together:function(t,e,s){if(!e)return"";this.A.tv.reset();this.A.loopElements(0,t,e,function(t){s(t)})}.bind(this)}};if(this.read=function(t,e,s,i,n){if("string"!=typeof e)throw new Error("Unexpected argument (1). Please use at least 2 arguments (function, string).");if(0==e.length)return void t("");var r=(new Date).getTime(),o=!1;n=n||function(t,e){e=e||"unknown",o="Error at line "+e+": "+t};var a=new Core,l=a.R.read(e,n,this,this.version);return i?l:void a.A.together(n,this,function(e){var i=o?o:e;t(s?[(new Date).getTime()-r,i,a.A.responses]:i)})},this.render=function(r,el,el2){r&&(el=el||this.e,this.read(function(inn){var responses,k,kk,l,ll,innerMatch=el.innerHTML.match(/[\s\S]+(?=(<style\s*(?:\s*[a-zA-Z0-9-]+\s*=\s*(?:\"[^\"]*\"|'[^']*'))*>[\s\S]+<\/style>.*|<script\s*(?:\s*[a-zA-Z0-9-]+\s*=\s*(?:\"[^\"]*\"|'[^']*'))*>[\s\S]+<\/script>.*))/),dd;if(inn instanceof Array&&(responses=inn[2]),el2&&inn instanceof Array&&(el2.innerHTML=inn[0]+"ms"),null!=innerMatch){dd=document.createElement("div"),dd.innerHTML=innerMatch[1];var styles=dd.querySelectorAll("style"),ddInner="";if(responses&&responses.styles.length>0)for(l=0;l<styles.length;l++)styles[l].hasAttribute("id")&&responses.styles.indexOf(styles[l].id)>-1&&(ddInner+=styles[l].outerHTML);dd.innerHTML=ddInner}if(el.style.display="none",el.innerHTML=inn instanceof Array?inn[1]:inn,dd)return el.innerHTML+=dd.innerHTML,eval(this.tooltip.html),void(el.style.display="");if(responses&&(responses.hasOwnProperty("styles")||responses.hasOwnProperty("scripts"))){if(responses.styles.length>0)for(k=0;kk=responses.styles[k];k++)this.getResponse(kk,function(t,e){el.innerHTML+='<style id="'+e+'">'+t+"</style>",0==responses.scripts.length&&k==responses.styles.length&&(el.style.display="")},function(t){el.innerHTML=t},!0);if(responses.scripts.length>0)for(k=0;kk=responses.scripts[k];k++)this.getResponse(kk,function(r){eval(r),k==responses.scripts.length&&(el.style.display="")},function(t){el.innerHTML=t},!0)}eval(this.tooltip.html),(!responses||responses&&(responses.hasOwnProperty("styles")||responses.hasOwnProperty("scripts"))&&0==responses.styles.length&&0==responses.scripts.length)&&(el.style.display="")}.bind(this),r,!0))},"undefined"!=typeof this.e){var link=this.e.getAttribute("m-enable");"this"==link?this.render(this.e.innerHTML.replace(/&/g,"&"),this.e):this.getResponse(link+".mi",function(t){this.render(t)}.bind(this),function(t){this.e.innerHTML=t}.bind(this),!0)}};