mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-14 16:36:21 +00:00
31a6940ab4
Added pagination to uploads and users list. With that, /api/uploads and /api/users API routes will now add "count" property to their response object. Enabled Delete user button in users list. With that also added /api/users/disable API route. As usual, you can only disable users whose usergroup is lower than your own. Click event will no longer trigger on "disabled" elements (basically any elements with "disabled" attribute). Changed all arrow functions into regular functions in public JS files (there were only a few that I somehow missed). Bumped v1 version string.
34 lines
944 B
JavaScript
34 lines
944 B
JavaScript
/* global LazyLoad */
|
|
|
|
const page = {
|
|
lazyLoad: null,
|
|
|
|
// byte units for getPrettyBytes()
|
|
byteUnits: ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
|
}
|
|
|
|
page.getPrettyBytes = function (num) {
|
|
// MIT License
|
|
// Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
|
|
|
if (!Number.isFinite(num)) return num
|
|
|
|
const neg = num < 0
|
|
if (neg) num = -num
|
|
if (num < 1) return (neg ? '-' : '') + num + ' B'
|
|
|
|
const exponent = Math.min(Math.floor(Math.log10(num) / 3), page.byteUnits.length - 1)
|
|
const numStr = Number((num / Math.pow(1000, exponent)).toPrecision(3))
|
|
const unit = page.byteUnits[exponent]
|
|
|
|
return (neg ? '-' : '') + numStr + ' ' + unit
|
|
}
|
|
|
|
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))
|
|
|
|
page.lazyLoad = new LazyLoad()
|
|
}
|