";
+ filesListSecondChild.innerHTML += filesToPrint;
+ datapath = arrayNameJoined;
+ getInfoFilesSecondSearch();
+ })
+}
+
+function printFilesSearchTrash(arrayFiles) {
+ let filesToPrint;
+ arrayFiles.forEach(function (element) {
+ let newName = element.slice(9);
+ let arrayName = newName.split(".");
+ let fileExt = arrayName.slice(-1)[0];
+ if (fileExt == "jpeg") {
+ fileExt = "jpg";
+ }
+ let fileExtUpper = fileExt.toUpperCase();
+ let arrayNameJoined = arrayName.join('.');
+ filesToPrint = "
";
+ filesListSecondChild.innerHTML += filesToPrint;
+ datapath = arrayNameJoined;
+ getInfoFilesSecondSearch();
+ })
+}
+
+function printFoldersSearchTrash(arrayFolders) {
+ let filesToPrint;
+ arrayFolders.forEach(function (element) {
+ let newName = element.slice(9);
+ let arrayName = newName.split("/");
+ let folderName = arrayName[arrayName.length - 1];
+ let arrayNameJoined = arrayName.join("/") + "/";
+ filesToPrint = "
" + folderName + "";
+ filesListSecondChild.innerHTML += filesToPrint;
+ datapath = arrayNameJoined;
+ getInfoFilesSecondSearch();
+ })
+}
+
+function getInfoFilesSecondSearch() {
+ let dataPathWithoutSlash = dataPath.substring(0, dataPath.length - 1);
+ fetch("modules/fileInfo.php" + "?" + "path=" + dataPathWithoutSlash, {
+ method: "GET",
+ })
+ .then((response) => response.json())
+ .then((data) => {
+ if (data != "Error in opening file") {
+ let sizeOnly = renderDataSecondListSearchSize(data);
+ let modificationOnlyFile = renderDataSecondListSearchModification(data);
+ sizeListSecondChild.innerHTML += sizeOnly;
+ modificationListSecondChild.innerHTML += modificationOnlyFile;
+ }
+ })
+ .catch((err) => console.log("Request failed: ", err));
+}
+
+function renderDataSecondListSearchSize(data) {
+ if (data["size"] > 1000) {
+ sizeInfo.innerHTML = "Size: " + Math.round(data["size"] / 1024) + "Mb";
+ let sizeOnlyVar = Math.round(data["size"] / 1024) + "Mb";
+ return sizeOnly = "
" + sizeOnlyVar + "
";
+ } else {
+ sizeInfo.innerHTML = "Size: " + data["size"] + "Kb";
+ let sizeOnlyVar = data["size"] + "Kb";
+ return sizeOnly = "
" + sizeOnlyVar + "
";
+ }
+}
+
+function renderDataSecondListSearchModification(data) {
+ return modificationOnlyFile = "
" + data["modificationDate"] + "
";
+}
+
+function showImagesMedia() {
+ pathSecondFolderTitle.textContent = "";
+ sizeListSecondChild.innerHTML = "";
+ modificationListSecondChild.innerHTML = "";
+ filesListSecondChild.innerHTML = "";
+ let arrayImageFormats = ["jpg", "jpeg", "svg", "png"];
+ arrayImageFormats.forEach(function (element) {
+ searchInput.value = element;
+ if (lastList != "") {
+ lastList.style.backgroundColor = "#D9D9D9";
+ }
+ searchValue = searchInput.value;
+ if (searchValue != "") {
+ fetch("modules/searchRecursive.php" + "?" + "search=" + searchValue, {
+ method: "GET",
+ })
+ .then((response) => response.json())
+ .then((data) => {
+ if ("ok" in data) {
+ let arrayFiles = data.files;
+ let arrayFolders = data.folders;
+ let arrayFilesTrash = data.filesTrash;
+ let arrayFoldersTrash = data.foldersTrash;
+ printFilesSearch(arrayFiles);
+ printFoldersSearch(arrayFolders);
+ printFilesSearchTrash(arrayFilesTrash);
+ printFoldersSearchTrash(arrayFoldersTrash);
+ } else {
+ console.log("Something went wrong");
+ }
+ })
+ .catch((err) => console.log("Request failed: ", err));
+ }
+ })
+ searchInput.value = "";
+}
+
+function showVideosMedia() {
+ pathSecondFolderTitle.textContent = "";
+ sizeListSecondChild.innerHTML = "";
+ modificationListSecondChild.innerHTML = "";
+ filesListSecondChild.innerHTML = "";
+ let arrayVideoFormats = ["mp4"];
+ arrayVideoFormats.forEach(function (element) {
+ searchInput.value = element;
+ if (lastList != "") {
+ lastList.style.backgroundColor = "#D9D9D9";
+ }
+ searchValue = searchInput.value;
+ if (searchValue != "") {
+ fetch("modules/searchRecursive.php" + "?" + "search=" + searchValue, {
+ method: "GET",
+ })
+ .then((response) => response.json())
+ .then((data) => {
+ if ("ok" in data) {
+ let arrayFiles = data.files;
+ let arrayFolders = data.folders;
+ let arrayFilesTrash = data.filesTrash;
+ let arrayFoldersTrash = data.foldersTrash;
+ printFilesSearch(arrayFiles);
+ printFoldersSearch(arrayFolders);
+ printFilesSearchTrash(arrayFilesTrash);
+ printFoldersSearchTrash(arrayFoldersTrash);
+ } else {
+ console.log("Something went wrong");
+ }
+ })
+ .catch((err) => console.log("Request failed: ", err));
+ }
+ })
+ searchInput.value = "";
+}
+
+function showAudiosMedia() {
+ let arrayAudioFormats = ["mp3"];
+ pathSecondFolderTitle.textContent = "";
+ sizeListSecondChild.innerHTML = "";
+ modificationListSecondChild.innerHTML = "";
+ filesListSecondChild.innerHTML = "";
+ arrayAudioFormats.forEach(function (element) {
+ searchInput.value = element;
+ if (lastList != "") {
+ lastList.style.backgroundColor = "#D9D9D9";
+ }
+ searchValue = searchInput.value;
+ if (searchValue != "") {
+ fetch("modules/searchRecursive.php" + "?" + "search=" + searchValue, {
+ method: "GET",
+ })
+ .then((response) => response.json())
+ .then((data) => {
+ if ("ok" in data) {
+ let arrayFiles = data.files;
+ let arrayFolders = data.folders;
+ let arrayFilesTrash = data.filesTrash;
+ let arrayFoldersTrash = data.foldersTrash;
+ printFilesSearch(arrayFiles);
+ printFoldersSearch(arrayFolders);
+ printFilesSearchTrash(arrayFilesTrash);
+ printFoldersSearchTrash(arrayFoldersTrash);
+ } else {
+ console.log("Something went wrong");
+ }
+ })
+ .catch((err) => console.log("Request failed: ", err));
+ }
+ })
+ searchInput.value = "";
+}
+
+function showDocumentsMedia() {
+ let arrayVideoFormats = ["doc", "csv", "txt", "odt", "pdf"];
+ pathSecondFolderTitle.textContent = "";
+ sizeListSecondChild.innerHTML = "";
+ modificationListSecondChild.innerHTML = "";
+ filesListSecondChild.innerHTML = "";
+ arrayVideoFormats.forEach(function (element) {
+ searchInput.value = element;
+ if (lastList != "") {
+ lastList.style.backgroundColor = "#D9D9D9";
+ }
+ searchValue = searchInput.value;
+ if (searchValue != "") {
+ fetch("modules/searchRecursive.php" + "?" + "search=" + searchValue, {
+ method: "GET",
+ })
+ .then((response) => response.json())
+ .then((data) => {
+ if ("ok" in data) {
+ let arrayFiles = data.files;
+ let arrayFolders = data.folders;
+ let arrayFilesTrash = data.filesTrash;
+ let arrayFoldersTrash = data.foldersTrash;
+ printFilesSearch(arrayFiles);
+ printFoldersSearch(arrayFolders);
+ printFilesSearchTrash(arrayFilesTrash);
+ printFoldersSearchTrash(arrayFoldersTrash);
+ } else {
+ console.log("Something went wrong");
+ }
+ })
+ .catch((err) => console.log("Request failed: ", err));
+ }
+ })
+ searchInput.value = "";
+}
\ No newline at end of file
diff --git a/js/selectElement.js b/js/selectElement.js
new file mode 100755
index 00000000..52d05446
--- /dev/null
+++ b/js/selectElement.js
@@ -0,0 +1,359 @@
+const modificationListSecondChild = document.querySelector("#modificationListSecondChild");
+const pathSecondFolderTitle = document.querySelector("#pathSecondFolderTitle");
+const folderFilesContainer = document.querySelector("#folderFilesContainer");
+const filesListSecondChild = document.querySelector("#filesListSecondChild");
+const sizeListSecondChild = document.querySelector("#sizeListSecondChild");
+const extensioinInfo = document.getElementById("extensioinInfo");
+const creationInfo = document.getElementById("creationInfo");
+const modifiedInfo = document.getElementById("modifiedInfo");
+const arrowLeft = document.querySelector("#arrowLeft");
+const sizeInfo = document.getElementById("sizeInfo");
+const pathInfo = document.getElementById("pathInfo");
+const deleteFile = document.querySelector("#deleteFile");
+const folderTrash = document.querySelector("#folderTrash");
+let dataPath = "";
+let firstList = "";
+let secondList = "";
+let lastList = "";
+let firstListOld = "";
+let secondListOld = "";
+let oldDataPath = "a";
+let modificationOnlyFile;
+let selectedElement;
+let typeDocument;
+let counter = 0;
+let sizeOnly;
+
+
+folderFilesContainer.addEventListener("click", selectSecondElement);
+folderFilesContainer.addEventListener("dblclick", selectElementSecond);
+arrowLeft.addEventListener("click", goBackDirectory);
+ul.addEventListener("click", getTextValueAndPadre);
+ul.addEventListener("click", selectElementFirst);
+ul.addEventListener("click", showOnlyFile);
+
+function putOffSelectElementColorFirst() {
+ if (firstListOld != "") {
+ if (firstListOld.style.backgroundColor === "yellow" && firstListOld !== firstList) {
+ firstListOld.style.backgroundColor = "#D9D9D9";
+ }
+ }
+}
+
+function putOffSelectElementColorSecond() {
+ if (secondListOld.style.backgroundColor === "yellow" && secondListOld !== secondList) {
+ secondListOld.style.backgroundColor = "#D9D9D9";
+ }
+}
+
+function selectElementFirst(event) {
+ let parentNode = event.target.parentNode;
+ let currentNode = event.target;
+ firstListOld = firstList;
+ oldDataPath = dataPath;
+ if (parentNode.classList.contains("first-list")) {
+ firstList = parentNode;
+ firstList.style.backgroundColor = "yellow";
+ dataPath = parentNode.getAttribute('data-path');
+ typeDocument = parentNode.getAttribute('type');
+ selectedElement = parentNode;
+ if (oldDataPath != dataPath) {
+ printFolderTitleName(parentNode);
+ }
+ deleteFile.addEventListener("click", moveFilesTrash);
+ } else if (currentNode.classList.contains("first-list")) {
+ firstList = currentNode;
+ firstList.style.backgroundColor = "yellow";
+ dataPath = currentNode.getAttribute('data-path');
+ typeDocument = parentNode.getAttribute('type');
+ parentNode = currentNode;
+ if (oldDataPath != dataPath) {
+ printFolderTitleName(currentNode);
+ }
+ deleteFile.addEventListener("click", moveFilesTrash);
+ }
+ if (typeDocument == "folder") {
+ if (oldDataPath != dataPath) {
+ sizeListSecondChild.innerHTML = "";
+ modificationListSecondChild.innerHTML = "";
+ printFilesSecondChild();
+ }
+ } else if (typeDocument == "file") {
+ showPreview();
+ }
+ if (firstListOld != "") {
+ window.addEventListener("click", putOffSelectElementColorFirst);
+ }
+ levelDirectory = (dataPath.match(/\//g) || []).length;
+ lastList = firstList;
+}
+
+function selectElementSecond(event) {
+ oneClick = false;
+ let parentNode = event.target.parentNode;
+ let currentNode = event.target;
+ firstListOld = firstList;
+ oldDataPath = dataPath;
+ if (parentNode.classList.contains("first-list")) {
+ firstList = parentNode;
+ firstList.style.backgroundColor = "yellow";
+ dataPath = parentNode.getAttribute('data-path');
+ typeDocument = parentNode.getAttribute('type');
+ selectedElement = parentNode;
+ console.log({typeDocument})
+ console.log({firstList})
+ printFolderTitleName(parentNode);
+ deleteFile.addEventListener("click", moveFilesTrash);
+ } else if (currentNode.classList.contains("first-list")) {
+ firstList = currentNode;
+ firstList.style.backgroundColor = "yellow";
+ dataPath = currentNode.getAttribute('data-path');
+ typeDocument = parentNode.getAttribute('type');
+ parentNode = currentNode;
+ console.log({typeDocument})
+ console.log({firstList})
+ printFolderTitleName(currentNode);
+ deleteFile.addEventListener("click", moveFilesTrash);
+ }
+ if (typeDocument == "folder") {
+ sizeListSecondChild.innerHTML = "";
+ modificationListSecondChild.innerHTML = "";
+ printFilesSecondChild();
+ } else if (typeDocument == "file") {
+ showMedia();
+ }
+ if (firstListOld != "") {
+ window.addEventListener("click", putOffSelectElementColorFirst);
+ }
+
+ levelDirectory = (dataPath.match(/\//g) || []).length;
+}
+
+function showOnlyFile(event) {
+ let parentNode = event.target.parentNode;
+ let currentNode = event.target;
+ if (parentNode.classList.contains("first-list")) {
+ typeDocument = parentNode.getAttribute('type');
+ } else if (currentNode.classList.contains("first-list")) {
+ typeDocument = parentNode.getAttribute('type');
+ }
+ if (typeDocument == "file") {
+ let dataPathWithoutSlash = dataPath.substring(0, dataPath.length - 1);
+ let arrayDataPath = dataPathWithoutSlash.split(".");
+ let dataPathExt = arrayDataPath.slice(-1)[0];
+ arrayDataPath.pop();
+ if (dataPathExt == "jpeg") {
+ dataPathExt = "jpg";
+ }
+ dataPathExt = dataPathExt.toUpperCase();
+ let arrayDataPathJoined = arrayDataPath.join('.');
+ filesListSecondChild.innerHTML = "
" + arrayDataPathJoined + "" + dataPathExt + "";
+ counter = 1;
+ showPreview();
+ }
+}
+
+function selectSecondElement(event) {
+ oneClick = true;
+ let parentNode = event.target.parentNode;
+ let currentNode = event.target;
+ secondListOld = secondList;
+ if (parentNode.classList.contains("first-list")) {
+ secondList = parentNode;
+ secondList.style.backgroundColor = "yellow";
+ dataPath = parentNode.getAttribute('data-path');
+ deleteFile.addEventListener("click", moveFilesTrash);
+ printFolderTitleName(parentNode);
+ } else if (currentNode.classList.contains("first-list")) {
+ secondList = currentNode;
+ secondList.style.backgroundColor = "yellow";
+ dataPath = currentNode.getAttribute('data-path');
+ deleteFile.addEventListener("click", moveFilesTrash);
+ printFolderTitleName(currentNode);
+ }else if (currentNode.classList.contains("trash-list")) {
+ secondList = currentNode;
+ secondList.style.backgroundColor = "yellow";
+ dataPath = currentNode.getAttribute('data-path');
+ deleteFile.addEventListener("click", moveFilesTrash);
+ printFolderTitleNameTrash(currentNode);
+ }else if ((parentNode.classList.contains("trash-list"))){
+ secondList = parentNode;
+ secondList.style.backgroundColor = "yellow";
+ dataPath = parentNode.getAttribute('data-path');
+ deleteFile.addEventListener("click", moveFilesTrash);
+ printFolderTitleNameTrash(parentNode);
+ }
+ if (secondListOld != "") {
+ window.addEventListener("click", putOffSelectElementColorSecond);
+ }
+
+ if (typeDocument == "folder") {
+ hidePreview();
+ }
+
+ lastList = secondList;
+
+ showPreview();
+ getInfoFilesCorner();
+ levelDirectory = (dataPath.match(/\//g) || []).length;
+}
+
+function getTextValueAndPadre(event) {
+ let parentNode = event.target.parentNode;
+ let currentNode = event.target;
+ let secondChild = event.target.lastChild;
+ let nextChild = event.target.nextElementSibling;
+ if (parentNode.classList.contains("text-list")) {
+ textValue = parentNode;
+ padre = textValue.parentNode;
+ } else if (currentNode.classList.contains("text-list")) {
+ textValue = currentNode;
+ padre = textValue.parentNode;
+ } else if (secondChild.classList.contains("text-list")) {
+ textValue = secondChild;
+ padre = textValue.parentNode;
+ } else if (nextChild.classList.contains("text-list")) {
+ textValue = nextChild;
+ padre = textValue.parentNode;
+ }
+}
+
+function printFolderTitleName(selectedElement) {
+ getInfoFilesCorner();
+ getInfoFilesSecond();
+ if (selectedElement.getAttribute('type') === "folder") {
+ pathSecondFolderTitle.textContent = "files/" + dataPath;
+ } else {
+ let dataPathWithoutSlash = dataPath.substring(0, dataPath.length - 1);
+ pathSecondFolderTitle.textContent = "files/" + dataPathWithoutSlash;
+ }
+}
+
+function printFilesSecondChild() {
+ let dataPathWithoutSlash = dataPath.substring(0, dataPath.length - 1);
+ filesListSecondChild.innerHTML = "";
+ fetch("modules/printFilesSecondChild.php" + "?" + "dataPathSecond=" + dataPathWithoutSlash, {
+ method: "GET",
+ })
+ .then((response) => response.json())
+ .then((data) => {
+ data.forEach(element =>
+ filesListSecondChild.innerHTML += element);
+ })
+ .catch((err) => console.log("Request failed: ", err));
+}
+
+function getInfoFilesCorner() {
+ let dataPathWithoutSlash = dataPath.substring(0, dataPath.length - 1);
+ fetch("modules/fileInfo.php" + "?" + "path=" + dataPathWithoutSlash, {
+ method: "GET",
+ })
+ .then((response) => response.json())
+ .then((data) => {
+ console.log(data)
+ renderFileInfoCorner(data);
+ })
+ .catch((err) => console.log("Request failed: ", err));
+}
+
+function getInfoFilesSecond() {
+ let dataPathWithoutSlash = dataPath.substring(0, dataPath.length - 1);
+ fetch("modules/fileInfo.php" + "?" + "path=" + dataPathWithoutSlash, {
+ method: "GET",
+ })
+ .then((response) => response.json())
+ .then((data) => {
+ if (data != "Error in opening file") {
+ renderFileInfoSecond(data);
+ }
+ })
+ .catch((err) => console.log("Request failed: ", err));
+}
+
+function renderFileInfoCorner(data) {
+ if (data["size"] > 1000) {
+ sizeInfo.innerHTML = "Size: " + Math.round(data["size"] / 1024) + "Mb";
+ let sizeOnlyVar = Math.round(data["size"] / 1024) + "Mb";
+ sizeOnly = "
" + sizeOnlyVar + "
";
+ } else {
+ sizeInfo.innerHTML = "Size: " + data["size"] + "Kb";
+ let sizeOnlyVar = data["size"] + "Kb";
+ sizeOnly = "
" + sizeOnlyVar + "
";
+ }
+ creationInfo.innerHTML = "Creation date: " + data["creationDate"];
+ modifiedInfo.innerHTML = "Last modificaton: " + data["modificationDate"];
+ if (dataPath.includes(".")) {
+ let dataPathWithoutSlash = dataPath.substring(0, dataPath.length - 1);
+ pathInfo.innerHTML = "Path: " + "files/" + dataPathWithoutSlash;
+ } else {
+ pathInfo.innerHTML = "Path: " + "files/" + dataPath;
+ }
+ extensioinInfo.innerHTML = "Extension: " + data["extension"];
+ modificationOnlyFile = "
" + data["modificationDate"] + "
";
+ if (counter == 1) {
+ sizeListSecondChild.innerHTML = sizeOnly;
+ modificationListSecondChild.innerHTML = modificationOnlyFile;
+ counter = 0;
+ }
+}
+
+function renderFileInfoSecond(data) {
+ if (dataPath != "") {
+ let dataLength = Object.keys(data).length;
+ for (let i = 0; i < dataLength; i++) {
+ if ("size" + `${i}` in data) {
+ let sizeVariable = "size" + i;
+ let modificationVariable = "modificationDate" + i;
+ let foundSize = data[sizeVariable];
+ let foundModificationDate = data[modificationVariable];
+ if (foundSize > 1000) {
+ foundSize = Math.round(foundSize / 1024) + "Mb";
+ } else {
+ foundSize = foundSize + "Kb";
+ }
+ sizeListSecondChild.innerHTML += "
" + foundSize + "
";
+ modificationListSecondChild.innerHTML += "
" + foundModificationDate + "
";
+ }
+ }
+ }
+ /* fileContent.innerHTML = "Content: " + data["content"]; */
+}
+
+function goBackDirectory() {
+ if(pathSecondFolderTitle.textContent.includes("trash/")){
+ sizeListSecondChild.innerHTML = "";
+ modificationListSecondChild.innerHTML = "";
+ dataPath = dataPath.split("/");
+ dataPath.pop();
+ dataPath.pop();
+ dataPath = dataPath.join("/");
+ dataPath = dataPath + "/";
+ if (dataPath == "/") {
+ dataPath = "";
+ } else {
+ printFilesTrash();
+ }
+ getInfoFilesCornerTrash();
+ getInfoFilesSecondTrash();
+ pathSecondFolderTitle.textContent = "trash/" + dataPath;
+ }
+ if(pathSecondFolderTitle.textContent.includes("files/")){
+ sizeListSecondChild.innerHTML = "";
+ modificationListSecondChild.innerHTML = "";
+ dataPath = dataPath.split("/");
+ dataPath.pop();
+ dataPath.pop();
+ dataPath = dataPath.join("/");
+ dataPath = dataPath + "/";
+ if (dataPath == "/") {
+ dataPath = "";
+ filesListSecondChild.innerHTML = "";
+ } else {
+ printFilesSecondChild();
+ }
+ getInfoFilesCorner();
+ getInfoFilesSecond();
+ pathSecondFolderTitle.textContent = "files/" + dataPath;
+ }
+
+}
\ No newline at end of file
diff --git a/js/showMedia.js b/js/showMedia.js
new file mode 100755
index 00000000..d97df3e8
--- /dev/null
+++ b/js/showMedia.js
@@ -0,0 +1,89 @@
+const showMediaContainer = document.querySelector("#showMediaContainer");
+const showMediaChild = document.querySelector("#showMediaChild");
+const previewChild = document.querySelector("#previewChild");
+let xIcon;
+
+function showMedia() {
+ previewChild.style.display = "none";
+ previewChild.innerHTML = "";
+ let dataPathWithoutSlash = dataPath.substring(0, dataPath.length - 1);
+ if (dataPath.includes(".mp4")) {
+ showMediaContainer.style.display = "flex";
+ showMediaChild.innerHTML = "

";
+ } else if (dataPath.includes(".mp3")) {
+ showMediaContainer.style.display = "flex";
+ showMediaChild.innerHTML = "

";
+ } else if (dataPath.includes(".jpg") || dataPath.includes(".jpeg")) {
+ showMediaContainer.style.display = "flex";
+ showMediaChild.innerHTML = "


";
+ } else if (dataPath.includes(".png")) {
+ showMediaContainer.style.display = "flex";
+ showMediaChild.innerHTML = "


";
+ } else if (dataPath.includes(".svg")) {
+ showMediaContainer.style.display = "flex";
+ showMediaChild.innerHTML = "


";
+ } else if (dataPath.includes(".pdf")) {
+ showMediaContainer.style.display = "flex";
+ showMediaChild.innerHTML = "

";
+ }
+ xIcon = document.querySelector("#xIcon");
+ xIcon.addEventListener("click", hideMedia);
+ window.addEventListener('click', clickOutside);
+}
+
+function clickOutside(e) {
+ if (!document.getElementById('showMediaChild').contains(e.target)) {
+ hideMedia();
+ }
+}
+
+function hideMedia() {
+ showMediaContainer.style.display = "none";
+ showMediaChild.innerHTML = "";
+ xIcon.removeEventListener("click", hideMedia);
+ window.removeEventListener("click", clickOutside);
+}
+
+function showPreview() {
+ let dataPathWithoutSlash;
+ let slashOrNoSlash = dataPath.slice(-1)[0];
+ if (slashOrNoSlash == "/") {
+ dataPathWithoutSlash = dataPath.substring(0, dataPath.length - 1);
+ } else {
+ dataPathWithoutSlash = dataPath;
+ }
+ if (dataPath.includes(".mp4")) {
+ setPreview();
+ previewChild.innerHTML = "
";
+ } else if (dataPath.includes(".mp3")) {
+ setPreview();
+ previewChild.innerHTML = "
";
+ } else if (dataPath.includes(".jpg") || dataPath.includes(".jpeg")) {
+ setPreview();
+ previewChild.innerHTML = "

";
+ } else if (dataPath.includes(".png")) {
+ setPreview();
+ previewChild.innerHTML = "

";
+ } else if (dataPath.includes(".svg")) {
+ setPreview();
+ previewChild.innerHTML = "

";
+ } else if (dataPath.includes(".pdf")) {
+ setPreview();
+ previewChild.innerHTML = "
";
+ }
+}
+
+function setPreview() {
+ previewText.style.display = "none";
+ previewChild.style.display = "flex";
+ ul.addEventListener("click", hidePreview);
+}
+
+function hidePreview() {
+ if (typeDocument == "folder") {
+ previewChild.innerHTML = "";
+ previewChild.style.display = "none";
+ previewText.style.display = "block";
+ ul.removeEventListener("click", hidePreview);
+ }
+}
\ No newline at end of file
diff --git a/js/trash.js b/js/trash.js
new file mode 100755
index 00000000..98ce8d5e
--- /dev/null
+++ b/js/trash.js
@@ -0,0 +1,160 @@
+let oneClick = false;
+folderTrash.addEventListener("click", printFilesTrash);
+
+
+function cleanTrash() {
+ let dataPathWithoutSlash = dataPath.substring(0, dataPath.length - 1);
+ fetch("modules/cleanTrash.php" + "?" + "dataPathSecond=" + dataPathWithoutSlash, {
+ method: "GET",
+ })
+ .then((response) => response.json())
+ .then((data) => printFilesTrash())
+ .catch((err) => console.log("Request failed: ", err));
+}
+
+function printFilesTrash() {
+ filesListSecondChild.textContent = "";
+ modificationListSecondChild.textContent = "";
+ sizeListSecondChild.textContent = "";
+ dataPath = "";
+ if (firstList !== "") {
+ firstList.style.backgroundColor = "#D9D9D9";
+ printFolderTitleNameTrash();
+ } else {
+ pathSecondFolderTitle.textContent = "trash/";
+ printFolderTitleNameTrash();
+ }
+ let dataPathWithoutSlash = dataPath.substring(0, dataPath.length - 1);
+ fetch("modules/printFilesTrash.php" + "?" + "dataPathSecond=" + dataPathWithoutSlash, {
+ method: "GET",
+ })
+ .then((response) => response.json())
+ .then((data) => {
+ data.forEach(element =>
+ filesListSecondChild.innerHTML += element);
+ })
+ .catch((err) => console.log("Request failed: ", err));
+}
+
+function printFolderTitleNameTrash() {
+ pathSecondFolderTitle.textContent = "trash/" + dataPath;
+ if (oneClick !== true) {
+ sizeListSecondChild.innerHTML = "";
+ modificationListSecondChild.innerHTML = "";
+ getInfoFilesSecondTrash();
+ getInfoFilesCornerTrash();
+
+ }
+
+
+}
+
+function getInfoFilesCornerTrash() {
+ let dataPathWithoutSlash = "";
+ if (dataPath !== "") {
+ dataPathWithoutSlash = dataPath.substring(0, dataPath.length - 1);
+
+ }
+
+ fetch("modules/fileInfoTrash.php" + "?" + "path=" + dataPathWithoutSlash, {
+ method: "GET",
+ })
+ .then((response) => response.json())
+ .then((data) => {
+ console.log(data)
+ renderFileInfoCornerTrash(data);
+ })
+ .catch((err) => console.log("Request failed: ", err));
+}
+
+function getInfoFilesSecondTrash() {
+ let dataPathWithoutSlash = "";
+ if (dataPath !== "") {
+ dataPathWithoutSlash = dataPath.substring(0, dataPath.length - 1);
+ }
+
+ fetch("modules/fileInfoTrash.php" + "?" + "path=" + dataPathWithoutSlash, {
+ method: "GET",
+ })
+ .then((response) => response.json())
+ .then((data) => {
+ console.log(data);
+ if (data != "Error in opening file") {
+ renderFileInfoSecondTrash(data);
+ }
+ })
+ .catch((err) => console.log("Request failed: ", err));
+}
+
+function renderFileInfoCornerTrash(data) {
+ if (data["size"] > 1000) {
+ sizeInfo.innerHTML = "Size: " + Math.round(data["size"] / 1024) + "Mb";
+ let sizeOnlyVar = Math.round(data["size"] / 1024) + "Mb";
+ sizeOnly = "
" + sizeOnlyVar + "
";
+ } else {
+ sizeInfo.innerHTML = "Size: " + data["size"] + "Kb";
+ let sizeOnlyVar = data["size"] + "Kb";
+ sizeOnly = "
" + sizeOnlyVar + "
";
+ }
+ creationInfo.innerHTML = "Creation date: " + data["creationDate"];
+ modifiedInfo.innerHTML = "Last modificaton: " + data["modificationDate"];
+ if (dataPath.includes(".")) {
+ let dataPathWithoutSlash = dataPath.substring(0, dataPath.length - 1);
+ pathInfo.innerHTML = "Path: " + "trash/" + dataPathWithoutSlash;
+ } else {
+ pathInfo.innerHTML = "Path: " + "trash/" + dataPath;
+ }
+ extensioinInfo.innerHTML = "Extension: " + data["extension"];
+ modificationOnly = "
" + data["modificationDate"] + "
";
+ if (counter == 1) {
+ sizeListSecondChild.innerHTML = sizeOnly;
+ modificationListSecondChild.innerHTML = modificationOnly;
+ counter = 0;
+ }
+}
+
+function renderFileInfoSecondTrash(data) {
+
+ let dataLength = Object.keys(data).length;
+ for (let i = 0; i < dataLength; i++) {
+ if ("size" + `${i}` in data) {
+ let sizeVariable = "size" + i;
+ let modificationVariable = "modificationDate" + i;
+ let foundSize = data[sizeVariable];
+ let foundModificationDate = data[modificationVariable];
+ if (foundSize > 1000) {
+ foundSize = Math.round(foundSize / 1024) + "Mb";
+ } else {
+ foundSize = foundSize + "Kb";
+ }
+ sizeListSecondChild.innerHTML += "
" + foundSize + "
";
+ modificationListSecondChild.innerHTML += "
" + foundModificationDate + "

";
+ const trashSecondListImg = document.querySelectorAll(".trash-second-list-img");
+ for (let i = 0; i < trashSecondListImg.length; i++) {
+ trashSecondListImg[i].addEventListener("click", cleanTrash);
+ }
+
+
+
+
+ }
+ }
+
+ /* fileContent.innerHTML = "Content: " + data["content"]; */
+}
+
+
+function moveFilesTrash() {
+ deleteFile.removeEventListener("click", moveFilesTrash);
+ let dataPathWithoutSlash = dataPath.substring(0, dataPath.length - 1);
+ fetch("modules/moveFilesTrash.php" + "?" + "dataPath=" + dataPathWithoutSlash, {
+ method: "GET",
+ })
+ .then((response) => response.json())
+ .then((data) => {
+ console.log(data)
+ console.log(lastList);
+ lastList.remove();
+ })
+ .catch((err) => console.log("Request failed: ", err));
+}
\ No newline at end of file
diff --git a/js/uploadFile.js b/js/uploadFile.js
new file mode 100755
index 00000000..11bd8470
--- /dev/null
+++ b/js/uploadFile.js
@@ -0,0 +1,69 @@
+const uploadFile = document.querySelector("#uploadFile");
+const inputUploadFile = document.querySelector("#inputUploadFile");
+
+uploadFile.addEventListener("click", uploadFileFunction);
+inputUploadFile.addEventListener('change', () => {
+ uploadFunction(inputUploadFile.files[0]);
+});
+
+function uploadFileFunction() {
+ inputUploadFile.click();
+}
+
+function uploadFunction(file){
+ let formData = new FormData();
+ formData.append("inputUploadFile", file);
+ fetch('modules/uploadFiles.php?dataPath=' + dataPath, {
+ method: "POST",
+ body: formData
+ }).then((response) => response.json())
+ .then((data) => {
+ console.log(data)
+ data.forEach(element =>
+ console.log(element));
+ if(dataPath!=""){
+ printFilesSecondChild();
+ } else {
+ appendUploadedFile(data);
+ }
+ })
+ .catch((err) => console.log("Request failed: ", err));
+}
+
+function appendUploadedFile(data){
+ if (data[2]=="jpeg"){
+ data[2]="jpg";
+ }
+ li = document.createElement("li");
+ li.setAttribute("class", "first-list");
+ li.setAttribute("data-path", data[1]+"/");
+ li.setAttribute("type", "file");
+ const img = document.createElement("img");
+ img.setAttribute("src", "images/"+data[2]+"Icon.png");
+ img.setAttribute("alt", "file");
+ img.classList.add("folder-list-img");
+ const span = document.createElement("span");
+ span.classList.add("text-list");
+ span.textContent = data[1];
+ li.appendChild(img);
+ li.appendChild(span);
+ filesList.appendChild(li);
+}
+
+/* function submitFunction() {
+ let photo = inputUploadFile.files[0];
+ let name = inputUploadFile.value;
+ console.log(photo)
+ console.log(name)
+ let formData = new FormData();
+ formData.append("inputUploadFile", photo);
+ console.log(formData)
+ fetch('modules/uploadFiles.php?dataPath=' + dataPath, {
+ method: "POST",
+ body: formData
+ }).then((response) => response.json())
+ .then((data) => {
+ console.log(data);
+ })
+ .catch((err) => console.log("Request failed: ", err));
+} */
\ No newline at end of file
diff --git a/modules/checkDirectoryName.php b/modules/checkDirectoryName.php
new file mode 100755
index 00000000..e0500cb9
--- /dev/null
+++ b/modules/checkDirectoryName.php
@@ -0,0 +1,8 @@
+true]);
+ } else {
+ unlink($dir);
+ echo json_encode(["ok"=>true]);
+ }
+
+}
+
+// foreach ($files as $file) {
+// if(is_file(($file))){
+// unlink($file);
+// }
+// }
\ No newline at end of file
diff --git a/modules/createFolder.php b/modules/createFolder.php
new file mode 100755
index 00000000..e1f4d29a
--- /dev/null
+++ b/modules/createFolder.php
@@ -0,0 +1,10 @@
+ 0,
+ "creationDate" => "",
+ "modificationDate" => "",
+ "extension" => "",
+ "name" => ""
+];
+
+// if ($file == false) {
+// echo json_encode ("Error in opening file");
+// exit();
+// }
+
+$fileInfo["size"] = filesize($filename);
+$fileInfo["creationDate"] = date("Y/m/d H:i:s", filectime($filename));
+$fileInfo["modificationDate"] = date("Y/m/d H:i:s", filemtime($filename));
+$fileInfo["extension"] = pathinfo($filename, PATHINFO_EXTENSION);
+if($fileInfo["extension"] == ""){
+ $fileInfo["extension"] = "folder";
+}
+$fileInfo["name"] = $filename;
+
+// fclose($file);
+
+if(is_dir($filename)){
+ $openedFolder = opendir($filename);
+ $numberOfFiles = 0;
+
+ while (false !== ($readFolder = readdir($openedFolder))) {
+
+ if ($readFolder != "." && $readFolder != "..") {
+
+ // $file = fopen($filename."/".$readFolder, "r");
+ // if ($file == false) {
+ // echo json_encode ("Error in opening file");
+ // exit();
+ // }
+
+ $fileInfo["size".$numberOfFiles] = filesize($filename."/".$readFolder);
+ $fileInfo["modificationDate".$numberOfFiles] = date("Y/m/d H:i:s", filemtime($filename."/".$readFolder));
+ $numberOfFiles += 1;
+ // fclose($file);
+ }
+ }
+ closedir($openedFolder);
+}
+
+echo json_encode($fileInfo);
diff --git a/modules/fileInfoTrash.php b/modules/fileInfoTrash.php
new file mode 100755
index 00000000..63c8854a
--- /dev/null
+++ b/modules/fileInfoTrash.php
@@ -0,0 +1,61 @@
+ 0,
+ "creationDate" => "",
+ "modificationDate" => "",
+ "extension" => "",
+ "name" => ""
+];
+
+// if ($file == false) {
+// echo json_encode ("Error in opening file");
+// exit();
+// }
+
+$fileInfo["size"] = filesize($filename);
+$fileInfo["creationDate"] = date("Y/m/d H:i:s", filectime($filename));
+$fileInfo["modificationDate"] = date("Y/m/d H:i:s", filemtime($filename));
+$fileInfo["extension"] = pathinfo($filename, PATHINFO_EXTENSION);
+if($fileInfo["extension"] == ""){
+ $fileInfo["extension"] = "folder";
+}
+$fileInfo["name"] = $filename;
+
+// fclose($file);
+
+if(is_dir($filename)){
+ $openedFolder = opendir($filename);
+ $numberOfFiles = 0;
+
+ while (false !== ($readFolder = readdir($openedFolder))) {
+
+ if ($readFolder != "." && $readFolder != "..") {
+
+ // $file = fopen($filename."/".$readFolder, "r");
+ // if ($file == false) {
+ // echo json_encode ("Error in opening file");
+ // exit();
+ // }
+
+ $fileInfo["size".$numberOfFiles] = filesize($filename."/".$readFolder);
+ $fileInfo["modificationDate".$numberOfFiles] = date("Y/m/d H:i:s", filemtime($filename."/".$readFolder));
+ $numberOfFiles += 1;
+ // fclose($file);
+ }
+ }
+ closedir($openedFolder);
+}
+
+echo json_encode($fileInfo);
diff --git a/modules/moveFilesTrash.php b/modules/moveFilesTrash.php
new file mode 100755
index 00000000..e395278e
--- /dev/null
+++ b/modules/moveFilesTrash.php
@@ -0,0 +1,11 @@
+
$readFolder");
+ } else {
+ $readFolderArray = explode(".", $readFolder);
+ $readFolder = reset($readFolderArray);
+ $readFolderExt = strtoupper(end($readFolderArray));
+ if($fileActualExt==="doc"){
+ array_push($arrayPrint, "
");
+ }
+ else if($fileActualExt==="csv"){
+ array_push($arrayPrint, "
");
+ }
+ else if($fileActualExt==="jpg"){
+ array_push($arrayPrint, "
");
+ }
+ else if($fileActualExt==="jpeg"){
+ array_push($arrayPrint, "
");
+ }
+ else if($fileActualExt==="png"){
+ array_push($arrayPrint, "
");
+ }
+ else if($fileActualExt==="txt"){
+ array_push($arrayPrint, "
");
+ }
+ else if($fileActualExt==="ppt"){
+ array_push($arrayPrint, "
");
+ }
+ else if($fileActualExt==="odt"){
+ array_push($arrayPrint, "
");
+ }
+ else if($fileActualExt==="pdf"){
+ array_push($arrayPrint, "
");
+ }
+ else if($fileActualExt==="zip"){
+ array_push($arrayPrint, "
");
+ }
+ else if($fileActualExt==="rar"){
+ array_push($arrayPrint, "
");
+ }
+ else if($fileActualExt==="exe"){
+ array_push($arrayPrint, "
");
+ }
+ else if($fileActualExt==="svg"){
+ array_push($arrayPrint, "
");
+ }
+ else if($fileActualExt==="mp3"){
+ array_push($arrayPrint, "
");
+ }
+ else if($fileActualExt==="mp4"){
+ array_push($arrayPrint, "
");
+ }
+ }
+ }
+ }
+ echo json_encode($arrayPrint);
+ closedir($openedFolder);
+} else {
+ echo json_encode("The directory does not exist");
+}
+
+?>
\ No newline at end of file
diff --git a/modules/printFilesFirstChild.php b/modules/printFilesFirstChild.php
new file mode 100755
index 00000000..e7329d40
--- /dev/null
+++ b/modules/printFilesFirstChild.php
@@ -0,0 +1,65 @@
+
";
+ }
+ } else if($fileActualExt==="doc"){
+ echo "
";
+ }
+ }
+ }
+
+ closedir($openedFolder);
+}
+
+/* function dir_is_empty($dir) {
+ $handle = opendir($dir);
+ while (false !== ($entry = readdir($handle))) {
+ if ($entry != "." && $entry != "..") {
+ closedir($handle);
+ return false;
+ }
+ }
+ closedir($handle);
+ return true;
+} */
+
+
+?>
\ No newline at end of file
diff --git a/modules/printFilesSecondChild.php b/modules/printFilesSecondChild.php
new file mode 100755
index 00000000..0e111428
--- /dev/null
+++ b/modules/printFilesSecondChild.php
@@ -0,0 +1,76 @@
+