'}function a(e,a){var i=ce("ul");e.appendChild(i);var o=ce("li");i.appendChild(o),s(a)?(o.innerHTML="Preview",o.onclick=function(t){n(a),document.body.getElementsByClassName("cm").length>0&&document.body.removeChild(e)}):d(a)&&(o.innerHTML="Edit",o.onclick=function(n){t.loadUrl(a),document.body.getElementsByClassName("cm").length>0&&document.body.removeChild(e)});var l=ce("li");i.appendChild(l),d(a)||s(a)||function(e){var t=/(?:.([^.]+))?$/.exec(e)[1];if(void 0!==typeof t)switch(t){case"ico":case"gz":case"zip":case"wav":case"mp3":case"pdf":return!0}return!1}(a)?(l.innerHTML="Download",l.onclick=function(t){(function(e){ge("download-frame").src="/edit?download="+e})(a),document.body.getElementsByClassName("cm").length>0&&document.body.removeChild(e)}):c(a)&&(i.appendChild(l),l.innerHTML="ChDir",l.onclick=function(t){m.removeChild(m.childNodes[0]),u(m,a),document.body.getElementsByClassName("cm").length>0&&document.body.removeChild(e)});var p=ce("li");i.appendChild(p),p.innerHTML="Delete",p.onclick=function(t){r(a),document.body.getElementsByClassName("cm").length>0&&document.body.removeChild(e)}}function i(e,t,n){var i=ce("div"),o=document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop,c=document.body.scrollLeft?document.body.scrollLeft:document.documentElement.scrollLeft,d=e.clientX+c,s=e.clientY+o;i.className="cm",i.style.display="block",i.style.left=d+"px",i.style.top=s+"px",a(i,t),document.body.appendChild(i);var r=i.offsetWidth,l=i.offsetHeight;i.onmouseout=function(e){(e.clientXd+r||e.clientYs+l)&&document.body.getElementsByClassName("cm").length>0&&document.body.removeChild(i)}}function o(e,a,o){var r=ce("li");r.id=a;var l=ce("span");return l.innerHTML=a,r.appendChild(l),r.onclick=function(e){d(r.id.toLowerCase())?t.loadUrl(r.id):s(r.id.toLowerCase())?n(r.id):c(r.id)&&(m.removeChild(m.childNodes[0])&&u(m,r.id.toLowerCase()))},r.oncontextmenu=function(e){e.preventDefault(),e.stopPropagation(),i(e,r.id)},r}function c(e){return-1==e.indexOf(".")}function d(e){var t=/(?:.([^.]+))?$/.exec(e)[1];if(void 0!==typeof t)switch(t){case"txt":case"htm":case"html":case"js":case"css":case"xml":case"json":case"conf":case"ini":case"h":case"c":case"cpp":case"php":case"hex":case"ino":case"pde":return!0}return!1}function s(e){var t=/(?:.([^.]+))?$/.exec(e)[1];if(void 0!==typeof t)switch(t){case"png":case"jpg":case"gif":case"bmp":return!0}return!1}function r(e){var t=new FormData;t.append("path",e),requests.add("DELETE","/edit",t,(function(e,t){200!=e?alert("ERROR["+e+"]: "+t):(m.removeChild(m.childNodes[0]),u(m,"/"))}))}function l(e,t){return function(t,n){200==t&&function(e,t,n){sortByKey(n,"name");var a=ce("ul");e.appendChild(a);for(var i=n.length,c=0;i>c;c++)"file"===n[c].type&&a.appendChild(o(0,n[c].name,n[c].size))}(e,0,JSON.parse(n))}}function u(e,t){requests.add("GET","/edit",{list:t},l(e))}var p=ge("preview"),m=ce("div");return m.className="tvu",ge(e).appendChild(m),this.refreshPath=function(e){m.removeChild(m.childNodes[0]),u(m,"/")},u(m,"/"),this}function createEditor(e,t,n,a,i){function o(e){var t="plain",n=/(?:.([^.]+))?$/.exec(e)[1];if(void 0!==typeof n)switch(n){case"txt":case"hex":case"conf":t="plain";break;case"htm":t="html";break;case"js":t="javascript";break;case"h":case"c":case"cpp":t="c_cpp";break;case"css":case"scss":case"php":case"html":case"json":case"xml":case"ini":t=n}return t}function c(e,t){200!=e&&alert("ERROR["+e+"]: "+t)}function d(e,t){ge("preview").style.display="none",ge("editor").style.display="block",200==e?s.setValue(t):s.setValue(""),s.clearSelection()}void 0===t&&(t="/index.htm"),void 0===n&&(n=o(t)),void 0===a&&(a="monokai"),void 0===i&&(i="text/"+n,"c_cpp"===n&&(i="text/plain"));var s=ace.edit(e);return"plain"!==n&&s.getSession().setMode("ace/mode/"+n),s.setTheme("ace/theme/"+a),s.$blockScrolling=1/0,s.getSession().setUseSoftTabs(!0),s.getSession().setTabSize(2),s.getSession().setUseWorker(!0),s.setHighlightActiveLine(!0),s.setShowPrintMargin(!1),s.commands.addCommand({name:"saveCommand",bindKey:{win:"Ctrl-S",mac:"Command-S"},exec:function(e){!function(e,t,n){var a=new FormData;a.append("data",new Blob([t],{type:n}),e),requests.add("POST","/edit",a,c)}(t,e.getValue()+"",i)},readOnly:!1}),s.commands.addCommand({name:"undoCommand",bindKey:{win:"Ctrl-Z",mac:"Command-Z"},exec:function(e){e.getSession().getUndoManager().undo(!1)},readOnly:!1}),s.commands.addCommand({name:"redoCommand",bindKey:{win:"Ctrl-Shift-Z",mac:"Command-Shift-Z"},exec:function(e){e.getSession().getUndoManager().redo(!1)},readOnly:!1}),s.loadUrl=function(e){ge("editor-filename").value=e,n=o(t=e),i="text/"+n,"plain"!==n&&s.getSession().setMode("ace/mode/"+n),function(e){requests.add("GET","/edit",{edit:e},d)}(t)},s}function onBodyLoad(){var e={},t=(window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,(function(t,n,a){e[n]=a})),createEditor("editor",e.file,e.lang,e.theme)),n=createTree("tree",t);window.define=ace.define,window.require=ace.require,ace.config.set("basePath","/"),ace.config.set("workerPath","/"),createFileUploader("uploader",n,t),void 0===e.file&&(e.file="/index.htm"),t.loadUrl(e.file)}"undefined"==typeof XMLHttpRequest&&(XMLHttpRequest=function(){try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(e){}try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}throw new Error("This browser does not support XMLHttpRequest.")});var QueuedRequester=function(){this.queue=[],this.running=!1,this.xmlhttp=null};QueuedRequester.prototype={_request:function(e){if(this.running=!0,!(!e instanceof Object)){var t=this;ge("loader").style.display="block";var n="";if(e.params instanceof FormData)n=e.params;else if(e.params instanceof Object)for(var a in e.params)n+=""===n?"GET"===e.method?"?":"":"&",n+=encodeURIComponent(a)+"="+encodeURIComponent(e.params[a]);this.xmlhttp=new XMLHttpRequest,this.xmlhttp.onreadystatechange=function(e,n){return function(){4==e.readyState&&(ge("loader").style.display="none",n.callback(e.status,e.responseText),0===t.queue.length&&(t.running=!1),t.running&&t._request(t.queue.shift()))}}(this.xmlhttp,e),"GET"===e.method?(this.xmlhttp.open(e.method,e.url+n,!0),this.xmlhttp.send()):(this.xmlhttp.open(e.method,e.url,!0),n instanceof String&&this.xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"),this.xmlhttp.send(n))}},stop:function(){this.running&&(this.running=!1),this.xmlhttp&&this.xmlhttp.readyState<4&&this.xmlhttp.abort()},add:function(e,t,n,a){this.queue.push({url:t,method:e,params:n,callback:a}),this.running||this._request(this.queue.shift())}};var requests=new QueuedRequester