diff --git a/.DS_Store b/.DS_Store new file mode 100755 index 00000000..34696fd4 Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..6a9d8fb5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +files/* +trash/* +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/css/style.css b/css/style.css new file mode 100755 index 00000000..be1441d6 --- /dev/null +++ b/css/style.css @@ -0,0 +1,395 @@ +html { + margin: 0; + padding: 0; + background-color: rgb(255, 255, 255); +} + +body { + margin: 0; + padding: 0; +} + +#navBar { + height: 100%; + padding: 1% 3%; + /* border-bottom: 2px solid black; */ + background-color: 838383; + display: flex; + justify-content: space-between; +} + +#companyLogo { + line-height: 4vw; + height: 3rem; + width: 3.5rem; +} + +#userLogo { + text-align: center; + line-height: 4vw; + background-color: grey; + height: 4vw; + width: 4vw; + border-radius: 50%; +} + +main { + padding: 0; + margin: 0; +} + +#mainContainer { + height: 100%; + display: grid; + grid-template-columns: 18vw 62vw 18vw; + grid-template-rows: 100%; + column-gap: 1vw; +} + +.main-children { + height: 89vh; + padding: 0 6%; + text-align: center; + background-color: #ABABAB; + display: flex; + flex-direction: column; + justify-content: space-evenly; +} + +#previwContainer{ + display: flex; + justify-content: center; + align-items: center; +} + +#previewChild{ + display: none; + justify-content: center; + align-items: center; +} + +#previewText{ + display: block; +} + +.thumbnail-media{ + max-width: 90%; +} + +#searchInput { + width: 80%; + text-align: center; + border: none; + margin: 0 auto; + height: 3vh; + background-color: #D9D9D9; + color: white +} + +#buttonsOptionsContainer { + display: flex; + justify-content: space-evenly; + padding: 0 5% 6% 5%; +} + +.buttons-options { + /* width: 16%; + height: 180%; */ + height: 2rem; + width: 2rem; + transition: 0.5s; +} + +.buttons-options:hover { + animation: shake 0.5s; + animation-iteration-count: infinite; +} + +.buttons-options:active { + height: 2rem; + width: 2rem; +} + +@keyframes shake { + 0% { transform: translate(1px, 1px); } + 20% { transform: translate(-3px, 0px); } + 40% { transform: translate(1px, -1px); } + 60% { transform: translate(-3px, 1px); } + 80% { transform: translate(-1px, -1px); } + 100% { transform: translate(1px, -2px); } +} + +#filesExplorerContainer { + display: grid; + grid-template-rows: 70% 30%; + padding: 5% 0; + background-color: #D9D9D9; + height: 50vh; +} + +#filesPath { + overflow-y: scroll; + overflow-x: auto; + padding: 0 5%; +} + +#filesFolderFather{ + list-style: none; + padding: 0; +} + +#filesFolder{ + text-align: left; +} + +/* .first-list{ + word-wrap: break-word; +} */ + +#mediaFolderContainer { + display: grid; + grid-template-columns: 49% 49%; + grid-template-rows: 32% 32% 32%; + gap: 2%; + padding: 5% 5% 0 5%; + /* height: 35vh; */ +} + +.media-folder-buttons { + background-color: #B6B6B6; + border: none; + color: white; +} + +.media-folder-buttons:hover{ + color: black; + background-color: white; + transition: 1s; +} + +#folderTrash { + grid-column: 1/3; + background-color: #ff8383; + border: none; + color: white; +} + +#folderTrash:hover { + background-color: #ff1515; + color: rgb(255, 255, 255); + transition: 1s; +} + +#informationFilesContainer { + background-color: #D9D9D9; + height: 20vh; + padding: 0 5%; + overflow-x: hidden; + overflow-y: auto; +} + +.information-files { + word-wrap: break-word; +} + +#informationFilesList { + list-style: none; + text-align: start; + padding: 8% 2%; + margin: 0; + font-size: 0.8rem; +} + +#secondChildrenContainer { + /* padding: 2%; */ + margin: 0; + padding: 0; + /* height: 84.4vh; */ +} + +#secondChildrenChild { + background-color: #D9D9D9; + height: 97%; + width: 98%; + margin: 0 auto; + display: flex; + flex-direction: column; +} + +#titleSecondChild { + display: grid; + grid-template-columns: 60% 20% 20%; + background-color: white; + text-align: start; + padding: 0 4%; +} + +#pathSecondChild { + display: flex; + background-color: #ada3a3; + text-align: start; + height: 7vh; + padding: 0 4%; +} + +#arrowLeft { + width: 1rem; + height: 1rem; + margin-top: 1rem; + padding: 0 1% 0 0; +} + +#folderIcon { + width: 2rem; + height: 2rem; + margin-top: 0.5rem; + padding: 0 2% 0 0; +} + +#contentSecondChild { + display: grid; + grid-template-columns: 60% 20% 20%; + text-align: start; + padding: 0 4%; + overflow-y: scroll; +} + +#previewText { + color: rgba(114, 114, 114, 0.8); + font-size: 0.8rem; +} + +#filesList { + list-style: none; + padding: 0 5% 0 10%; + margin: 0; + text-align: start; +} + +#filesListSecondChild, +#sizeListSecondChild, +#modificationListSecondChild { + display: flex; + flex-direction: column; + text-align: start; + padding: 2vh 0; + margin: 0; +} + +.second-flex { + height: 5vh; +} + +.second-info { + font-size: 0.85rem; + line-height: 5vh; +} + +.text-directory { + margin-bottom: 24px; +} + +.text-list { + padding-left: 3%; + font-size: 0.8rem; +} + +.text-second-list { + padding-left: 5%; +} + +#formUploadFile, +#inputUploadFile { + display: none; +} + +.folder-list-p { + display: inline-block; + font-size: 0.9rem; + padding-left: 5%; + margin: 0; +} + +.folder-list-img { + display: inline-block; + height: 1.2rem; +} + +.folder-second-list-img { + display: inline-block; + height: 2rem; +} + +.folder-list-input { + display: inline-block; + margin-left: 6%; + width: 60%; + font-size: 0.8rem; +} + +.extesion-file { + color: #6a6a6a; + padding-left: 3%; +} + +#showMediaContainer { + position: fixed; + top: 0; + left: 0; + width: 100vw; + height: 100vh; + align-items: center; + justify-content: center; + background-color: rgba(0, 0, 0, 0.6); + display: none; +} + +#showMediaChild{ + min-width: 50%; + min-height: 50%; + padding: 6%; + background-color: rgb(0, 0, 0); + display: flex; + align-items: center; + justify-content: center; + border-radius: 20px; + position: relative; +} + +#xIcon{ + position: absolute; + top: 2vh; + right: 2vh; + height: 3vh; +} + +#shownImage{ + width: 60%; + +} + +.search-trash{ + background-color: rgb(255, 137, 137); +} + +.arrow-rigth{ + height: 1.5vh; +} + +.container-modification{ + display: flex; + justify-content: space-around; +} +.trash-second-list-img{ + width: 20%; + height: 30%; +} + +::placeholder { + color: white; +} + +textarea:focus, +input:focus { + outline: none; +} \ No newline at end of file diff --git a/fileexplorer.pdf b/fileexplorer.pdf new file mode 100755 index 00000000..ffd1fcf4 Binary files /dev/null and b/fileexplorer.pdf differ diff --git a/files/.DS_Store b/files/.DS_Store new file mode 100755 index 00000000..5008ddfc Binary files /dev/null and b/files/.DS_Store differ diff --git a/images/.DS_Store b/images/.DS_Store new file mode 100755 index 00000000..29872622 Binary files /dev/null and b/images/.DS_Store differ diff --git a/images/addFolder.png b/images/addFolder.png new file mode 100755 index 00000000..fa88f49b Binary files /dev/null and b/images/addFolder.png differ diff --git a/images/arrowDown.png b/images/arrowDown.png new file mode 100755 index 00000000..75ceccd4 Binary files /dev/null and b/images/arrowDown.png differ diff --git a/images/arrowLeft.png b/images/arrowLeft.png new file mode 100755 index 00000000..97366f8c Binary files /dev/null and b/images/arrowLeft.png differ diff --git a/images/arrowRigth.png b/images/arrowRigth.png new file mode 100755 index 00000000..cb752ed2 Binary files /dev/null and b/images/arrowRigth.png differ diff --git a/images/csvIcon.png b/images/csvIcon.png new file mode 100755 index 00000000..706e869c Binary files /dev/null and b/images/csvIcon.png differ diff --git a/images/deleteIcon.png b/images/deleteIcon.png new file mode 100755 index 00000000..79c600f4 Binary files /dev/null and b/images/deleteIcon.png differ diff --git a/images/docIcon.png b/images/docIcon.png new file mode 100755 index 00000000..b20dc3b3 Binary files /dev/null and b/images/docIcon.png differ diff --git a/images/encarnita.jpeg b/images/encarnita.jpeg new file mode 100755 index 00000000..ba74d250 Binary files /dev/null and b/images/encarnita.jpeg differ diff --git a/images/encarnita.jpg b/images/encarnita.jpg new file mode 100755 index 00000000..e1391b1d Binary files /dev/null and b/images/encarnita.jpg differ diff --git a/images/exeIcon.png b/images/exeIcon.png new file mode 100755 index 00000000..e8178b74 Binary files /dev/null and b/images/exeIcon.png differ diff --git a/images/folderIconBig.png b/images/folderIconBig.png new file mode 100755 index 00000000..55490862 Binary files /dev/null and b/images/folderIconBig.png differ diff --git a/images/folderIconSmall.png b/images/folderIconSmall.png new file mode 100755 index 00000000..9733d6b1 Binary files /dev/null and b/images/folderIconSmall.png differ diff --git a/images/folderIconSmallSmall.png b/images/folderIconSmallSmall.png new file mode 100755 index 00000000..92a93d31 Binary files /dev/null and b/images/folderIconSmallSmall.png differ diff --git a/images/folderIconSmallx2.png b/images/folderIconSmallx2.png new file mode 100755 index 00000000..92a93d31 Binary files /dev/null and b/images/folderIconSmallx2.png differ diff --git a/images/folderIconSmallx3.png b/images/folderIconSmallx3.png new file mode 100755 index 00000000..9e8aee00 Binary files /dev/null and b/images/folderIconSmallx3.png differ diff --git a/images/jpgIcon.png b/images/jpgIcon.png new file mode 100755 index 00000000..79a3375b Binary files /dev/null and b/images/jpgIcon.png differ diff --git a/images/logo.png b/images/logo.png new file mode 100755 index 00000000..c1cd4d27 Binary files /dev/null and b/images/logo.png differ diff --git a/images/mp3Icon.png b/images/mp3Icon.png new file mode 100755 index 00000000..b4e29877 Binary files /dev/null and b/images/mp3Icon.png differ diff --git a/images/mp4Icon.png b/images/mp4Icon.png new file mode 100755 index 00000000..03b6c762 Binary files /dev/null and b/images/mp4Icon.png differ diff --git a/images/odtIcon.png b/images/odtIcon.png new file mode 100755 index 00000000..876f3233 Binary files /dev/null and b/images/odtIcon.png differ diff --git a/images/pdfIcon.png b/images/pdfIcon.png new file mode 100755 index 00000000..3cc0cc44 Binary files /dev/null and b/images/pdfIcon.png differ diff --git a/images/pngIcon.png b/images/pngIcon.png new file mode 100755 index 00000000..3c13949f Binary files /dev/null and b/images/pngIcon.png differ diff --git a/images/pptIcon.png b/images/pptIcon.png new file mode 100755 index 00000000..8d922169 Binary files /dev/null and b/images/pptIcon.png differ diff --git a/images/rarIcon.png b/images/rarIcon.png new file mode 100755 index 00000000..4bc2831c Binary files /dev/null and b/images/rarIcon.png differ diff --git a/images/renameIcon.png b/images/renameIcon.png new file mode 100755 index 00000000..4400cf1b Binary files /dev/null and b/images/renameIcon.png differ diff --git a/images/svgIcon.png b/images/svgIcon.png new file mode 100755 index 00000000..4092d34a Binary files /dev/null and b/images/svgIcon.png differ diff --git a/images/trashIcon.png b/images/trashIcon.png new file mode 100755 index 00000000..74d8fcc0 Binary files /dev/null and b/images/trashIcon.png differ diff --git a/images/txtIcon.png b/images/txtIcon.png new file mode 100755 index 00000000..06c0f797 Binary files /dev/null and b/images/txtIcon.png differ diff --git a/images/upload.png b/images/upload.png new file mode 100755 index 00000000..dadd32ca Binary files /dev/null and b/images/upload.png differ diff --git a/images/xIcon.png b/images/xIcon.png new file mode 100755 index 00000000..536209ff Binary files /dev/null and b/images/xIcon.png differ diff --git a/images/zipIcon.png b/images/zipIcon.png new file mode 100755 index 00000000..1dabb482 Binary files /dev/null and b/images/zipIcon.png differ diff --git a/index.php b/index.php new file mode 100755 index 00000000..df3d520f --- /dev/null +++ b/index.php @@ -0,0 +1,103 @@ + + + + + + + Wisus Drive + + + + + + + + + +
+ +
+
+
+
+
+ +
+
+ create folder icon + upload file icon + delete file icon + rename file icon +
+
+
+
+
folderfiles +
+
    +
+
+
+
+ + + + + +
+
+
+
    +
  • Creation date:
  • +
  • Last modificaton:
  • +
  • Extension:
  • +
  • Size:
  • +
  • Path:
  • +
+
+
+
+
+
+ left arrow + folder icon +

+
+
+

Name

+

Size

+

Modified

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

preview

+
+
+
+
+ +
+
+
+ +
+
+ + + \ No newline at end of file diff --git a/js/script.js b/js/script.js new file mode 100755 index 00000000..ce009768 --- /dev/null +++ b/js/script.js @@ -0,0 +1,180 @@ +const addFolderImage = document.querySelector("#addFolderImage"); +const ul = document.querySelector("#filesList"); +const filesPath = document.querySelector("#filesPath"); +const renameFile = document.querySelector("#renameFile"); +let inputValue; +let inputRename; +let reNameFolder; +let nameFolder; +let li; +let inputEdit; +let inputCounter = 0; +let oldDirectoryName; +let textValue = ""; +let padre = ""; +let levelDirectory = 0; + +addFolderImage.addEventListener("click", showImageFolder); +renameFile.addEventListener("click", renameFiles); +ul.addEventListener("dblclick", renameFiles); + +function renameFiles() { + if (textValue != "") { + /* text value and padre are taken from selectElement */ + oldDirectoryName = textValue.textContent; + inputRename = document.createElement("input"); + inputRename.setAttribute("id", "folderValues"); + inputRename.setAttribute("class", "folder-list-input"); + inputRename.setAttribute("type", "text"); + inputRename.setAttribute("value", textValue.textContent); + padre.replaceChild(inputRename, textValue); + inputRename.addEventListener("focusout", checkDirectoryReName); + inputRename.select(); + } +} + +function sameFolderName() { + padre.replaceChild(textValue, inputRename); +} + +function checkDirectoryReName() { + if (inputRename.value == oldDirectoryName) { + sameFolderName(); + } else { + fetch("modules/checkDirectoryName.php" + "?" + "directoryName=" + inputRename.value, { + method: "GET", + }) + .then((response) => response.json()) + .then((data) => { + console.log(data); + getInputRenameValue(data); + }) + .catch((err) => console.log("Request failed: ", err)); + } +} + +function getInputRenameValue(data) { + if (data === "Exist") { + inputRename.select(); + } else { + reNameFolder = inputRename.value; + const span = document.createElement("span"); + span.classList.add("text-list"); + span.textContent = reNameFolder; + li = document.querySelector('[data-path="' + dataPath + '"]'); + li.removeAttribute("data-path") + li.setAttribute("data-path", reNameFolder + "/"); + firstList = li; + dataPath = reNameFolder; + inputRename.remove(); + li.appendChild(span); + renameFolder(); + } +} + +function renameFolder() { + fetch("modules/reNameFolder.php?directoryNewName=" + reNameFolder + "&directoryOldName=" + oldDirectoryName, { + method: "GET", + }) + .then((response) => response.json()) + .then((data) => { + dataPath = firstList.getAttribute('data-path'); + printFilesSecondChild(); + printFolderTitleName(firstList); + }) + .catch((err) => console.log("Request failed: ", err)); +}; + +function showImageFolder() { + if (firstList != "") { + dataPath = firstList.getAttribute('data-path'); + levelDirectory = (dataPath.match(/\//g) || []).length; + } + li = document.createElement("li"); + li.setAttribute("class", "first-list"); + li.setAttribute("type", "folder"); + li.setAttribute("level", levelDirectory); + let levelDown = li.getAttribute("level"); + li.style.paddingLeft = levelDown * 10 + "%"; + const img = document.createElement("img"); + img.setAttribute("src", "images/folderIconSmallx3.png"); + img.setAttribute("alt", "Folder"); + img.classList.add("folder-list-img"); + const input = document.createElement("input"); + input.setAttribute("id", "folderValues"); + input.setAttribute("class", "folder-list-input"); + input.setAttribute("type", "text"); + input.setAttribute("value", "New folder"); + li.appendChild(img); + li.appendChild(input); + if (firstList == "") { + ul.insertBefore(li, firstList.nextSibling); + } else { + firstList.parentNode.insertBefore(li, firstList.nextSibling); + } + li.scrollIntoView(); + inputValue = input; + inputValue.addEventListener("focusout", checkDirectoryName); + input.select(); + firstListOld = firstList; + firstList = li; + firstList.style.backgroundColor = "yellow"; + putOffSelectElementColorFirst(); + addFolderImage.removeEventListener("click", showImageFolder); +} + +function checkDirectoryName() { + fetch("modules/checkDirectoryName.php" + "?" + "directoryName=" + dataPath + inputValue.value, { + method: "GET", + }) + .then((response) => response.json()) + .then((data) => { + console.log(data); + if (data == "Error creando directorio") { + checkDirectoryName(); + console.log("marina1") + console.log("marina2") + } + getInputValue(data); + }) + .catch((err) => console.log("Request failed: ", err)); +} + +function getInputValue(data) { + if (data === "Exist") { + inputValue.select(); + } else { + nameFolder = inputValue.value; + console.log(inputValue.value); + const span = document.createElement("span"); + span.classList.add("text-list"); + span.textContent = nameFolder; + li.setAttribute("data-path", dataPath + nameFolder + "/"); + let newDataPath = dataPath + nameFolder; + li = document.querySelector('[data-path="'+ newDataPath + "/" + '"]'); + inputValue.remove(); + li.appendChild(span); + addFolderImage.addEventListener("click", showImageFolder); + printFilesSecondChild(); + createFolder(); + } +} + +function createFolder() { + console.log(dataPath) + console.log(nameFolder) + console.log(dataPath + nameFolder) + fetch("modules/createFolder.php" + "?" + "directoryName=" + dataPath + nameFolder, { + method: "GET", + }) + .then((response) => response.json()) + .then((data) => { + console.log(data); + if (data === "Error creando directorio") { + li.remove(); + img.remove(); + p.remove(); + } + }) + .catch((err) => console.log("Request failed: ", err)); +} \ No newline at end of file diff --git a/js/search.js b/js/search.js new file mode 100755 index 00000000..f4cc5074 --- /dev/null +++ b/js/search.js @@ -0,0 +1,290 @@ +const searchInputForm = document.querySelector("#searchInputForm"); +const documentsMedia = document.querySelector("#documentsMedia"); +const imagesMedia = document.querySelector("#imagesMedia"); +const videosMedia = document.querySelector("#videosMedia"); +const audiosMedia = document.querySelector("#audiosMedia"); +const searchInput = document.querySelector("#searchInput"); +let searchValue; + +searchInput.addEventListener("keyup", searchElements); +imagesMedia.addEventListener("click", showImagesMedia); +videosMedia.addEventListener("click", showVideosMedia); +audiosMedia.addEventListener("click", showAudiosMedia); +documentsMedia.addEventListener("click", showDocumentsMedia); + +function searchElements() { + if (lastList != "") { + lastList.style.backgroundColor = "#D9D9D9"; + } + pathSecondFolderTitle.textContent = ""; + sizeListSecondChild.innerHTML = ""; + modificationListSecondChild.innerHTML = ""; + filesListSecondChild.innerHTML = ""; + 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)); + } +} + +function printFilesSearch(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 = "
document icon" + arrayNameJoined + "" + fileExtUpper + "
"; + filesListSecondChild.innerHTML += filesToPrint; + datapath = arrayNameJoined; + getInfoFilesSecondSearch(); + }) +} + +function printFoldersSearch(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 = "
folder" + folderName + ""; + 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 = "
document icon" + arrayNameJoined + "" + fileExtUpper + "
"; + 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 = "
folder" + 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 = "
document icon" + 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 = "x icon"; + } else if (dataPath.includes(".mp3")) { + showMediaContainer.style.display = "flex"; + showMediaChild.innerHTML = "x icon"; + } else if (dataPath.includes(".jpg") || dataPath.includes(".jpeg")) { + showMediaContainer.style.display = "flex"; + showMediaChild.innerHTML = "x icon"; + } else if (dataPath.includes(".png")) { + showMediaContainer.style.display = "flex"; + showMediaChild.innerHTML = "x icon"; + } else if (dataPath.includes(".svg")) { + showMediaContainer.style.display = "flex"; + showMediaChild.innerHTML = "x icon"; + } else if (dataPath.includes(".pdf")) { + showMediaContainer.style.display = "flex"; + showMediaChild.innerHTML = "x icon"; + } + 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 + "
trash-image
"; + 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 @@ +folder$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 @@ +folder$readFolder"; + }else{ + echo "
  • right arrow iconfolder$readFolder
  • "; + } + } else if($fileActualExt==="doc"){ + echo "
  • file$readFolder
  • "; + } else if($fileActualExt==="csv"){ + echo "
  • file$readFolder
  • "; + } else if($fileActualExt==="jpg"){ + echo "
  • file$readFolder
  • "; + } else if($fileActualExt==="jpeg"){ + echo "
  • file$readFolder
  • "; + } else if($fileActualExt==="png"){ + echo "
  • file$readFolder
  • "; + } else if($fileActualExt==="txt"){ + echo "
  • file$readFolder
  • "; + } else if($fileActualExt==="ppt"){ + echo "
  • file$readFolder
  • "; + } else if($fileActualExt==="odt"){ + echo "
  • file$readFolder
  • "; + } else if($fileActualExt==="pdf"){ + echo "
  • file$readFolder
  • "; + } else if($fileActualExt==="zip"){ + echo "
  • file$readFolder
  • "; + } else if($fileActualExt==="rar"){ + echo "
  • file$readFolder
  • "; + } else if($fileActualExt==="exe"){ + echo "
  • file$readFolder
  • "; + } else if($fileActualExt==="svg"){ + echo "
  • file$readFolder
  • "; + } else if($fileActualExt==="mp3"){ + echo "
  • file$readFolder
  • "; + } else if($fileActualExt==="mp4"){ + echo "
  • file$readFolder
  • "; + } + } + } + + 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 @@ +folder$readFolder
    "); + } else { + $readFolderArray = explode(".", $readFolder); + $readFolder = reset($readFolderArray); + $readFolderExt = strtoupper(end($readFolderArray)); + if($fileActualExt==="doc"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="csv"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="jpg"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="jpeg"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="png"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="txt"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="ppt"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="odt"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="pdf"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="zip"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="rar"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="exe"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="svg"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="mp3"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="mp4"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + } + } + } + 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/printFilesTrash.php b/modules/printFilesTrash.php new file mode 100755 index 00000000..96b59f4d --- /dev/null +++ b/modules/printFilesTrash.php @@ -0,0 +1,74 @@ +folder$readFolder"); + } else { + $readFolderArray = explode(".", $readFolder); + $readFolder = reset($readFolderArray); + $readFolderExt = strtoupper(end($readFolderArray)); + if($fileActualExt==="doc"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="csv"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="jpg"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="jpeg"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="png"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="txt"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="ppt"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="odt"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="pdf"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="zip"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="rar"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="exe"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="svg"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="mp3"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + else if($fileActualExt==="mp4"){ + array_push($arrayPrint, "
    $readFolder$readFolderExt
    "); + } + } + } + } + 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/reNameFolder.php b/modules/reNameFolder.php new file mode 100755 index 00000000..3bfc32de --- /dev/null +++ b/modules/reNameFolder.php @@ -0,0 +1,10 @@ + true, + "folders" => $foldersArray, + "files" => $filesArray, + "foldersTrash" => $foldersArrayTrash, + "filesTrash" => $filesArrayTrash +]); \ No newline at end of file diff --git a/modules/uploadFiles.php b/modules/uploadFiles.php new file mode 100755 index 00000000..6efc8acd --- /dev/null +++ b/modules/uploadFiles.php @@ -0,0 +1,41 @@ +