Fix filename parsing

This commit is contained in:
fvanroie 2021-05-21 18:56:32 +02:00
parent c1d4fad16e
commit 8d16dfb186
2 changed files with 64 additions and 66 deletions

View File

@ -1,10 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<!doctypehtml>
<html lang=en>
<head>
<meta charset='utf-8'>
<meta charset=utf-8>
<title>File Editor</title>
<style type="text/css" media="screen">
<style media=screen>
.cm {
z-index: 300;
position: absolute;
@ -17,7 +17,7 @@
font-family: sans-serif;
font-weight: 700
}
.cm ul {
list-style: none;
top: 0;
@ -25,39 +25,39 @@
margin: 0;
padding: 0
}
.cm li {
position: relative;
min-width: 60px;
cursor: pointer
}
.cm span {
color: #444;
display: inline-block;
padding: 6px
}
.cm li:hover {
background: #444
}
.cm li:hover span {
color: #eee
}
.tvu li,
.tvu ul {
padding: 0;
margin: 0;
list-style: none
}
.tvu input {
position: absolute;
opacity: 0
}
.tvu {
font: normal 12px Verdana, Arial, Sans-serif;
-moz-user-select: none;
@ -66,7 +66,7 @@
color: #444;
line-height: 16px
}
.tvu span {
margin-bottom: 5px;
padding: 0 0 0 18px;
@ -77,27 +77,26 @@
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAADoSURBVBgZBcExblNBGAbA2ceegTRBuIKOgiihSZNTcC5LUHAihNJR0kGKCDcYJY6D3/77MdOinTvzAgCw8ysThIvn/VojIyMjIyPP+bS1sUQIV2s95pBDDvmbP/mdkft83tpYguZq5Jh/OeaYh+yzy8hTHvNlaxNNczm+la9OTlar1UdA/+C2A4trRCnD3jS8BB1obq2Gk6GU6QbQAS4BUaYSQAf4bhhKKTFdAzrAOwAxEUAH+KEM01SY3gM6wBsEAQB0gJ+maZoC3gI6iPYaAIBJsiRmHU0AALOeFC3aK2cWAACUXe7+AwO0lc9eTHYTAAAAAElFTkSuQmCC) no-repeat;
background-position: 0 0
}
.tvu span:hover {
text-decoration: underline
}
@media screen and (-webkit-min-device-pixel-ratio:0) {
.tvu {
-webkit-animation: webkit-adjacent-element-selector-bugfix infinite 1s
}
}
@-webkit-keyframes webkit-adjacent-element-selector-bugfix {
from {
padding: 0
}
to {
padding: 0
}
}
#uploader {
position: absolute;
top: 0;
@ -110,7 +109,7 @@
background-color: #444;
color: #eee
}
#tree {
position: absolute;
top: 28px;
@ -119,7 +118,7 @@
width: 160px;
padding: 8px
}
#editor,
#preview {
position: absolute;
@ -129,16 +128,16 @@
left: 160px;
border-left: 1px solid #eee
}
#preview {
background-color: #eee;
padding: 5px
}
button.right {
float: right
}
input.number {
float: right;
width: 48px
@ -165,41 +164,41 @@
function u() {
4 == o.readyState && (200 != o.status ? alert("ERROR[" + o.status + "]: " + o.responseText) : t.refreshPath(c.value))
}
m.setAttribute("type", "number"), m.setAttribute("min", 1), m.setAttribute("max", 12), document.getElementById(e).appendChild(m), m.className = "number", i.onclick = function (e) {
-1 !== c.value.indexOf(".") && (function (e) {
m.setAttribute("type", "number"), m.setAttribute("min", 1), m.setAttribute("max", 12), document.getElementById(e).appendChild(m), m.className = "number", i.onclick = function(e) {
-1 !== c.value.indexOf(".") && (function(e) {
(o = new XMLHttpRequest).onreadystatechange = u;
var t = new FormData;
t.append("path", e), o.open("PUT", "/edit"), o.send(t)
}(c.value), n.loadUrl(c.value))
}, l.onclick = function (e) {
}, l.onclick = function(e) {
if (0 !== d.files.length) {
(o = new XMLHttpRequest).onreadystatechange = u;
var t = new FormData;
t.append("data", d.files[0], c.value), o.open("POST", "/edit"), o.send(t)
}
}, d.onchange = function (e) {
}, d.onchange = function(e) {
if (0 !== d.files.length) {
var t = d.files[0].name,
n = /(?:.([^.]+))?$/.exec(t)[1],
a = /(.*).[^.]+$/.exec(t)[1];
void 0 !== typeof a && (t = a), void 0 !== typeof n && ("html" === n ? n = "htm" : "jpeg" === n && (n = "jpg"), t = t + "." + n), "/" === c.value || 0 === c.value.lastIndexOf("/") ? c.value = "/" + t : c.value = c.value.substring(0, c.value.lastIndexOf("/") + 1) + t
}
}, s.onclick = function (e) {
! function (e) {
}, s.onclick = function(e) {
! function(e) {
(o = new XMLHttpRequest).onreadystatechange = u;
var t = new FormData;
t.append("load", e), o.open("PUT", "/edit"), o.send(t)
}(c.value)
}, r.onclick = function (e) {
! function (e) {
}, r.onclick = function(e) {
! function(e) {
(o = new XMLHttpRequest).onreadystatechange = u;
var t = new FormData;
t.append("init", e), o.open("PUT", "/edit"), o.send(t)
}(c.value)
}, a.onclick = function (e) {
}, a.onclick = function(e) {
c.value, window.location.href = "/"
}, m.onchange = function (e) {
! function (e) {
}, m.onchange = function(e) {
! function(e) {
(o = new XMLHttpRequest).onreadystatechange = u;
var t = new FormData;
t.append("page", e), o.open("PUT", "/edit"), o.send(t)
@ -212,28 +211,28 @@
a = document.createElement("div");
function o(e) {
document.getElementById("editor").style.display = "none", n.style.display = "block", n.innerHTML = '<img src="' + e + "?_cb=" + Date.now() + '" style="max-width:100%; max - height: 100 % ; margin: auto; display: block;" />'
document.getElementById("editor").style.display = "none", n.style.display = "block", n.innerHTML = '<img src="' + e + "?_cb=" + Date.now() + '" style="max-width:100%; max - height: 100 % ; margin: auto; display: block;"/>'
}
function d(e, n) {
var d = document.createElement("ul");
e.appendChild(d);
var c = document.createElement("li");
d.appendChild(c), l(n) ? (c.innerHTML = "<span>Edit</span>", c.onclick = function (a) {
d.appendChild(c), l(n) ? (c.innerHTML = "<span>Edit</span>", c.onclick = function(a) {
t.loadUrl(n), document.body.getElementsByClassName("cm").length > 0 && document.body.removeChild(e)
}) : i(n) && (c.innerHTML = "<span>Preview</span>", c.onclick = function (t) {
}) : i(n) && (c.innerHTML = "<span>Preview</span>", c.onclick = function(t) {
o(n), document.body.getElementsByClassName("cm").length > 0 && document.body.removeChild(e)
});
var r = document.createElement("li");
d.appendChild(r), r.innerHTML = "<span>Download</span>", r.onclick = function (t) {
! function (e) {
d.appendChild(r), r.innerHTML = "<span>Download</span>", r.onclick = function(t) {
! function(e) {
document.getElementById("download-frame").src = e + "?download=true"
}(n), document.body.getElementsByClassName("cm").length > 0 && document.body.removeChild(e)
};
var m = document.createElement("li");
d.appendChild(m), m.innerHTML = "<span>Delete</span>", m.onclick = function (t) {
! function (e) {
xmlHttp = new XMLHttpRequest, xmlHttp.onreadystatechange = function () {
d.appendChild(m), m.innerHTML = "<span>Delete</span>", m.onclick = function(t) {
! function(e) {
xmlHttp = new XMLHttpRequest, xmlHttp.onreadystatechange = function() {
4 == xmlHttp.readyState && (200 != xmlHttp.status ? alert("ERROR[" + xmlHttp.status + "]: " + xmlHttp.responseText) : (a.removeChild(a.childNodes[0]), s(a, "/")))
};
var t = new FormData;
@ -246,11 +245,11 @@
var c = document.createElement("li");
c.id = ("/" == e ? "" : e) + "/" + n;
var s = document.createElement("span");
return s.innerText = n, c.appendChild(s), c.onclick = function (e) {
return s.innerText = n, c.appendChild(s), c.onclick = function(e) {
l(c.id.toLowerCase()) ? t.loadUrl(c.id) : i(c.id.toLowerCase()) && o(c.id)
}, c.oncontextmenu = function (e) {
}, c.oncontextmenu = function(e) {
e.preventDefault(), e.stopPropagation(),
function (e, t, n) {
function(e, t, n) {
var a = document.createElement("div"),
o = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop,
c = document.body.scrollLeft ? document.body.scrollLeft : document.documentElement.scrollLeft,
@ -259,7 +258,7 @@
a.className = "cm", a.style.display = "block", a.style.left = l + "px", a.style.top = i + "px", d(a, t), document.body.appendChild(a);
var s = a.offsetWidth,
r = a.offsetHeight;
a.onmouseout = function (e) {
a.onmouseout = function(e) {
(e.clientX < l || e.clientX > l + s || e.clientY < i || e.clientY > i + r) && document.body.getElementsByClassName("cm").length > 0 && document.body.removeChild(a)
}
}(0, c.id)
@ -295,9 +294,9 @@
}
function s(e, t) {
xmlHttp = new XMLHttpRequest(e, t), xmlHttp.onreadystatechange = function (e, t) {
return function () {
4 == xmlHttp.readyState && 200 == xmlHttp.status && function (e, t, n) {
xmlHttp = new XMLHttpRequest(e, t), xmlHttp.onreadystatechange = function(e, t) {
return function() {
4 == xmlHttp.readyState && 200 == xmlHttp.status && function(e, t, n) {
var a = document.createElement("ul");
e.appendChild(a);
for (var o = n.length, d = 0; d < o; d++) "file" === n[d].type && a.appendChild(c(t, n[d].name, n[d].size))
@ -305,7 +304,7 @@
}
}(e, t), xmlHttp.open("GET", "/list?dir=" + t, !0), xmlHttp.send(null)
}
return a.className = "tvu", document.getElementById(e).appendChild(a), this.refreshPath = function (e) {
return a.className = "tvu", document.getElementById(e).appendChild(a), this.refreshPath = function(e) {
a.removeChild(a.childNodes[0]), s(a, "/")
}, s(a, "/"), this
}
@ -354,14 +353,14 @@
}
function s() {
4 == c.readyState && (document.getElementById("preview").style.display = "none", document.getElementById("editor").style.display = "block", function (e, t) {
4 == c.readyState && (document.getElementById("preview").style.display = "none", document.getElementById("editor").style.display = "block", function(e, t) {
if (200 == t.status) try {
var n = JSON.parse(t.responseText);
e.setValue(JSON.stringify(n, null, 4))
} catch (n) {
e.setValue(t.responseText)
} else e.setValue("");
e.resize(!0), e.scrollToLine(1, !0, !0, function () { }), e.gotoLine(1, 0, !0), e.clearSelection()
e.resize(!0), e.scrollToLine(1, !0, !0, function() {}), e.gotoLine(1, 0, !0), e.clearSelection()
}(l, c))
}
@ -374,14 +373,14 @@
win: "Ctrl-S",
mac: "Command-S"
},
exec: function (e) {
! function (e, t, n) {
exec: function(e) {
! function(e, t, n) {
(c = new XMLHttpRequest).onreadystatechange = i;
var a = new FormData;
a.append("data", new Blob([t], {
type: n
}), e), c.open("POST", "/edit"), c.send(a)
}(t, function (e) {
}(t, function(e) {
var t = e.getValue();
try {
var n = JSON.parse(t);
@ -398,7 +397,7 @@
win: "Ctrl-Z",
mac: "Command-Z"
},
exec: function (e) {
exec: function(e) {
e.getSession().getUndoManager().undo(!1)
},
readOnly: !1
@ -408,32 +407,31 @@
win: "Ctrl-Shift-Z",
mac: "Command-Shift-Z"
},
exec: function (e) {
exec: function(e) {
e.getSession().getUndoManager().redo(!1)
},
readOnly: !1
}), r(t), l.loadUrl = function (e) {
}), r(t), l.loadUrl = function(e) {
n = d(t = e), o = "text/" + n, "plain" !== n && l.getSession().setMode("ace/mode/" + n), r(t), document.getElementById("upload-path").value = e
}, l
}
function onBodyLoad() {
var e = {},
t = (window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (t, n, a) {
t = (window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(t, n, a) {
e[n] = a
}), createEditor("editor", e.file, e.lang, e.theme));
createFileUploader("uploader", createTree("tree", t), t), e.file && (document.getElementById("upload-path").value = e.file)
}
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ace.js" type="text/javascript"
charset="utf-8"></script>
<script charset=utf-8 src=https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ace.js></script>
</head>
<body onload="onBodyLoad();">
<div id="uploader"></div>
<div id="tree"></div>
<div id="editor"></div>
<div id="preview" style="display:none;"></div><iframe id=download-frame style='display:none;'></iframe>
<body onload=onBodyLoad();>
<div id=uploader></div>
<div id=tree></div>
<div id=editor></div>
<div id=preview style=display:none;></div><iframe id=download-frame style=display:none;></iframe>
</body>
</html>

Binary file not shown.