diff --git a/fileManager.js b/fileManager.js index 0efcee3..81b0098 100644 --- a/fileManager.js +++ b/fileManager.js @@ -107,40 +107,42 @@ export function renderFileTable(folder) { const currentPage = window.currentPage || 1; const totalFiles = filteredFiles.length; const totalPages = Math.ceil(totalFiles / itemsPerPage); - + const safeSearchTerm = escapeHTML(searchTerm); // 1. Top controls: Responsive row with search box on the left and Prev/Next on the right. const topControlsHTML = ` -
- -
-
-
- - search - +
+ +
+
+
+ + search + +
+ +
+
+ +
+
+ + Page ${currentPage} of ${totalPages || 1} +
-
- -
- - Page ${currentPage} of ${totalPages || 1} - -
-
- `; +`; // 2. Build the File Table with Bootstrap styling. let tableHTML = ` @@ -185,30 +187,32 @@ export function renderFileTable(folder) { const safeUploader = escapeHTML(file.uploader || "Unknown"); tableBody += ` - - - - - ${safeFileName} - ${safeModified} - ${safeUploaded} - ${safeSize} - ${safeUploader} - -
- Download - ${isEditable ? ` - - ` : ""} - -
- - - `; + ` : ""} + +
+ + + `; }); } else { tableBody += `No files found.`; @@ -299,34 +303,34 @@ export function sortFiles(column, folder) { sortOrder.column = column; sortOrder.ascending = true; } - + // Sort fileData based on the column. fileData.sort((a, b) => { let valA = a[column] || ""; let valB = b[column] || ""; - + if (column === "modified" || column === "uploaded") { // Log the raw date strings. //console.log(`Sorting ${column}: raw values ->`, valA, valB); - + const parsedA = parseCustomDate(valA); const parsedB = parseCustomDate(valB); - + // Log the parsed numeric timestamps. //console.log(`Sorting ${column}: parsed values ->`, parsedA, parsedB); - + valA = parsedA; valB = parsedB; } else if (typeof valA === "string") { valA = valA.toLowerCase(); valB = valB.toLowerCase(); } - + if (valA < valB) return sortOrder.ascending ? -1 : 1; if (valA > valB) return sortOrder.ascending ? 1 : -1; return 0; }); - + // Re-render the file table after sorting. renderFileTable(folder); } @@ -408,15 +412,15 @@ export async function loadCopyMoveFolderListForModal(dropdownId) { const response = await fetch('getFolderList.php'); const folders = await response.json(); console.log('Folders fetched for modal:', folders); - + const folderSelect = document.getElementById(dropdownId); folderSelect.innerHTML = ''; - + const rootOption = document.createElement('option'); rootOption.value = 'root'; rootOption.textContent = '(Root)'; folderSelect.appendChild(rootOption); - + if (Array.isArray(folders) && folders.length > 0) { folders.forEach(folder => { const option = document.createElement('option'); @@ -462,7 +466,7 @@ document.addEventListener("DOMContentLoaded", function () { showToast("Selected files copied successfully!", 5000); loadFileList(window.currentFolder); } else { - showToast("Error: " + (data.error || "Could not copy files"), 5000); + showToast("Error: " + (data.error || "Could not copy files"), 5000); } }) .catch(error => console.error("Error copying files:", error)) @@ -656,10 +660,10 @@ export function renameFile(oldName, folder) { // Store the file name and folder globally for use in the modal. window.fileToRename = oldName; window.fileFolder = folder || window.currentFolder || "root"; - + // Pre-fill the input with the current file name. document.getElementById("newFileName").value = oldName; - + // Show the rename file modal. document.getElementById("renameFileModal").style.display = "block"; } @@ -669,16 +673,16 @@ document.addEventListener("DOMContentLoaded", () => { // Cancel button: hide modal and clear input. const cancelBtn = document.getElementById("cancelRenameFile"); if (cancelBtn) { - cancelBtn.addEventListener("click", function() { + cancelBtn.addEventListener("click", function () { document.getElementById("renameFileModal").style.display = "none"; document.getElementById("newFileName").value = ""; }); } - + // Submit button: send rename request. const submitBtn = document.getElementById("submitRenameFile"); if (submitBtn) { - submitBtn.addEventListener("click", function() { + submitBtn.addEventListener("click", function () { const newName = document.getElementById("newFileName").value.trim(); if (!newName || newName === window.fileToRename) { // No change; just hide the modal. diff --git a/index.html b/index.html index dcf008c..66aada2 100644 --- a/index.html +++ b/index.html @@ -26,9 +26,15 @@

Multi File Upload Editor

- - - + + +
@@ -163,39 +169,53 @@

Files in (Root)

- +