From 3d4cbd7d10ca2e5f23f9e3982e18f9cec3ee1a04 Mon Sep 17 00:00:00 2001 From: ed Date: Sun, 26 Sep 2021 14:48:05 +0200 Subject: [PATCH] spa mkdir --- copyparty/web/browser.js | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 43ee0921..d318d171 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -1561,6 +1561,9 @@ function play_linked() { function sortfiles(nodes) { + if (!nodes.length) + return nodes; + var sopts = jread('fsort', [["href", 1, ""]]); try { @@ -4078,6 +4081,59 @@ var msel = (function () { })(); +(function () { + if (!window.FormData) + return; + + var form = QS('#op_mkdir>form'), + tb = QS('#op_mkdir input[name="name"]'), + sf = mknod('div'); + + clmod(sf, 'msg', 1); + form.parentNode.appendChild(sf); + + form.onsubmit = function (e) { + ev(e); + clmod(sf, 'vis', 1); + sf.textContent = 'creating "' + tb.value + '"...' + + var fd = new FormData(); + fd.append("act", "mkdir"); + fd.append("name", tb.value); + + var xhr = new XMLHttpRequest(); + xhr.vp = get_evpath(); + xhr.dn = tb.value; + xhr.open('POST', xhr.vp, true); + xhr.onreadystatechange = cb; + xhr.responseType = 'text'; + xhr.send(fd); + + return false; + }; + + function cb() { + if (this.readyState != XMLHttpRequest.DONE) + return; + + if (this.vp !== get_evpath()) { + sf.textContent = 'aborted due to location change'; + return; + } + + if (this.status !== 200) { + sf.textContent = 'error: ' + this.responseText; + return; + } + + clmod(sf, 'vis'); + sf.textContent = ''; + tb.value = ''; + treectl.goto(this.vp + uricom_enc(this.dn) + '/', true); + } +})(); + + function show_readme(md, url, depth) { if (!treectl.ireadme) return;