Updated albums public page

File size when JavaScript is disabled will now properly use B suffix.
It's referring to the fact that their unit is bytes.

Disclaimer about this. Back-end will only return the file size in bytes,
front-end is supposed to convert them into prettier units (KB, MB, ...).

Nothing much can be done if front-end have JavaScript disabled.
I don't want to defer the task, prettying the units, to back-end.
This commit is contained in:
Bobby Wibowo 2019-04-19 11:56:57 +07:00
parent ecb8afbe40
commit b754470630
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF
3 changed files with 4 additions and 4 deletions

View File

@ -23,7 +23,7 @@ page.getPrettyBytes = function (num, si) {
window.onload = function () {
const elements = document.getElementsByClassName('file-size')
for (let i = 0; i < elements.length; i++)
elements[i].innerHTML = page.getPrettyBytes(parseInt(elements[i].innerHTML))
elements[i].innerHTML = page.getPrettyBytes(parseInt(elements[i].innerHTML.replace(/\s*B$/i, '')))
page.lazyLoad = new LazyLoad()
}

View File

@ -16,7 +16,7 @@
v3: CSS and JS files (libs such as bulma, lazyload, etc).
v4: Renders in /public/render/* directories (to be used by render.js).
#}
{% set v1 = "DKoamSTKbO" %}
{% set v1 = "VAH8ougx12" %}
{% set v2 = "hiboQUzAzp" %}
{% set v3 = "DKoamSTKbO" %}
{% set v4 = "dplQUZqTnf" %}

View File

@ -42,7 +42,7 @@
</div>
<div class="level-item">
<h1 id="count" class="subtitle">
{{ count }} files (<span class="file-size">{{ totalSize }}</span>)
{{ count }} files (<span class="file-size">{{ totalSize }} B</span>)
</h1>
</div>
</div>
@ -84,7 +84,7 @@
</a>
<div class="details">
<p><span class="name" title="{{ file.file }}">{{ file.name }}</span></p>
<p class="file-size">{{ file.size }}</p>
<p class="file-size">{{ file.size }} B</p>
</div>
</div>
{% endfor %}