mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-15 01:07:21 -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();
|
event.preventDefault();
|
||||||
|
|
||||||
// Disable button, and update text
|
// Disable button, and update text
|
||||||
uploadButton.disabled = true;
|
|
||||||
uploadButton.innerHTML = 'Uploading ...';
|
uploadButton.innerHTML = 'Uploading ...';
|
||||||
|
uploadButton.disabled = true;
|
||||||
|
fileSelect.disabled = true;
|
||||||
|
|
||||||
// Create form data
|
// Create form data
|
||||||
var files = fileSelect.files;
|
var files = fileSelect.files;
|
||||||
@ -25,7 +26,7 @@ form.onsubmit = function(event) {
|
|||||||
|
|
||||||
ajax.upload.addEventListener('progress', function(event){
|
ajax.upload.addEventListener('progress', function(event){
|
||||||
console.log('upload progress', 'uploaded '+event.loaded+' bytes / '+event.total+' bytes');
|
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+'%';
|
uploadButton.innerHTML = 'Uploading '+percent+'%';
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
@ -35,6 +36,7 @@ form.onsubmit = function(event) {
|
|||||||
// Re-enable button, and update text
|
// Re-enable button, and update text
|
||||||
uploadButton.innerHTML = 'Send Files';
|
uploadButton.innerHTML = 'Send Files';
|
||||||
uploadButton.disabled = false;
|
uploadButton.disabled = false;
|
||||||
|
fileSelect.disabled = false;
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user