* file.db: file_user_rating: Table for tracking average user rating of a file

* Default filter order to descending
* File rating support including in search/filter
* Default to passing submitted form data (if any) @ prevMenu()
* Fix issues with byte/size formatting for 0
* Allow action keys for prompts
* use MenuModule.pausePrompt() in various places
* Add quick search to file area
* Display dupes, if any @ upload
This commit is contained in:
Bryan Ashby 2017-02-07 20:20:10 -07:00
parent 5f929b3d63
commit f0db0e3c94
16 changed files with 714 additions and 230 deletions

View file

@ -301,13 +301,17 @@ function renderStringLength(s) {
const SIZE_ABBRS = [ 'B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB' ]; // :)
function formatByteSizeAbbr(byteSize) {
if(0 === byteSize) {
return SIZE_ABBRS[0]; // B
}
return SIZE_ABBRS[Math.floor(Math.log(byteSize) / Math.log(1024))];
}
function formatByteSize(byteSize, withAbbr, decimals) {
withAbbr = withAbbr || false;
decimals = decimals || 3;
const i = Math.floor(Math.log(byteSize) / Math.log(1024));
const i = 0 === byteSize ? byteSize : Math.floor(Math.log(byteSize) / Math.log(1024));
let result = parseFloat((byteSize / Math.pow(1024, i)).toFixed(decimals));
if(withAbbr) {
result += ` ${SIZE_ABBRS[i]}`;