2022-12-24 11:37:02 +01:00
|
|
|
<script>
|
2025-03-28 14:16:20 +01:00
|
|
|
import { formatDataVolume } from "util/Formatting";
|
|
|
|
import { stats } from "lib/StatsSocket"
|
2022-12-24 11:37:02 +01:00
|
|
|
|
|
|
|
let percent = 0
|
|
|
|
let title = ""
|
|
|
|
$: {
|
2025-03-27 12:52:45 +01:00
|
|
|
if ($stats.limits_init === true) {
|
|
|
|
if ($stats.limits.transfer_limit === 0) {
|
|
|
|
percent = 0 // Avoid division by 0
|
|
|
|
} else if ($stats.limits.transfer_limit_used / $stats.limits.transfer_limit > 1) {
|
|
|
|
percent = 100
|
|
|
|
} else {
|
|
|
|
percent = ($stats.limits.transfer_limit_used / $stats.limits.transfer_limit) * 100
|
|
|
|
}
|
2022-12-24 11:37:02 +01:00
|
|
|
|
2025-03-27 12:52:45 +01:00
|
|
|
title = "Download limit used: " +
|
|
|
|
formatDataVolume($stats.limits.transfer_limit_used, 3) +
|
|
|
|
" of " +
|
|
|
|
formatDataVolume($stats.limits.transfer_limit, 3);
|
|
|
|
}
|
2022-12-24 11:37:02 +01:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2023-09-18 22:43:12 +02:00
|
|
|
<!-- Always show the outer bar to prevent layout shift -->
|
|
|
|
<div class="progress_bar_outer" title="{title}">
|
2024-04-25 14:50:42 +02:00
|
|
|
{#if $stats.limits_init}
|
2023-01-11 19:23:02 +01:00
|
|
|
<div class="progress_bar_text">
|
|
|
|
{title}
|
|
|
|
</div>
|
2022-12-24 11:37:02 +01:00
|
|
|
<div class="progress_bar_inner" style="width: {percent}%;">
|
2023-01-11 19:23:02 +01:00
|
|
|
{title}
|
2022-12-24 11:37:02 +01:00
|
|
|
</div>
|
2023-09-18 22:43:12 +02:00
|
|
|
{/if}
|
|
|
|
</div>
|
2022-12-24 11:37:02 +01:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.progress_bar_outer {
|
2023-01-11 19:23:02 +01:00
|
|
|
position: relative;
|
2022-12-24 11:37:02 +01:00
|
|
|
display: block;
|
|
|
|
width: 100%;
|
2023-01-11 19:23:02 +01:00
|
|
|
/* the font-size is two pixels smaller than the progress bar, this leaves
|
|
|
|
one px margin top and bottom */
|
2024-12-27 11:46:21 +01:00
|
|
|
height: 18px;
|
|
|
|
font-size: 15px;
|
|
|
|
line-height: 18px;
|
2022-12-24 11:37:02 +01:00
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
.progress_bar_inner {
|
2023-01-11 19:23:02 +01:00
|
|
|
position: absolute;
|
|
|
|
display: block;
|
2022-12-24 11:37:02 +01:00
|
|
|
background: var(--highlight_background);
|
|
|
|
height: 100%;
|
|
|
|
width: 0;
|
|
|
|
transition: width 5s linear;
|
2023-01-11 19:23:02 +01:00
|
|
|
|
|
|
|
/* Welcome to Hacktown! What's happening here is that the text in the
|
|
|
|
progress bar and the text behind the progress bar are perfectly aligned. The
|
|
|
|
text in the background is dark and the text on the foreground is light, this
|
|
|
|
makes it look like the text changes colour as the progress bar progresses.
|
|
|
|
The text-align: right makes the text move along with the tip of the progress
|
|
|
|
bar once the width of the text has been exceeded. */
|
|
|
|
text-align: right;
|
|
|
|
overflow: hidden;
|
|
|
|
white-space: nowrap;
|
|
|
|
color: var(--highlight_text_color);
|
|
|
|
padding-right: 4px;
|
|
|
|
padding-left: 4px;
|
|
|
|
z-index: 2;
|
|
|
|
}
|
|
|
|
.progress_bar_text {
|
|
|
|
position: absolute;
|
|
|
|
display: block;
|
|
|
|
top: 0;
|
|
|
|
left: 4px;
|
|
|
|
z-index: 1;
|
2022-12-24 11:37:02 +01:00
|
|
|
}
|
|
|
|
</style>
|