]> git.immae.eu Git - perso/Immae/Projets/Nodejs/Surfer.git/blobdiff - frontend/js/app.js
Ensure upload progress stays within bounds
[perso/Immae/Projets/Nodejs/Surfer.git] / frontend / js / app.js
index 0a6ada16c788cae357568b8625cea425993f99ff..e446db3dd374530f2309f1b8fe6c772e4ff2f70e 100644 (file)
@@ -171,7 +171,8 @@ function uploadFiles(files) {
             if (!(event.target instanceof XMLHttpRequestUpload)) return;
 
             app.uploadStatus.done = finishedUploadSize + event.loaded;
-            app.uploadStatus.percentDone = Math.round(app.uploadStatus.done / app.uploadStatus.size * 100);
+            var tmp = Math.round(app.uploadStatus.done / app.uploadStatus.size * 100);
+            app.uploadStatus.percentDone = tmp > 100 ? 100 : tmp;
         }).end(function (error, result) {
             if (result && result.statusCode === 401) return logout();
             if (result && result.statusCode !== 201) return callback('Error uploading file: ', result.statusCode);
@@ -288,7 +289,7 @@ var app = new Vue({
                 getProfile(result.body.accessToken, function (error) {
                     if (error) return console.error(error);
 
-                    loadDirectory(window.location.hash.slice(1));
+                    loadDirectory(decode(window.location.hash.slice(1)));
                 });
             });
         },
@@ -428,11 +429,11 @@ var app = new Vue({
 getProfile(localStorage.accessToken, function (error) {
     if (error) return console.error(error);
 
-    loadDirectory(window.location.hash.slice(1));
+    loadDirectory(decode(window.location.hash.slice(1)));
 });
 
 $(window).on('hashchange', function () {
-    loadDirectory(window.location.hash.slice(1));
+    loadDirectory(decode(window.location.hash.slice(1)));
 });
 
 })();