2018-08-19 18:51:20 +00:00
|
|
|
var binary = null;
|
|
|
|
var pathNodes = [];
|
2018-05-20 08:58:37 +00:00
|
|
|
|
2018-04-23 01:43:19 +00:00
|
|
|
|
2018-08-19 18:51:20 +00:00
|
|
|
function getDir(query) {
|
|
|
|
var formUlPth = document.getElementById("DIRPATHUL");
|
|
|
|
var mergeType = document.getElementById("MergeType");
|
|
|
|
var passwd = undefined;
|
|
|
|
var data = "";
|
|
|
|
var cookies = "";
|
|
|
|
var dirCookie = "";
|
|
|
|
|
|
|
|
// push or pop to path list
|
|
|
|
if (query === "/") {
|
|
|
|
// Process path from cookie and set to array/list
|
|
|
|
dirCookie = getCookie("dirQuery");
|
|
|
|
if (dirCookie != "" && dirCookie != "./") {
|
|
|
|
dirCookie = dirCookie.split("/");
|
|
|
|
dirCookie.pop(); // account for ending empty slot
|
|
|
|
|
|
|
|
var size = dirCookie.length;
|
|
|
|
for (var i = 0; i < size; i++) {
|
|
|
|
pathNodes.push(dirCookie[i] + "/");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pathNodes = [];
|
|
|
|
pathNodes.push("." + query);
|
|
|
|
}
|
|
|
|
} else if (query === "../") {
|
|
|
|
// Only remove while not in root
|
|
|
|
if (pathNodes.length > 1) {
|
|
|
|
pathNodes.pop();
|
|
|
|
}
|
|
|
|
} else if (query === "./") {
|
|
|
|
// Do nothing since re-scanning dir
|
2018-08-25 21:10:09 +00:00
|
|
|
} else {
|
2018-08-19 18:51:20 +00:00
|
|
|
pathNodes.push(query); // Add path
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create path from array of items
|
|
|
|
for (pathNode of pathNodes) { data += pathNode; }
|
|
|
|
|
|
|
|
try {
|
|
|
|
passwd = document.getElementById("PASSWD").value;
|
|
|
|
} catch (e) {
|
|
|
|
passwd = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setup upload path for form and make a cookie for persistence during browser session....
|
|
|
|
formUlPth.value = data;
|
|
|
|
data = "dirQuery=" + encodeURIComponent(data);
|
|
|
|
document.cookie = data + "; expires=Sun, 31 Dec 2034 12:00:00 UTC";
|
|
|
|
data +="&mergeType=" + mergeType.checked
|
|
|
|
+ "Here&passwd=" + passwd;
|
|
|
|
|
|
|
|
doAjax("resources/php/getDirList.php", data);
|
|
|
|
}
|
|
|
|
|
|
|
|
async function uploadFiles() {
|
|
|
|
var toUpload = document.getElementsByName("filesToUpload[]")[0];
|
|
|
|
var path = document.getElementById("path").innerHTML;
|
|
|
|
var reader = new FileReader();
|
|
|
|
var data = new FormData();
|
|
|
|
var size = toUpload.files.length;
|
|
|
|
|
|
|
|
data.append("UploadFiles", "trut");
|
|
|
|
data.append("DIRPATHUL", path);
|
2018-04-23 01:43:19 +00:00
|
|
|
|
2018-08-19 18:51:20 +00:00
|
|
|
// Add files
|
|
|
|
if (size > 0) {
|
|
|
|
for (var i = 0; i < size; i++) {
|
|
|
|
data.append("filesToUpload[]", toUpload.files[i]);
|
|
|
|
}
|
2018-08-19 19:44:29 +00:00
|
|
|
fileUploader(data);
|
2018-08-19 18:51:20 +00:00
|
|
|
}
|
2018-04-23 01:43:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function createItem(type) {
|
2018-05-20 08:58:37 +00:00
|
|
|
var path = document.getElementById("path").innerHTML;
|
|
|
|
var newItem = document.getElementById("NewItem");
|
|
|
|
var fullPth = path + newItem.value;
|
2018-04-23 01:43:19 +00:00
|
|
|
newItem.value = "";
|
2018-05-20 08:58:37 +00:00
|
|
|
fullPth = encodeURIComponent(fullPth);
|
2018-04-23 01:43:19 +00:00
|
|
|
|
2018-08-19 18:51:20 +00:00
|
|
|
doAjax("resources/php/filesystemActions.php",
|
|
|
|
"createItem=true&item=" + fullPth + "&type=" + type);
|
2018-04-23 01:43:19 +00:00
|
|
|
}
|
|
|
|
|
2018-05-20 08:58:37 +00:00
|
|
|
function deleteItem() {
|
2018-04-23 01:43:19 +00:00
|
|
|
var path = document.getElementById("path").innerHTML;
|
|
|
|
// Clicked yes to delete and there is an item
|
|
|
|
if (itemObj != undefined && itemObj != null) {
|
|
|
|
var fullPth = path + itemObj;
|
2018-05-20 08:58:37 +00:00
|
|
|
fullPth = encodeURIComponent(fullPth);
|
2018-07-07 20:32:45 +00:00
|
|
|
var answer = confirm("Are you sure you want to delete: " + fullPth);
|
2018-04-23 01:43:19 +00:00
|
|
|
if (answer == true) {
|
2018-08-19 18:51:20 +00:00
|
|
|
doAjax("resources/php/filesystemActions.php",
|
|
|
|
"deleteItem=true&item=" + fullPth);
|
2018-04-23 01:43:19 +00:00
|
|
|
|
|
|
|
console.log("Deleted: " + fullPth);
|
|
|
|
itemObj = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-19 18:51:20 +00:00
|
|
|
function renameItem(obj) {
|
|
|
|
var path = encodeURIComponent(document.getElementById("path").innerHTML);
|
|
|
|
var oldName = encodeURIComponent(formerFileName);
|
|
|
|
var newName = encodeURIComponent(obj.value);
|
|
|
|
var formData = "renameItem=true&oldName=" + oldName + "&newName=" + newName + "&path=" + path;
|
|
|
|
|
|
|
|
console.log("Old name: " + oldName);
|
|
|
|
console.log("New name: " + newName);
|
|
|
|
|
|
|
|
doAjax("resources/php/filesystemActions.php",
|
|
|
|
formData);
|
2018-07-07 20:32:45 +00:00
|
|
|
}
|
2018-04-23 01:43:19 +00:00
|
|
|
|
2018-08-19 18:51:20 +00:00
|
|
|
function openInLocalProg(media) {
|
|
|
|
doAjax("resources/php/filesystemActions.php",
|
|
|
|
"media=" + media);
|
2018-04-23 01:43:19 +00:00
|
|
|
}
|