Verified Commit 7bd71684 authored by noplanman's avatar noplanman

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

parent 7b1367fc
...@@ -67,13 +67,14 @@ function human_filesize($bytes, $decimals = 2) ...@@ -67,13 +67,14 @@ function human_filesize($bytes, $decimals = 2)
return ''; return '';
} }
$sz = 'BKMGTP'; $sizes = 'BKMGTP';
$factor = floor((strlen($bytes) - 1) / 3); $factor = floor((strlen($bytes) - 1) / 3) ?: 0;
$suff = @$sz[$factor]; $suffix = @$sizes[$factor];
if ($suff != 'B') { if ($suffix === 'B') {
$suff .= 'iB'; 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) function get_dl_link($flavor, $version, $file = null)
...@@ -162,7 +163,7 @@ save_binaries_json($files, $stable); ...@@ -162,7 +163,7 @@ save_binaries_json($files, $stable);
</div> </div>
</div> </div>
<h2>Frequently Asked Questions</h2> <h2 id="faq">Frequently Asked Questions</h2>
<div class="container"> <div class="container">
<h3>Which version should I choose?</h3> <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. 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); ...@@ -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. 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> </div>
<h2>Archive</h2> <h2 id="archive">Archive</h2>
<a href="?show-unstable">(show unstable builds)</a> <a href="?show-unstable">(show unstable builds)</a>
<div id="view" class="view-details view-size-20"> <div id="view" class="view-details view-size-20">
<ul id="items" class="clearfix"> <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