Fix #1047 Change from bit to byte

Fix some issues
This commit is contained in:
Nicolas Le Goff
2012-12-27 12:54:27 +01:00
parent 5abd5691af
commit 67abd2d0c4
2 changed files with 15 additions and 10 deletions

View File

@@ -150,7 +150,7 @@ $(document).ready(function () {
var totalElement; var totalElement;
var maxFileSize = {{ maxFileSize }}; var maxFileSize = {{ maxFileSize }};
UploaderManager.Preview.setOptions({ UploaderManager.Preview.setOptions({
maxWidth: 160, maxWidth: 160,
maxHeight: 120, maxHeight: 120,
@@ -338,7 +338,7 @@ $(document).ready(function () {
return false; return false;
}, },
fail: function(){ fail: function(){
//disabled cancel-all button, if queue is emepty and last upload fail //disabled cancel-all button, if queue is empty and last upload fail
if (UploaderManager.Queue.isEmpty()){ if (UploaderManager.Queue.isEmpty()){
$("#cancel-all").attr("disabled", true); $("#cancel-all").attr("disabled", true);
} }
@@ -395,10 +395,12 @@ $(document).ready(function () {
if (errorThrown === 'abort') { if (errorThrown === 'abort') {
return false; return false;
} else { } else {
data.context.find('.upload-record p.error').append(jqXHR.responseText); data.context.find('.upload-record p.error').append(jqXHR.status + " " + jqXHR.statusText).show();
} }
//Remove data //Remove data
UploaderManager.removeData(data.uploadIndex); UploaderManager.removeData(data.uploadIndex);
// Remove cancel button
$('button.remove-element', data.context).remove();
}); });
//cancel request //cancel request

View File

@@ -183,16 +183,19 @@ var p4 = p4 || {};
if (typeof bits !== 'number') { if (typeof bits !== 'number') {
throw bits + ' is not a number'; throw bits + ' is not a number';
} }
if (bits >= 1073741824) { // 1 byte = 8 bits
return (bits / 1073741824).toFixed(2) + ' Gbit/s'; var bytes = (bits >> 3);
if (bytes >= (1 << 30)) {
return (bytes / (1 << 30)).toFixed(2) + ' Go/s';
} }
if (bits >= 1048576) { if (bytes >= (1 << 20)) {
return (bits / 1048576).toFixed(2) + ' Mbit/s'; return (bytes / (1 << 20)).toFixed(2) + ' Mo/s';
} }
if (bits >= 1024) { if (bytes >= (1 << 10)) {
return (bits / 1024).toFixed(2) + ' Kbit/s'; return (bytes / (1 << 10)).toFixed(2) + ' Ko/s';
} }
return bits + ' bit/s'; return bytes + ' o/s';
}, },
pourcent: function(current, total){ pourcent: function(current, total){
return (current/ total * 100).toFixed(2) return (current/ total * 100).toFixed(2)