mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-11 15:56:07 -07:00
Use human file size in table
This commit is contained in:
parent
9bdac38561
commit
010c12da67
2 changed files with 39 additions and 39 deletions
|
@ -449,3 +449,20 @@ $('*').on('click', '.refresh_pms_image', function (e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Taken from http://stackoverflow.com/questions/10420352/converting-file-size-in-bytes-to-human-readable#answer-14919494
|
||||||
|
function humanFileSize(bytes, si) {
|
||||||
|
var thresh = si ? 1000 : 1024;
|
||||||
|
if (Math.abs(bytes) < thresh) {
|
||||||
|
return bytes + ' B';
|
||||||
|
}
|
||||||
|
var units = si
|
||||||
|
? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
||||||
|
: ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
|
||||||
|
var u = -1;
|
||||||
|
do {
|
||||||
|
bytes /= thresh;
|
||||||
|
++u;
|
||||||
|
} while (Math.abs(bytes) >= thresh && u < units.length - 1);
|
||||||
|
return bytes.toFixed(1) + ' ' + units[u];
|
||||||
|
}
|
|
@ -194,7 +194,7 @@ media_info_table_options = {
|
||||||
"data": "file_size",
|
"data": "file_size",
|
||||||
"createdCell": function (td, cellData, rowData, row, col) {
|
"createdCell": function (td, cellData, rowData, row, col) {
|
||||||
if (cellData !== null && cellData !== '') {
|
if (cellData !== null && cellData !== '') {
|
||||||
$(td).html(Math.round(cellData / Math.pow(1024, 2)).toString() + ' MiB');
|
$(td).html(humanFileSize(cellData));
|
||||||
} else {
|
} else {
|
||||||
if (rowData['section_type'] != 'photo' && get_file_sizes != null) {
|
if (rowData['section_type'] != 'photo' && get_file_sizes != null) {
|
||||||
get_file_sizes = true;
|
get_file_sizes = true;
|
||||||
|
@ -485,20 +485,3 @@ function createChildTableMedia(row, rowData) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Taken from http://stackoverflow.com/questions/10420352/converting-file-size-in-bytes-to-human-readable#answer-14919494
|
|
||||||
function humanFileSize(bytes, si) {
|
|
||||||
var thresh = si ? 1000 : 1024;
|
|
||||||
if(Math.abs(bytes) < thresh) {
|
|
||||||
return bytes + ' B';
|
|
||||||
}
|
|
||||||
var units = si
|
|
||||||
? ['kB','MB','GB','TB','PB','EB','ZB','YB']
|
|
||||||
: ['KiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB'];
|
|
||||||
var u = -1;
|
|
||||||
do {
|
|
||||||
bytes /= thresh;
|
|
||||||
++u;
|
|
||||||
} while(Math.abs(bytes) >= thresh && u < units.length - 1);
|
|
||||||
return bytes.toFixed(1)+' '+units[u];
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue