`;
-
+
fileListContainer.innerHTML = topControlsHTML + tableHTML + tableBody + bottomControlsHTML;
-
- // Only add event listeners if searchInputElement exists.
- if (searchInputElement) {
- searchInputElement.addEventListener("input", function () {
+
+ // Re-attach event listener for the new search input element.
+ const newSearchInput = document.getElementById("searchInput");
+ if (newSearchInput) {
+ newSearchInput.addEventListener("input", debounce(function () {
+ window.currentSearchTerm = newSearchInput.value;
window.currentPage = 1;
renderFileTable(folder);
- });
+ // After re-rendering, restore focus and caret position.
+ setTimeout(() => {
+ const freshInput = document.getElementById("searchInput");
+ if (freshInput) {
+ freshInput.focus();
+ freshInput.setSelectionRange(freshInput.value.length, freshInput.value.length);
+ }
+ }, 0);
+ }, 300));
}
-
+
+ // Add event listeners for header sorting.
document.querySelectorAll("table.table thead th[data-column]").forEach(cell => {
cell.addEventListener("click", function () {
const column = this.getAttribute("data-column");
sortFiles(column, folder);
});
});
-
+
+ // Add event listeners for checkboxes.
document.querySelectorAll('#fileList .file-checkbox').forEach(checkbox => {
checkbox.addEventListener('change', function (e) {
updateRowHighlight(e.target);
updateFileActionButtons();
});
});
-
+
updateFileActionButtons();
}
@@ -712,15 +730,15 @@ export function editFile(fileName, folder) {
theme: theme,
viewportMargin: Infinity
});
-
+
// Ensure height adjustment
window.currentEditor = editor;
-
+
// Adjust height AFTER modal appears
setTimeout(() => {
adjustEditorSize(); // Set initial height
}, 50);
-
+
// Attach modal resize observer
observeModalResize(modal);
@@ -732,7 +750,7 @@ export function editFile(fileName, folder) {
document.getElementById("closeEditorX").addEventListener("click", function () {
modal.remove();
});
-
+
document.getElementById("decreaseFont").addEventListener("click", function () {
currentFontSize = Math.max(8, currentFontSize - 2);
editor.getWrapperElement().style.fontSize = currentFontSize + "px";
diff --git a/upload.js b/upload.js
index c8f53b8..9d46534 100644
--- a/upload.js
+++ b/upload.js
@@ -45,6 +45,29 @@ function getFilesFromDataTransferItems(items) {
return Promise.all(promises).then(results => results.flat());
}
+// Helper: Set default drop area content.
+// Moved to module scope so it is available globally in this module.
+function setDropAreaDefault() {
+ const dropArea = document.getElementById("uploadDropArea");
+ if (dropArea) {
+ dropArea.innerHTML = `
+
+ Drop files/folders here or click 'Choose files'
+
+
+
+
+
+
+ No files selected
+
+
+ `;
+ }
+}
+
function adjustFolderHelpExpansion() {
const uploadCard = document.getElementById("uploadCard");
const folderHelpDetails = document.querySelector(".folder-help-details");
@@ -247,8 +270,8 @@ function processFiles(filesInput) {
}
const listWrapper = document.createElement("div");
listWrapper.classList.add("upload-progress-wrapper");
- // Set a maximum height (adjust as needed) and enable vertical scrolling.
- listWrapper.style.maxHeight = "300px"; // for example, 300px
+ // Set a maximum height and enable vertical scrolling.
+ listWrapper.style.maxHeight = "300px";
listWrapper.style.overflowY = "auto";
listWrapper.appendChild(list);
progressContainer.appendChild(listWrapper);
@@ -433,30 +456,11 @@ function initUpload() {
fileInput.setAttribute("directory", "");
}
- // Helper: Set default drop area content.
- function setDropAreaDefault() {
- if (dropArea) {
- dropArea.innerHTML = `
-
- Drop files/folders here or click 'Choose files'
-
-
-
-
-
-
- No files selected
-
-
- `;
- }
- }
+ // Set default drop area content.
+ setDropAreaDefault();
if (dropArea) {
dropArea.classList.add("upload-drop-area");
- setDropAreaDefault();
dropArea.addEventListener("dragover", function (e) {
e.preventDefault();
// Use a darker color if dark mode is active.