summaryrefslogtreecommitdiffhomepage
path: root/plugins/webbox/html/webbox.js
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-05-11 20:03:09 +0200
committerRoland Reichwein <mail@reichwein.it>2020-05-11 20:03:09 +0200
commit99048beee343e0aacf538d53ce91c7b545f09089 (patch)
tree8b810067649a7762350b81edd3498ccfdaefe18e /plugins/webbox/html/webbox.js
parent15b2be158ac0147982dd30382251b3ce83e219c7 (diff)
webbox: added copy function
Diffstat (limited to 'plugins/webbox/html/webbox.js')
-rw-r--r--plugins/webbox/html/webbox.js65
1 files changed, 65 insertions, 0 deletions
diff --git a/plugins/webbox/html/webbox.js b/plugins/webbox/html/webbox.js
index e056c16..80ee8ed 100644
--- a/plugins/webbox/html/webbox.js
+++ b/plugins/webbox/html/webbox.js
@@ -626,6 +626,71 @@ function deleteItems() {
}
}
+function copy() {
+ showDialog();
+
+ var files = getSelectedFiles();
+ if (files.length == 0) {
+ document.getElementById("dialog").innerHTML = "No files selected.";
+ document.getElementById("okbutton").onclick = hideDialog;
+ return;
+ }
+
+ var message = "";
+ for (var i = 0; i < files.length; i++) {
+ message += files[i] + "<br/>";
+ }
+
+ document.getElementById("dialog").innerHTML = document.getElementById("copy-dialog").innerHTML;
+ document.getElementById("copydir").focus();
+ document.getElementById("copydir").onkeydown = function(evt) {
+ if (evt.key == "Enter") {
+ document.getElementById("okbutton").click();
+ }
+ }
+
+ document.getElementById("copyfiles").innerHTML = message;
+
+ document.getElementById("okbutton").onclick = function() {
+
+ var xhr = new XMLHttpRequest();
+
+ xhr.onreadystatechange = function() {
+ if (this.readyState != 4) {
+ return;
+ }
+ if (this.status != 200) {
+ document.getElementById("dialog").innerHTML = "HTTP error";
+ } else {
+ document.getElementById("dialog").innerHTML = xhr.responseText;
+ }
+
+ document.getElementById("okbutton").onclick = hideDialog;
+ document.getElementById("okbutton").focus();
+ loadContents(currentDir); // load new file list with deleted items
+ }
+
+ var parser = new DOMParser();
+ var xmlDocument = parser.parseFromString("<request></request>", "text/xml");
+ var filesElement = xmlDocument.getElementsByTagName("request")[0];
+
+ var targetElement = xmlDocument.createElement("target");
+ targetElement.appendChild(document.createTextNode(document.getElementById("copydir").value));
+ filesElement.appendChild(targetElement);
+
+ for (var i = 0; i < files.length; i++) {
+ var fileElement = xmlDocument.createElement("file");
+ fileElement.appendChild(document.createTextNode(files[i]));
+ filesElement.appendChild(fileElement);
+ }
+
+ xhr.open("POST", relativePath(currentDir) + "?command=copy", true);
+ xhr.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password));
+ xhr.setRequestHeader("Content-type", "text/xml");
+ xhr.send(xmlDocument);
+ }
+}
+
function move() {
showDialog();