aboutsummaryrefslogtreecommitdiff
path: root/src/static/main.js
diff options
context:
space:
mode:
authorJoris Guyonvarch2026-01-01 17:10:39 +0100
committerJoris Guyonvarch2026-01-01 17:10:39 +0100
commit7404107ee65f6c3978e72fafd66cc050a2ca7e5b (patch)
treef8a6166dcd8016f617ba473c11f2b4a22894b9f8 /src/static/main.js
parent8fcce388b0a66ca69c71f2f428940a6f7f9258f2 (diff)
Show progress pct on upload
Diffstat (limited to 'src/static/main.js')
-rw-r--r--src/static/main.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/static/main.js b/src/static/main.js
index b3ed57b..3a62743 100644
--- a/src/static/main.js
+++ b/src/static/main.js
@@ -4,6 +4,7 @@ window.onload = function() {
if (form !== null) {
const submit = document.querySelector('input[type="submit"]')
const loading = document.querySelector('.g-Loading')
+ const loadingPct = document.querySelector('.g-LoadingPct')
const error = document.querySelector('.g-Error')
function showError(msg) {
@@ -29,6 +30,12 @@ window.onload = function() {
setTimeout(function() {
const xhr = new XMLHttpRequest()
xhr.open('POST', '/upload', true)
+ xhr.onprogress = function (event) {
+ if (event.lengthComputable) {
+ const pct = (event.loaded / event.total) * 100;
+ loadingPct.innerText = `${pct} %`
+ }
+ }
xhr.onload = function () {
if (xhr.status === 200) {
window.location = `/share/${xhr.responseText}`