diff options
| -rw-r--r-- | src/static/main.js | 7 | ||||
| -rw-r--r-- | src/templates.rs | 2 |
2 files changed, 8 insertions, 1 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}` diff --git a/src/templates.rs b/src/templates.rs index 9fd2162..0dc6230 100644 --- a/src/templates.rs +++ b/src/templates.rs @@ -71,7 +71,7 @@ pub const INDEX: &str = const_format::concatcp!( <div class="g-Loading"> <div class="g-Spinner"></div> - Uploading… + <div class="g-LoadingPct">0 %</div> </div> <div class="g-Error"> |
