diff --git a/fileManager.js b/fileManager.js index 81b0098..38bf124 100644 --- a/fileManager.js +++ b/fileManager.js @@ -158,13 +158,13 @@ export function renderFileTable(folder) { Date Modified ${sortOrder.column === "modified" ? (sortOrder.ascending ? "▲" : "▼") : ""} - + Upload Date ${sortOrder.column === "uploaded" ? (sortOrder.ascending ? "▲" : "▼") : ""} File Size ${sortOrder.column === "size" ? (sortOrder.ascending ? "▲" : "▼") : ""} - + Uploader ${sortOrder.column === "uploader" ? (sortOrder.ascending ? "▲" : "▼") : ""} Actions @@ -193,9 +193,9 @@ export function renderFileTable(folder) { ${safeFileName} ${safeModified} - ${safeUploaded} + ${safeUploaded} ${safeSize} - ${safeUploader} + ${safeUploader}
diff --git a/networkUtils.js b/networkUtils.js index 18dd691..c3e579d 100644 --- a/networkUtils.js +++ b/networkUtils.js @@ -1,22 +1,32 @@ // networkUtils.js export function sendRequest(url, method = "GET", data = null) { - console.log("Sending request to:", url, "with method:", method); - const options = { method, headers: { "Content-Type": "application/json" } }; - if (data) { - options.body = JSON.stringify(data); - } - return fetch(url, options) - .then(response => { - console.log("Response status:", response.status); - if (!response.ok) { - return response.text().then(text => { - throw new Error(`HTTP error ${response.status}: ${text}`); - }); - } - return response.json().catch(() => { - console.warn("Response is not JSON, returning as text"); - return response.text(); - }); - }); + console.log("Sending request to:", url, "with method:", method); + const options = { + method, + credentials: 'include', // include cookies in requests + headers: {} + }; + + // If data is provided and is not FormData, assume JSON. + if (data && !(data instanceof FormData)) { + options.headers["Content-Type"] = "application/json"; + options.body = JSON.stringify(data); + } else if (data instanceof FormData) { + // For FormData, don't set the Content-Type header; the browser will handle it. + options.body = data; } - \ No newline at end of file + + return fetch(url, options) + .then(response => { + console.log("Response status:", response.status); + if (!response.ok) { + return response.text().then(text => { + throw new Error(`HTTP error ${response.status}: ${text}`); + }); + } + return response.json().catch(() => { + console.warn("Response is not JSON, returning as text"); + return response.text(); + }); + }); +} \ No newline at end of file diff --git a/styles.css b/styles.css index 63e31a8..d7094d7 100644 --- a/styles.css +++ b/styles.css @@ -208,6 +208,24 @@ header { align-items: center; } +#customChooseBtn { + background-color: #9E9E9E; + color: #fff; + border: none; + border-radius: 4px; + padding: 8px 18px; + font-size: 16px; + cursor: pointer; + white-space: nowrap; /* Prevent text wrapping */ +} + +/* For medium screens, reduce font size and padding */ +@media (max-width: 768px) { + #customChooseBtn { + font-size: 14px; + padding: 6px 14px; + } +} /* =========================================================== UPLOAD PROGRESS STYLES =========================================================== */ @@ -286,6 +304,11 @@ header { display: none; } } +@media (min-width: 768px) and (max-width: 991px) { + .hide-medium { + display: none !important; + } +} /* =========================================================== BUTTON STYLES (MATERIAL THEME) diff --git a/upload.js b/upload.js index c55b7e7..da338c1 100644 --- a/upload.js +++ b/upload.js @@ -1,8 +1,7 @@ // upload.js import { loadFileList, displayFilePreview, initFileActions } from './fileManager.js'; -import { showToast } from './domUtils.js'; - +import { showToast, escapeHTML } from './domUtils.js'; export function initUpload() { const fileInput = document.getElementById("file"); @@ -18,8 +17,8 @@ export function initUpload() { Drop files here or click 'Choose files'
-
No files selected @@ -27,12 +26,12 @@ export function initUpload() {
`; // Wire up the custom button. - /* const customChooseBtn = document.getElementById("customChooseBtn"); + /* const customChooseBtn = document.getElementById("customChooseBtn"); if (customChooseBtn) { customChooseBtn.addEventListener("click", function () { fileInput.click(); }); - }*/ + } */ } } @@ -82,7 +81,7 @@ export function initUpload() { if (files.length === 1) { fileInfoContainer.innerHTML = `
- ${files[0].name} + ${escapeHTML(files[0].name)} `; } else { fileInfoContainer.innerHTML = ` @@ -121,6 +120,7 @@ export function initUpload() { displayFilePreview(file, preview); const nameDiv = document.createElement("div"); + // Using textContent here is safe, so no need to escape nameDiv.textContent = file.name; nameDiv.style.flexGrow = "1"; nameDiv.style.marginLeft = "5px";