diff --git a/displayFileList.js b/displayFileList.js
index 6c51bc7..b0117f7 100644
--- a/displayFileList.js
+++ b/displayFileList.js
@@ -35,18 +35,6 @@ export function loadFileList() {
-
-export function toggleDeleteButton() {
- const selectedFiles = document.querySelectorAll(".file-checkbox:checked");
- const deleteBtn = document.getElementById("deleteSelectedBtn");
- const copyBtn = document.getElementById("copySelectedBtn");
- const moveBtn = document.getElementById("moveSelectedBtn");
- const disabled = selectedFiles.length === 0;
- deleteBtn.disabled = disabled;
- if (copyBtn) copyBtn.disabled = disabled;
- if (moveBtn) moveBtn.disabled = disabled;
-}
-
export function toggleAllCheckboxes(source) {
const checkboxes = document.querySelectorAll(".file-checkbox");
checkboxes.forEach(checkbox => checkbox.checked = source.checked);
@@ -90,59 +78,6 @@ document.addEventListener("DOMContentLoaded", function () {
}
});
-export function editFile(fileName) {
- const threshold = 10 * 1024 * 1024; // 10 MB threshold
- fetch(`uploads/${encodeURIComponent(fileName)}`, { method: 'HEAD' })
- .then(response => {
- const fileSize = parseInt(response.headers.get('Content-Length') || "0", 10);
- if (fileSize > threshold) {
- alert("This file is too large to edit in the browser.");
- return;
- }
- return fetch(`uploads/${encodeURIComponent(fileName)}?t=${new Date().getTime()}`);
- })
- .then(response => {
- if (!response) return;
- if (!response.ok) throw new Error("HTTP error! Status: " + response.status);
- return response.text();
- })
- .then(content => {
- if (!content) return;
- const modal = document.createElement("div");
- modal.id = "editorContainer";
- modal.classList.add("modal", "editor-modal");
- modal.innerHTML = `
-
Editing: ${fileName}
-
-
-
-
-
- `;
- document.body.appendChild(modal);
- modal.style.display = "block";
- })
- .catch(error => console.error("Error in editFile:", error));
-}
-
-export function saveFile(fileName) {
- const editor = document.getElementById("fileEditor");
- if (!editor) {
- console.error("Editor not found!");
- return;
- }
- const fileData = {
- fileName: fileName,
- content: editor.value
- };
- sendRequest("saveFile.php", "POST", fileData)
- .then(result => {
- alert(result.success || result.error);
- document.getElementById("editorContainer")?.remove();
- loadFileList();
- })
- .catch(error => console.error("Error saving file:", error));
-}
// ===== NEW CODE: Copy & Move Functions =====
@@ -159,6 +94,10 @@ export function copySelectedFiles() {
alert("Please select a target folder.");
return;
}
+ if (currentFolder === targetFolder) {
+ alert("Cannot copy files to the same folder.");
+ return;
+ }
// Send the correct keys
sendRequest("copyFiles.php", "POST", {
source: currentFolder,
@@ -172,8 +111,6 @@ export function copySelectedFiles() {
.catch(error => console.error("Error copying files:", error));
}
-
-
export function moveSelectedFiles() {
const selectedFiles = Array.from(document.querySelectorAll(".file-checkbox:checked"))
.map(checkbox => checkbox.value);
@@ -186,11 +123,10 @@ export function moveSelectedFiles() {
alert("Please select a target folder.");
return;
}
- console.log("Payload:", {
- source: currentFolder,
- destination: document.getElementById("copyMoveFolderSelect").value,
- files: selectedFiles
- });
+ if (currentFolder === targetFolder) {
+ alert("Cannot move files to the same folder.");
+ return;
+ }
sendRequest("moveFiles.php", "POST", {
source: currentFolder,
destination: targetFolder,
@@ -204,14 +140,13 @@ export function moveSelectedFiles() {
}
-
// Populate the Copy/Move folder dropdown
export function loadCopyMoveFolderList() {
$.get('getFolderList.php', function (response) {
const folderSelect = $('#copyMoveFolderSelect');
folderSelect.empty();
// Always add a "Root" option as the default.
- folderSelect.append($('