Improve human_filesize function, add anchor ids to FAQ and Archive titles

parent 7b1367fc
......@@ -67,13 +67,14 @@ function human_filesize($bytes, $decimals = 2)
return '';
}
$sz = 'BKMGTP';
$factor = floor((strlen($bytes) - 1) / 3);
$suff = @$sz[$factor];
if ($suff != 'B') {
$suff .= 'iB';
$sizes = 'BKMGTP';
$factor = floor((strlen($bytes) - 1) / 3) ?: 0;
$suffix = @$sizes[$factor];
if ($suffix === 'B') {
return "{$bytes}B";
}
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . $suff;
return sprintf("%.{$decimals}f", $bytes / (1024 ** $factor)) . "{$suffix}iB";
}
function get_dl_link($flavor, $version, $file = null)
......@@ -162,7 +163,7 @@ save_binaries_json($files, $stable);
</div>
</div>
<h2>Frequently Asked Questions</h2>
<h2 id="faq">Frequently Asked Questions</h2>
<div class="container">
<h3>Which version should I choose?</h3>
There is probably only one version that's going to run on your device. Run <code><b class="command">uname</b> -m</code> and choose the version that's named similar to the output.
......@@ -192,7 +193,7 @@ save_binaries_json($files, $stable);
Yes, but please use <a href="/binaries.json">this JSON representation</a> in stead of this website. Also, please note that excessive polling might get you banned.
</div>
<h2>Archive</h2>
<h2 id="archive">Archive</h2>
<a href="?show-unstable">(show unstable builds)</a>
<div id="view" class="view-details view-size-20">
<ul id="items" class="clearfix">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment