add a few plugins
This commit is contained in:
parent
b3bc49e576
commit
f254601f6f
5 changed files with 156 additions and 20 deletions
50
plugins/AdminerReadableTableSize.php
Normal file
50
plugins/AdminerReadableTableSize.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
/** This plugin replaces bytes sizes in tables list with human-readable sizes.
|
||||
* Original sizes are set to the title=""
|
||||
*
|
||||
* @link https://www.adminer.org/plugins/#use
|
||||
* @author Anonymous
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
|
||||
*/
|
||||
|
||||
class AdminerReadableTableSize
|
||||
{
|
||||
/** @access protected */
|
||||
var $prepend;
|
||||
|
||||
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 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) {
|
||||
sized = AdminerReadableTableSizeConvert(bytes, 2);
|
||||
}
|
||||
row.title = row.title+' [' + row.innerText + ' Bytes]';
|
||||
row.innerText = sized;
|
||||
}
|
||||
}
|
||||
document.addEventListener('DOMContentLoaded', function(event) {
|
||||
setTimeout(function() {
|
||||
AdminerReadableTableSize('Data_length');
|
||||
AdminerReadableTableSize('Index_length');
|
||||
AdminerReadableTableSize('Data_free');
|
||||
}, 500);
|
||||
});
|
||||
|
||||
EOT;
|
||||
}
|
||||
|
||||
function head()
|
||||
{
|
||||
echo script($this->prepend);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue