Add homepage stats toggles

This commit is contained in:
JonnyWong16 2017-07-22 18:13:53 -07:00
parent 25455e8194
commit 1f55b5457e
8 changed files with 235 additions and 111 deletions

View file

@ -495,4 +495,24 @@ function humanFileSize(bytes, si) {
++u;
} while (Math.abs(bytes) >= thresh && u < units.length - 1);
return bytes.toFixed(1) + '&nbsp;' + units[u];
}
// Force max/min in number inputs
function forceMinMax(elem) {
var min = parseInt(elem.attr('min'));
var max = parseInt(elem.attr('max'));
var val = parseInt(elem.val());
var default_val = parseInt(elem.data('default'));
if (isNaN(val)) {
elem.val(default_val);
}
else if (min != undefined && val < min) {
elem.val(min);
}
else if (max != undefined && val > max) {
elem.val(max);
}
else {
elem.val(val);
}
}