]> git.immae.eu Git - perso/Immae/Projets/Nodejs/Surfer.git/blobdiff - frontend/js/app.js
add mov and avi filetypes as videos
[perso/Immae/Projets/Nodejs/Surfer.git] / frontend / js / app.js
index 26791878faa55370ca31b1902019129069ea9040..be5705f6a8eb962e6413a533992aa046d37f1ade 100644 (file)
@@ -60,7 +60,7 @@ var mimeTypes = {
     text: [ '.txt', '.md' ],
     pdf: [ '.pdf' ],
     html: [ '.html', '.htm', '.php' ],
-    video: [ '.mp4', '.mpg', '.mpeg', '.ogg', '.mkv' ]
+    video: [ '.mp4', '.mpg', '.mpeg', '.ogg', '.mkv', '.avi', '.mov' ]
 };
 
 function getPreviewUrl(entry, basePath) {
@@ -146,11 +146,16 @@ function uploadFiles(files) {
         var formData = new FormData();
         formData.append('file', file);
 
+        var finishedUploadSize = app.uploadStatus.done;
+
         superagent.post('/api/files' + path)
           .query({ access_token: localStorage.accessToken })
           .send(formData)
           .on('progress', function (event) {
-            app.uploadStatus.done += event.loaded;
+            // only handle upload events
+            if (!(event.target instanceof XMLHttpRequestUpload)) return;
+
+            app.uploadStatus.done = finishedUploadSize + event.loaded;
             app.uploadStatus.percentDone = Math.round(app.uploadStatus.done / app.uploadStatus.size * 100);
         }).end(function (error, result) {
             if (result && result.statusCode === 401) return logout();