" + fsInfo.unsupportedFiles + "")) : e +="INIT ERROR !", document.getElementById("status").innerHTML=e, "SPIFFS" !=fsInfo.type && (document.getElementById("mkdir").style.display="inline"))}, n.open("GET", "/status", !0), n.send(null)}function showHttpError(e){alert("ERROR: [" + e.status + "] " + e.responseText)}function canLoadNewContents(){return !!document.getElementById("saveBtn").disabled || !!confirm("Changes to your document will be lost if you continue") && (enableSaveDiscardBtns(!1), !0)}function enableSaveDiscardBtns(e){document.getElementById("saveBtn").disabled=!e, document.getElementById("discardBtn").disabled=!e}function getParentFolder(e){return (e=(e=e.startsWith("/") ? e : "/" + e).endsWith("/") ? e.slice(0, -1) : e).substring(0, e.lastIndexOf("/"))}function createHeader(e, n, t){var o=document.getElementById(e), a=document.createElement("input"); a.type="file", a.multiple=!1, a.name="data", o.appendChild(a); var d=document.createElement("input"); d.id="pathInput", d.type="text", d.name="path", d.defaultValue="/", o.appendChild(d); var l=document.createElement("button"); l.innerHTML="Upload", o.appendChild(l); var s=document.createElement("button"); s.id="mkdir", s.style.display="none", s.innerHTML="MkDir", o.appendChild(s); var i=document.createElement("button"); i.innerHTML="MkFile", o.appendChild(i); var c=document.createElement("span"); c.id="editorButtons", c.style.display="none", o.appendChild(c); var r=document.createElement("button"); r.id="saveBtn", r.innerHTML="Save", r.style.marginLeft="30px", r.disabled=!0, c.appendChild(r); var m=document.createElement("button"); m.id="discardBtn", m.innerHTML="Discard", m.disabled=!0, c.appendChild(m), (e=document.createElement("button")).id="helpBtn", e.innerHTML="?", c.appendChild(e), (c=document.createElement("span")).id="status", c.innerHTML="(loading)", o.appendChild(c), a.onchange=function (e){var t; 0 !==a.files.length && (t=a.files[0].name, d.value.startsWith("/") || (d.value="/" + d.value), d.value=getParentFolder(d.value) + "/" + t)}, l.onclick=function (e){0 !==a.files.length && n.httpUpload(a.files[0], d.value)}, i.onclick=function (e){var t=d.value.trim(); ""===t ? alert("A filename must be given") : t.endsWith("/") ? alert("Filenames must not end with a '/' character") : n.httpCreate(t)}, s.onclick=function (e){var t=d.value.trim(); ""===t ? alert("A folder name must be given") : (t.endsWith("/") || (t +="/"), n.httpCreate(t))}, r.onclick=function (e){t.save()}, m.onclick=function (e){t.discard()}, e.onclick=function (e){t.showShortcuts()}}function createTree(e, a){var n=document.getElementById("preview"), t=document.createElement("div"); function d(e){document.getElementById("pathInput").value=e, document.getElementById("editor").style.display="none", document.getElementById("editorButtons").style.display="none", n.style.display="block", n.innerHTML=""}function l(e){document.getElementById("pathInput").value=e, document.getElementById("editor").style.display="none", document.getElementById("editorButtons").style.display="none", n.style.display="block", n.innerHTML="Ace editor could not be loaded from the internet nor from /edit/ace.js . Defaulting to text viewer...
"; var t=new XMLHttpRequest; t.onload=function (){document.getElementById("txtContents").textContent=this.responseText}, t.open("GET", e), t.send()}function s(e){if (void 0 !==(e=/(?:\.([^.]+))?$/.exec(e)[1])) switch (e.toLowerCase()){case "txt": case "htm": case "html": case "js": case "json": case "c": case "h": case "cpp": case "css": case "xml": return 1}}function i(e){if (void 0 !==(e=/(?:\.([^.]+))?$/.exec(e)[1])) switch (e.toLowerCase()){case "png": case "jpg": case "jpeg": case "gif": case "ico": return 1}}function r(n, o){var e=document.createElement("ul"); n.appendChild(e); var t=document.createElement("li"); e.appendChild(t), s(o) ? "undefined"==typeof ace ? (t.innerHTML="View", t.onclick=function (e){0 < document.body.getElementsByClassName("contextMenu").length && document.body.removeChild(n), canLoadNewContents() && l(o)}) : (t.innerHTML="Edit", t.onclick=function (e){0 < document.body.getElementsByClassName("contextMenu").length && document.body.removeChild(n), canLoadNewContents() && a.loadUrl(o)}) : i(o) && (t.innerHTML="Preview", t.onclick=function (e){0 < document.body.getElementsByClassName("contextMenu").length && document.body.removeChild(n), canLoadNewContents() && d(o)}), t=document.createElement("li"), e.appendChild(t), t.innerHTML="Download", t.onclick=function (e){var t; 0 < document.body.getElementsByClassName("contextMenu").length && document.body.removeChild(n), t=o, document.getElementById("download-frame").src=t + "?download=true"}, t=document.createElement("li"), e.appendChild(t), t.innerHTML="Rename/Move", t.onclick=function (e){0 < document.body.getElementsByClassName("contextMenu").length && document.body.removeChild(n); var t=prompt("Rename " + o + " to", o); null !=t && t !=o && p(o, t)}, t=document.createElement("li"), e.appendChild(t), t.innerHTML="Delete", t.onclick=function (e){0 < document.body.getElementsByClassName("contextMenu").length && document.body.removeChild(n), h(o)}}function c(e, t, n){var o=document.createElement("div"), a=document.body.scrollTop || document.documentElement.scrollTop, d=document.body.scrollLeft || document.documentElement.scrollLeft, l=e.clientX + d, s=e.clientY + a; o.className="contextMenu", o.style.display="block", o.style.left=l + "px", o.style.top=s + "px", (n ? r : function (n, o){var e=document.createElement("ul"); n.appendChild(e); var t=document.createElement("li"); e.appendChild(t); var a=document.getElementById(o).childNodes[0].checked, t=document.createElement("li"); e.appendChild(t), a ? (t.innerHTML="Collapse", t.onclick=function (e){0 < document.body.getElementsByClassName("contextMenu").length && document.body.removeChild(n), document.getElementById(o).childNodes[0].checked=!1}, a=document.createElement("li"), e.appendChild(a), a.innerHTML="Refresh", a.onclick=function (e){0 < document.body.getElementsByClassName("contextMenu").length && document.body.removeChild(n), m(o)}) : (t.innerHTML="Expand", t.onclick=function (e){0 < document.body.getElementsByClassName("contextMenu").length && document.body.removeChild(n), document.getElementById(o).childNodes[0].checked=!0, m(o)}), t=document.createElement("li"), e.appendChild(t), t.innerHTML="Rename/Move", t.onclick=function (e){0 < document.body.getElementsByClassName("contextMenu").length && document.body.removeChild(n); var t=prompt("Rename " + o + " to", o); null !=t && t !=o && p(o, t)}, t=document.createElement("li"), e.appendChild(t), t.innerHTML="Delete", t.onclick=function (e){0 < document.body.getElementsByClassName("contextMenu").length && document.body.removeChild(n), h(o)}})(o, t), document.body.appendChild(o); var i=o.offsetWidth, c=o.offsetHeight; o.onmouseout=function (e){(e.clientX < l || e.clientX > l + i || e.clientY < s || e.clientY > s + c) && 0 < document.body.getElementsByClassName("contextMenu").length && document.body.removeChild(o)}}function o(t, n){return function (){var e; setLoading(!1), 200 !=t.status ? showHttpError(t) : n ? (e=getParentFolder(n), t.responseText && t.responseText !=e && refreshPath(t.responseText), refreshPath(e), attemptLoad(n)) : refreshPath(t.responseText), refreshStatus()}}function m(e, t){var n, o, a; setLoading(!0, "Listing '" + e + "'..."), xmlHttp=new XMLHttpRequest, xmlHttp.onload=(n=xmlHttp, o=e, a=t, function (){var e, t; setLoading(!1), 200 !=n.status ? showHttpError(n) : (!(e=document.getElementById(o)) || (t=e.lastElementChild) && "UL"==t.tagName && e.removeChild(t), function (e, t){t.sort(function (e, t){return e.type==t.type ? e.name.localeCompare(t.name) : e.type.localeCompare(t.type)}); var n=document.createElement("ul"); document.getElementById(e).appendChild(n); for (var o=t.length, a=0; a < o; a++){var d="file"===(d=t[a]).type ? function (e, t, n){var o=document.createElement("li"); return o.id=("/"==e ? "" : e) + "/" + t, e=document.createElement("span"), s(t) ? e.classList.add("txt") : i(t) && e.classList.add("img"), e.innerHTML=t + " (" + readableSize(n) + ")", o.appendChild(e), o.onclick=function (e){attemptLoad(o.id)}, o.oncontextmenu=function (e){e.preventDefault(), e.stopPropagation(), c(e, o.id, !0)}, o}(e, d.name, d.size) : function (e, t, n){var o=document.createElement("li"); o.id=("/"==e ? "" : e) + "/" + t; var a=document.createElement("input"); return a.type="checkbox", void 0 !==n && n && (a.disabled="disabled"), o.appendChild(a), (n=document.createElement("label")).textContent=t, o.appendChild(n), a.onchange=function (e){a.checked && m(o.id)}, n.onclick=function (e){a.checked ? a.checked=!1 : (a.checked=!0, m(o.id))}, o.oncontextmenu=function (e){e.preventDefault(), e.stopPropagation(), c(e, o.id, !1)}, o}(e, d.name); n.appendChild(d)}}(o, JSON.parse(n.responseText)), void 0 !==document.getElementById(o).childNodes[0].checked && (document.getElementById(o).childNodes[0].checked=!0), a && a.length && u(a))}), xmlHttp.open("GET", "/list?dir=" + e, !0), xmlHttp.send(null)}function u(e){var t=e.pop(); t && m(t, e)}function p(e, t){setLoading(!0, "Renaming '" + e + "' to '" + t + "'..."), t.startsWith("/") || (t="/" + t), xmlHttp=new XMLHttpRequest, xmlHttp.onload=o(xmlHttp, t); var n=new FormData; n.append("path", t), n.append("src", e), xmlHttp.open("PUT", "/edit"), xmlHttp.send(n)}function h(e){setLoading(!0, "Deleting '" + e + "'..."), xmlHttp=new XMLHttpRequest, xmlHttp.onload=o(xmlHttp); var t=new FormData; t.append("path", e), xmlHttp.open("DELETE", "/edit"), xmlHttp.send(t)}return t.className="css-treeview", t.id="/", document.getElementById(e).appendChild(t), this.clearMainPanel=function (){document.getElementById("editor").style.display="none", document.getElementById("editorButtons").style.display="none", n.style.display="block", n.innerHTML="