From 9516aa199730115014538314dd46a5eaf3b12d20 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 17 Sep 2013 18:54:06 -0400 Subject: [PATCH] ajax.js: fix upload progress display in firefox --- js/ajax.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/js/ajax.js b/js/ajax.js index 74cfe9c0..ee2ff7b5 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -28,7 +28,14 @@ $(window).ready(function() { formData.append('post', submit_txt); var updateProgress = function(e) { - $(form).find('input[type="submit"]').val(_('Posting... (#%)').replace('#', Math.round(e.position / e.total * 100))); + var percentage; + if (e.position === undefined) { // Firefox + percentage = Math.round(e.loaded * 100 / e.total); + } + else { // Chrome? + percentage = Math.round(e.position * 100 / e.total); + } + $(form).find('input[type="submit"]').val(_('Posting... (#%)').replace('#', percentage)); }; $.ajax({