diff options
Diffstat (limited to 'src/static/main.js')
| -rw-r--r-- | src/static/main.js | 7 |
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}` |
