AdminerReadableTableSize show '-' for "empty" tables with less than 16KiB and use the SI annotation

This commit is contained in:
Pau Capó 2019-09-10 19:44:31 +02:00
parent 99a9242da9
commit 6e089e9aa1

View file

@ -17,14 +17,14 @@ class AdminerReadableTableSize
function __construct()
{
$this->prepend = <<<EOT
function AdminerReadableTableSizeConvert(a,b){if(0==a)return"0 Bytes";var c=1024,d=b||2,e=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],f=Math.floor(Math.log(a)/Math.log(c));return parseFloat((a/Math.pow(c,f)).toFixed(d))+" "+e[f]}
function AdminerReadableTableSizeConvert(a,b){if(0==a)return"0 Bytes";var c=1024,d=b||2,e=["Bytes","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],f=Math.floor(Math.log(a)/Math.log(c));return parseFloat((a/Math.pow(c,f)).toFixed(d))+" "+e[f]}
function AdminerReadableTableSize(field) {
var rows = document.querySelectorAll('[id*="'+field+'"]');
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
var bytes = row.innerText.replace(/,/g, '');
var sized = '-';
if (bytes > 0) {
if (bytes > 16384) {
sized = AdminerReadableTableSizeConvert(bytes, 2);
}
row.title = row.title+' [' + row.innerText + ' Bytes]';