From 53d90cb0701ab4060ed686bb84ce7fa544a8e349 Mon Sep 17 00:00:00 2001 From: Kumi Date: Sat, 16 Mar 2024 21:35:45 +0100 Subject: [PATCH] feat(userarea): handle file upload success more visibly Improve user feedback during file uploads by explicitly handling HTTP 201 responses as successful uploads. Upon a successful upload, the progress bar now turns green (`bg-success`) and displays a "Success!" message, providing a clearer and more immediate visual cue to the user that their file has been successfully uploaded. This change addresses usability issues by making the upload progress and outcome more discernible to users. --- assets/js/userarea.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/assets/js/userarea.js b/assets/js/userarea.js index 576f179..2cd48d6 100644 --- a/assets/js/userarea.js +++ b/assets/js/userarea.js @@ -117,10 +117,12 @@ function uploadFile(file, progressBar, thumbnail) { xhr.open('POST', document.location.href, true); xhr.onload = () => { - if (xhr.status === 200) { + if (xhr.status === 201) { const response = JSON.parse(xhr.responseText); const thumbnailUrl = response.thumbnailUrl; thumbnail.src = thumbnailUrl; + progressBar.classList.add('bg-success'); + progressBar.textContent = "Success!"; } else { progressBar.classList.add('bg-danger'); progressBar.textContent = "Error!";