summaryrefslogtreecommitdiffhomepage
path: root/plugins/webbox/html/webbox.js
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/webbox/html/webbox.js')
-rw-r--r--plugins/webbox/html/webbox.js33
1 files changed, 20 insertions, 13 deletions
diff --git a/plugins/webbox/html/webbox.js b/plugins/webbox/html/webbox.js
index 9a38051..602f76d 100644
--- a/plugins/webbox/html/webbox.js
+++ b/plugins/webbox/html/webbox.js
@@ -4,6 +4,13 @@ var numberOfSelectedRows = 0;
var username = "notaname";
var password = "password";
+function relativePath(path) {
+ if (path.startsWith("/"))
+ return path.substr(1);
+ else
+ return path;
+}
+
function clearContents() {
var result = "<table class=\"list\">";
// empty list
@@ -35,9 +42,9 @@ function loadContents(dir) {
for (var i = 0; i < listElements.length; i++) {
var type = listElements[i].getAttribute("type");
if (type == "file") {
- type = "<img src=\"file.png\"/>";
+ type = "<img src=\"webbox-html/file.png\"/>";
} else if (type == "dir") {
- type = "<img src=\"directory.png\"/>";
+ type = "<img src=\"webbox-html/directory.png\"/>";
} else {
type = "";
}
@@ -57,7 +64,7 @@ function loadContents(dir) {
}
- xhr.open("GET", "bin" + dir + "?command=list", true);
+ xhr.open("GET", relativePath(dir) + "?command=list", true);
xhr.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password));
xhr.send();
}
@@ -329,7 +336,7 @@ function initMainpage() {
initMainpage2();
}
- xhrTitle.open("GET", "bin?command=server-info", true);
+ xhrTitle.open("GET", "?command=server-info", true);
xhrTitle.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password));
xhrTitle.send();
@@ -350,7 +357,7 @@ function initMainpage2() {
document.getElementsByClassName("footer")[0].innerHTML = xhrFooter.responseText;
}
- xhrFooter.open("GET", "bin?command=version", true);
+ xhrFooter.open("GET", "?command=version", true);
xhrFooter.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password));
xhrFooter.send();
@@ -431,7 +438,7 @@ function download(filename) {
filesElement.appendChild(fileElement);
}
- xhr.open("POST", "bin" + currentDir + "?command=download-zip", true);
+ xhr.open("POST", relativePath(currentDir) + "?command=download-zip", true);
xhr.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password));
xhr.setRequestHeader("Content-type", "text/xml");
xhr.responseType = 'blob';
@@ -458,7 +465,7 @@ function download(filename) {
dir += "/"
}
progressOn();
- xhr.open("GET", "bin" + dir + filename, true);
+ xhr.open("GET", relativePath(dir) + filename, true);
xhr.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password));
xhr.responseType = 'blob';
xhr.send();
@@ -493,7 +500,7 @@ function createDir() {
dirElement.appendChild(document.createTextNode(document.getElementById("newdir").value));
- xhr.open("POST", "bin" + currentDir + "?command=newdir", true);
+ xhr.open("POST", relativePath(currentDir) + "?command=newdir", true);
xhr.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password));
xhr.setRequestHeader("Content-type", "text/xml");
xhr.send(xmlDocument);
@@ -557,7 +564,7 @@ function onUploadFile() {
formData.append("uploadfile", uploadfile.files[i]);
}
- xhr.open("POST", "bin" + currentDir + "?command=upload", true);
+ xhr.open("POST", relativePath(currentDir) + "?command=upload", true);
xhr.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password));
xhr.send(formData);
}
@@ -607,7 +614,7 @@ function deleteItems() {
filesElement.appendChild(fileElement);
}
- xhr.open("POST", "bin" + currentDir + "?command=delete", true);
+ xhr.open("POST", relativePath(currentDir) + "?command=delete", true);
xhr.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password));
xhr.setRequestHeader("Content-type", "text/xml");
xhr.send(xmlDocument);
@@ -672,7 +679,7 @@ function move() {
filesElement.appendChild(fileElement);
}
- xhr.open("POST", "bin" + currentDir + "?command=move", true);
+ xhr.open("POST", relativePath(currentDir) + "?command=move", true);
xhr.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password));
xhr.setRequestHeader("Content-type", "text/xml");
xhr.send(xmlDocument);
@@ -736,7 +743,7 @@ function rename() {
newnameElement.appendChild(document.createTextNode(document.getElementById("renamenew").value));
filesElement.appendChild(newnameElement);
- xhr.open("POST", "bin" + currentDir + "?command=rename", true);
+ xhr.open("POST", relativePath(currentDir) + "?command=rename", true);
xhr.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password));
xhr.setRequestHeader("Content-type", "text/xml");
xhr.send(xmlDocument);
@@ -784,7 +791,7 @@ function info() {
filesElement.appendChild(fileElement);
}
- xhr.open("POST", "bin" + currentDir + "?command=info", true);
+ xhr.open("POST", relativePath(currentDir) + "?command=info", true);
xhr.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password));
xhr.setRequestHeader("Content-type", "text/xml");
xhr.send(xmlDocument);