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 maxFileSize = {{ maxFileSize }};
UploaderManager.Preview.setOptions({
maxWidth: 160,
maxHeight: 120,
@@ -338,7 +338,7 @@ $(document).ready(function () {
return false;
},
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()){
$("#cancel-all").attr("disabled", true);
}
@@ -395,10 +395,12 @@ $(document).ready(function () {
if (errorThrown === 'abort') {
return false;
} 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
UploaderManager.removeData(data.uploadIndex);
// Remove cancel button
$('button.remove-element', data.context).remove();
});
//cancel request

View File

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