diff --git a/CHANGELOG.md b/CHANGELOG.md index 0728596..21eda79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,25 @@ - Removed the inline `onclick` attributes from `#cancelDownloadFile` and `#confirmSingleDownloadButton` in the HTML - Ensured all file-action modals (delete, download, extract, copy, move, rename) now use JS event handlers instead of inline code +### 5. domUtils.js + +- **Removed** all inline `onclick` and `onchange` attributes from: + - `buildSearchAndPaginationControls` (advanced search toggle, prev/next buttons, items-per-page selector) + - `buildFileTableHeader` (select-all checkbox) + - `buildFileTableRow` (download, edit, preview, rename buttons) +- **Retained** all original logic (file-type icon detection, shift-select, debounce, custom confirm modal, etc.) + +### 6. fileListView.js + +- **Stopped** generating inline `onclick` handlers in both table and gallery views. +- **Added** `data-` attributes on actionable elements: + - `data-download-name`, `data-download-folder` + - `data-edit-name`, `data-edit-folder` + - `data-rename-name`, `data-rename-folder` + - `data-preview-url`, `data-preview-name` + - IDs on controls: `#advancedSearchToggle`, `#searchInput`, `#prevPageBtn`, `#nextPageBtn`, `#selectAll`, `#itemsPerPageSelect` +- **Introduced** `attachListControlListeners()` to bind all events via `addEventListener` immediately after rendering, preserving every interaction without inline code. + --- ## Changes 4/25/2025 diff --git a/public/js/authModals.js b/public/js/authModals.js index 1b3984c..b913d17 100644 --- a/public/js/authModals.js +++ b/public/js/authModals.js @@ -3,7 +3,7 @@ import { sendRequest } from './networkUtils.js'; import { t, applyTranslations, setLocale } from './i18n.js'; import { loadAdminConfigFunc } from './auth.js'; -const version = "v1.2.5"; // Update this version string as needed +const version = "v1.2.6"; // Update this version string as needed const adminTitle = `${t("admin_panel")} ${version}`; let lastLoginData = null; diff --git a/public/js/domUtils.js b/public/js/domUtils.js index 2817bad..905af8a 100644 --- a/public/js/domUtils.js +++ b/public/js/domUtils.js @@ -91,7 +91,7 @@ export function showToast(message, duration = 3000) { export function buildSearchAndPaginationControls({ currentPage, totalPages, searchTerm }) { const safeSearchTerm = escapeHTML(searchTerm); // Choose the placeholder text based on advanced search mode - const placeholderText = window.advancedSearchEnabled + const placeholderText = window.advancedSearchEnabled ? t("search_placeholder_advanced") : t("search_placeholder"); @@ -101,7 +101,7 @@ export function buildSearchAndPaginationControls({ currentPage, totalPages, sear
| + | ${t("file_name")} ${sortOrder.column === "name" ? (sortOrder.ascending ? "▲" : "▼") : ""} | @@ -162,15 +162,15 @@ export function buildFileTableRow(file, folderPath) { } else if (/\.(mp3|wav|m4a|ogg|flac|aac|wma|opus)$/i.test(file.name)) { previewIcon = `audiotrack`; } - previewButton = `||||
|---|---|---|---|---|---|
| - + | ${safeFileName} | @@ -179,22 +179,16 @@ export function buildFileTableRow(file, folderPath) {
@@ -207,10 +201,10 @@ export function buildBottomControls(itemsPerPageSetting) {
return `
-
@@ -345,4 +339,7 @@ export function showCustomConfirmModal(message) {
yesBtn.addEventListener("click", onYes);
noBtn.addEventListener("click", onNo);
});
-}
\ No newline at end of file
+}
+
+window.toggleRowSelection = toggleRowSelection;
+window.updateRowHighlight = updateRowHighlight;
\ No newline at end of file
diff --git a/public/js/fileListView.js b/public/js/fileListView.js
index 8d2e43f..745c82a 100644
--- a/public/js/fileListView.js
+++ b/public/js/fileListView.js
@@ -340,6 +340,48 @@ export function renderFileTable(folder, container) {
fileListContent.innerHTML = combinedTopHTML + headerHTML + rowsHTML + bottomControlsHTML;
+ // 1) Row-click selects the row
+fileListContent.querySelectorAll("tbody tr").forEach(row => {
+ row.addEventListener("click", e => {
+ // grab the underlying checkbox value
+ const cb = row.querySelector(".file-checkbox");
+ if (!cb) return;
+ toggleRowSelection(e, cb.value);
+ });
+ });
+
+ // 2) Download buttons
+ fileListContent.querySelectorAll(".download-btn").forEach(btn => {
+ btn.addEventListener("click", e => {
+ e.stopPropagation();
+ openDownloadModal(btn.dataset.downloadName, btn.dataset.downloadFolder);
+ });
+ });
+
+ // 3) Edit buttons
+ fileListContent.querySelectorAll(".edit-btn").forEach(btn => {
+ btn.addEventListener("click", e => {
+ e.stopPropagation();
+ editFile(btn.dataset.editName, btn.dataset.editFolder);
+ });
+ });
+
+ // 4) Rename buttons
+ fileListContent.querySelectorAll(".rename-btn").forEach(btn => {
+ btn.addEventListener("click", e => {
+ e.stopPropagation();
+ renameFile(btn.dataset.renameName, btn.dataset.renameFolder);
+ });
+ });
+
+ // 5) Preview buttons (if you still have a .preview-btn)
+ fileListContent.querySelectorAll(".preview-btn").forEach(btn => {
+ btn.addEventListener("click", e => {
+ e.stopPropagation();
+ previewFile(btn.dataset.previewUrl, btn.dataset.previewName);
+ });
+ });
+
createViewToggleButton();
// Setup event listeners.
@@ -529,9 +571,9 @@ export function renderGalleryView(folder, container) {
-
+
${thumbnail}
@@ -543,20 +585,21 @@ export function renderGalleryView(folder, container) {
${tagBadgesHTML}
|