mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-14 16:57:16 -05:00
Display upload progress percent in submit button
This commit is contained in:
parent
dd3f2d60b6
commit
38c39918d4
@ -9,8 +9,9 @@ form.onsubmit = function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
// Disable button, and update text
|
||||
uploadButton.disabled = true;
|
||||
uploadButton.innerHTML = 'Uploading ...';
|
||||
uploadButton.disabled = true;
|
||||
fileSelect.disabled = true;
|
||||
|
||||
// Create form data
|
||||
var files = fileSelect.files;
|
||||
@ -25,7 +26,7 @@ form.onsubmit = function(event) {
|
||||
|
||||
ajax.upload.addEventListener('progress', function(event){
|
||||
console.log('upload progress', 'uploaded '+event.loaded+' bytes / '+event.total+' bytes');
|
||||
var percent = Math.ceil(event.loaded / event.total) * 100;
|
||||
var percent = parseInt((event.loaded / event.total) * 100, 10);
|
||||
uploadButton.innerHTML = 'Uploading '+percent+'%';
|
||||
}, false);
|
||||
|
||||
@ -35,6 +36,7 @@ form.onsubmit = function(event) {
|
||||
// Re-enable button, and update text
|
||||
uploadButton.innerHTML = 'Send Files';
|
||||
uploadButton.disabled = false;
|
||||
fileSelect.disabled = false;
|
||||
}
|
||||
}, false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user