From 70e5d64c1bec487db027ba8a176b0bc5cfea2c82 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 276e1ac7..8f0f7258 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -29,7 +29,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({