You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.9 KiB
63 lines
1.9 KiB
//- common routines for all views everywhere
|
|
|
|
include button-icon
|
|
include labeled-icon
|
|
include section-title
|
|
|
|
-
|
|
function formatCount(value) {
|
|
value = value || 0;
|
|
return (value < 1000) ? numeral(value).format('0,0') : numeral(value).format('0,0.0a');
|
|
}
|
|
|
|
function formatBitRate (value) {
|
|
if ((value !== 0) && !value) { return '---'; }
|
|
return numeral(value).format('0,0.0ib').slice(0, -2) + 'bps';
|
|
}
|
|
|
|
function formatDataSize (value) {
|
|
if ((value !== 0) && !value) { return '---'; }
|
|
return numeral(value).format('0,0.0b');
|
|
}
|
|
|
|
function formatTimestamp (value, withFractional = false) {
|
|
if (value !== 0 && !value) {
|
|
return withFractional ? '-:--:--.---' : '-:--:--';
|
|
}
|
|
return numeral(value).format(withFractional ? 'h:mm:ss.sss' : 'h:mm:ss');
|
|
}
|
|
|
|
function formatDuration (value) {
|
|
let duration = formatTimestamp(value);
|
|
if (duration.startsWith('0:')) { duration = duration.slice(2); }
|
|
if (duration.startsWith('0')) { duration = duration.slice(1); }
|
|
return duration;
|
|
}
|
|
|
|
function displayIntegerValue (value) {
|
|
return numeral(value).format(value > 1000 ? '0,0.0a' : '0,0');
|
|
}
|
|
|
|
function getUserProfileUrl (user) {
|
|
if (user.core) {
|
|
return `/user/core/${user._id}`;
|
|
}
|
|
return `/user/${user._id}`;
|
|
}
|
|
|
|
mixin renderCell (label, value, className)
|
|
div(title=`${label}: ${numeral(value).format('0,0')}`).uk-tile.uk-tile-default.uk-padding-remove.no-select
|
|
div(class=className)!= value
|
|
.uk-text-muted.uk-text-small= label
|
|
|
|
mixin renderBackButton ( )
|
|
button(type="button", onclick="window.history.back();").uk-button.uk-button-default
|
|
span
|
|
i.fas.fa-chevron-left
|
|
span(class="uk-visible@s").uk-margin-small-left Back
|
|
|
|
mixin renderUserLink (user)
|
|
if user.coreUserId
|
|
a(href=`/user/core/${user._id}`)= `${user.username}@${user.core.meta.domainKey}`
|
|
else
|
|
a(href=`/user/${user._id}`)= user.displayName || user.username
|