2018-11-23 23:46:40 +00:00
|
|
|
let binary = null;
|
|
|
|
let pathNodes = [];
|
2018-05-20 08:58:37 +00:00
|
|
|
|
2018-04-23 01:43:19 +00:00
|
|
|
|
2018-11-23 23:46:40 +00:00
|
|
|
const getDir = (query) => {
|
|
|
|
let formUlPth = document.getElementById("DIRPATHUL");
|
|
|
|
let mergeType = document.getElementById("MergeType");
|
|
|
|
let passwd = undefined;
|
|
|
|
let data = "";
|
|
|
|
let cookies = "";
|
|
|
|
let dirCookie = "";
|
2018-08-19 18:51:20 +00:00
|
|
|
|
|
|
|
// 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
|
|
|
|
|
2018-11-23 23:46:40 +00:00
|
|
|
let size = dirCookie.length;
|
2018-08-19 18:51:20 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-11-23 23:46:40 +00:00
|
|
|
const uploadFiles = async () => {
|
|
|
|
let toUpload = document.getElementsByName("filesToUpload[]")[0];
|
|
|
|
let path = document.getElementById("path").innerHTML;
|
|
|
|
let reader = new FileReader();
|
|
|
|
let data = new FormData();
|
|
|
|
let size = toUpload.files.length;
|
2018-08-19 18:51:20 +00:00
|
|
|
|
|
|
|
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) {
|
2018-11-23 23:46:40 +00:00
|
|
|
for (let i = 0; i < size; i++) {
|
2018-08-19 18:51:20 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-11-23 23:46:40 +00:00
|
|
|
const createItem = (type) => {
|
|
|
|
let path = document.getElementById("path").innerHTML;
|
|
|
|
let newItem = document.getElementById("NewItem");
|
|
|
|
let 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-11-23 23:46:40 +00:00
|
|
|
const deleteItem = () => {
|
|
|
|
let path = document.getElementById("path").innerHTML;
|
2018-04-23 01:43:19 +00:00
|
|
|
// Clicked yes to delete and there is an item
|
|
|
|
if (itemObj != undefined && itemObj != null) {
|
2018-11-23 23:46:40 +00:00
|
|
|
let fullPth = path + itemObj;
|
2018-05-20 08:58:37 +00:00
|
|
|
fullPth = encodeURIComponent(fullPth);
|
2018-11-23 23:46:40 +00:00
|
|
|
let 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-11-23 23:46:40 +00:00
|
|
|
const renameItem = (obj) => {
|
|
|
|
let path = encodeURIComponent(document.getElementById("path").innerHTML);
|
|
|
|
let oldName = encodeURIComponent(formerFileName);
|
|
|
|
let newName = encodeURIComponent(obj.value);
|
|
|
|
let formData = "renameItem=true&oldName=" + oldName + "&newName=" + newName + "&path=" + path;
|
2018-08-19 18:51:20 +00:00
|
|
|
|
|
|
|
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-11-23 23:46:40 +00:00
|
|
|
const openInLocalProg = (media) => {
|
2018-08-19 18:51:20 +00:00
|
|
|
doAjax("resources/php/filesystemActions.php",
|
|
|
|
"media=" + media);
|
2018-04-23 01:43:19 +00:00
|
|
|
}
|