aboutsummaryrefslogtreecommitdiffstats
path: root/view/js
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2016-07-28 22:32:58 +0200
committerMario Vavti <mario@mariovavti.com>2016-07-28 22:32:58 +0200
commit3bf2935ee363a784f0140242b569eb4e2a837249 (patch)
tree05e98dc9d2e5e8ef6d8570f03e9c1b29f91088be /view/js
parent500ee4c1bf50efc5a9db419d9ad1c722851c29aa (diff)
downloadvolse-hubzilla-3bf2935ee363a784f0140242b569eb4e2a837249.tar.gz
volse-hubzilla-3bf2935ee363a784f0140242b569eb4e2a837249.tar.bz2
volse-hubzilla-3bf2935ee363a784f0140242b569eb4e2a837249.zip
add more info on what is happening after we are at 100% and minor fixes
Diffstat (limited to 'view/js')
-rw-r--r--view/js/mod_cloud.js22
1 files changed, 19 insertions, 3 deletions
diff --git a/view/js/mod_cloud.js b/view/js/mod_cloud.js
index 72e6185d6..cdcb0c8ee 100644
--- a/view/js/mod_cloud.js
+++ b/view/js/mod_cloud.js
@@ -88,13 +88,13 @@ function UploadFileSelectHandler(e) {
function prepareHtml(f, i) {
$("#cloud-index tr:nth-child(2)").after(
- '<tr class="new-upload">' +
+ '<tr id="new-upload-' + i + '" class="new-upload">' +
'<td><i class="fa ' + getIconFromType(f.type) + '" title="' + f.type + '"></i></td>' +
'<td>' + f.name + '</td>' +
'<td id="upload-progress-' + i + '"></td><td></td><td></td><td></td><td></td>' +
'<td class="hidden-xs">' + formatSizeUnits(f.size) + '</td><td class="hidden-xs"></td>' +
'</tr>' +
- '<tr class="new-upload">' +
+ '<tr id="new-upload-progress-bar-' + i + '"class="new-upload">' +
'<td id="upload-progress-bar-' + i + '" colspan="9" class="upload-progress-bar"></td>' +
'</tr>'
);
@@ -134,6 +134,7 @@ function getIconFromType(type) {
'application/x-rar-compressed': 'fa-file-archive-o',
//Audio
'audio/mpeg': 'fa-file-audio-o',
+ 'audio/mp3': 'fa-file-audio-o', //webkit browsers need that
'audio/wav': 'fa-file-audio-o',
'application/ogg': 'fa-file-audio-o',
'audio/ogg': 'fa-file-audio-o',
@@ -158,27 +159,37 @@ function getIconFromType(type) {
// upload files
function UploadFile(file, idx) {
- window.filesToUpload = window.filesToUpload + 1;
+ window.filesToUpload = window.filesToUpload + 1
var xhr = new XMLHttpRequest();
xhr.withCredentials = true; // Include the SESSION cookie info for authentication
(xhr.upload || xhr).addEventListener('progress', function (e) {
+
var done = e.position || e.loaded;
var total = e.totalSize || e.total;
// Dynamically update the percentage complete displayed in the file upload list
$('#upload-progress-' + idx).html(Math.round(done / total * 100) + '%');
$('#upload-progress-bar-' + idx).css('background-size', Math.round(done / total * 100) + '%');
+
+ if(done == total) {
+ $('#upload-progress-' + idx).html('Processing...');
+ }
+
});
+
xhr.addEventListener('load', function (e) {
+ //we could possibly turn the filenames to real links here and add the delete and edit buttons to avoid page reload...
+ $('#upload-progress-' + idx).html('Ready!');
//console.log('xhr upload complete', e);
window.fileUploadsCompleted = window.fileUploadsCompleted + 1;
// When all the uploads have completed, refresh the page
if (window.filesToUpload > 0 && window.fileUploadsCompleted === window.filesToUpload) {
+
window.fileUploadsCompleted = window.filesToUpload = 0;
// After uploads complete, refresh browser window to display new files
@@ -186,6 +197,11 @@ function UploadFile(file, idx) {
}
});
+
+ xhr.addEventListener('error', function (e) {
+ $('#upload-progress-' + idx).html('<span style="color: red;">ERROR</span>');
+ });
+
// POST to the entire cloud path
xhr.open('post', window.location.pathname, true);