2023-11-17 01:05:35 +01:00
|
|
|
<script lang="ts">
|
2023-11-19 20:27:22 +01:00
|
|
|
export let status = {};
|
2024-07-29 20:10:26 +02:00
|
|
|
import RocketIcon from '../icons/RocketIcon.svelte';
|
|
|
|
import PickaxeIcon from '../icons/PickaxeIcon.svelte';
|
2024-08-31 15:37:20 +02:00
|
|
|
import ZapIcon from '../icons/ZapIcon.svelte';
|
2023-11-17 01:05:35 +01:00
|
|
|
|
2023-11-19 20:27:22 +01:00
|
|
|
const isSplitText = (str: string) => {
|
|
|
|
return str.includes('/');
|
|
|
|
};
|
2024-08-31 17:10:26 +02:00
|
|
|
|
|
|
|
export let className = 'btclock-wrapper';
|
2024-12-18 00:45:26 +01:00
|
|
|
export let verticalDesc = false;
|
2024-09-05 01:59:05 +02:00
|
|
|
// Define the currency symbols as constants
|
|
|
|
const CURRENCY_USD = '$';
|
|
|
|
const CURRENCY_EUR = '[';
|
|
|
|
const CURRENCY_GBP = ']';
|
|
|
|
const CURRENCY_JPY = '^';
|
|
|
|
const CURRENCY_AUD = '_';
|
|
|
|
//const CURRENCY_CHF = '_';
|
|
|
|
const CURRENCY_CAD = '`';
|
|
|
|
|
|
|
|
function getCurrencySymbol(input: string): string {
|
|
|
|
// Split the string into an array of characters to process each one
|
|
|
|
return input
|
|
|
|
.split('')
|
|
|
|
.map((char) => {
|
|
|
|
switch (char) {
|
|
|
|
case CURRENCY_EUR:
|
|
|
|
return '€'; // Euro symbol
|
|
|
|
case CURRENCY_GBP:
|
|
|
|
return '£'; // Pound symbol
|
|
|
|
case CURRENCY_JPY:
|
|
|
|
return '¥'; // Yen symbol
|
|
|
|
case CURRENCY_AUD:
|
|
|
|
case CURRENCY_CAD:
|
|
|
|
case CURRENCY_USD:
|
|
|
|
return '$'; // Dollar symbol
|
|
|
|
default:
|
|
|
|
return char; // Return the original character if no match
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.join(''); // Join the array back into a string
|
|
|
|
}
|
2023-11-17 01:05:35 +01:00
|
|
|
</script>
|
|
|
|
|
2024-08-31 17:18:26 +02:00
|
|
|
<div class={className} id={className}>
|
2024-12-18 00:45:26 +01:00
|
|
|
<div class={'btclock' + (verticalDesc ? ' verticalDesc' : '')}>
|
2023-11-19 20:27:22 +01:00
|
|
|
{#each status.data as char}
|
|
|
|
{#if isSplitText(char)}
|
|
|
|
<div class="splitText">
|
2024-12-18 00:45:26 +01:00
|
|
|
<div class="textcontainer">
|
|
|
|
{#if char.split('/').length}
|
|
|
|
<span class="top-text">{char.split('/')[0]}</span>
|
|
|
|
<span class="bottom-text">{char.split('/')[1]}</span>
|
|
|
|
{/if}
|
|
|
|
</div>
|
2024-08-31 17:10:26 +02:00
|
|
|
<!-- {#each char.split('/') as part}
|
2023-11-19 20:27:22 +01:00
|
|
|
<div class="flex-items">{part}</div>
|
2024-08-31 17:10:26 +02:00
|
|
|
{/each} -->
|
2023-11-19 20:27:22 +01:00
|
|
|
</div>
|
2024-07-29 20:10:26 +02:00
|
|
|
{:else if char.startsWith('mdi')}
|
2024-12-18 01:24:21 +01:00
|
|
|
<div class={'digit icon' + (char.endsWith('bitaxe') ? ' icon-img' : '')}>
|
2024-07-29 20:10:26 +02:00
|
|
|
{#if char.endsWith('rocket')}
|
|
|
|
<RocketIcon></RocketIcon>
|
|
|
|
{/if}
|
|
|
|
{#if char.endsWith('pickaxe')}
|
|
|
|
<PickaxeIcon></PickaxeIcon>
|
|
|
|
{/if}
|
2024-08-31 15:37:20 +02:00
|
|
|
{#if char.endsWith('bolt')}
|
|
|
|
<ZapIcon></ZapIcon>
|
|
|
|
{/if}
|
2024-12-18 01:24:21 +01:00
|
|
|
{#if char.endsWith('bitaxe')}
|
|
|
|
<img src="/bitaxe.webp" class="bitaxelogo" />
|
|
|
|
{/if}
|
2024-07-29 20:10:26 +02:00
|
|
|
</div>
|
2024-03-10 12:21:25 +01:00
|
|
|
{:else if char === 'STS'}
|
2024-08-31 15:37:20 +02:00
|
|
|
<div class="digit sats">S</div>
|
2023-11-25 00:42:37 +01:00
|
|
|
{:else if char.length >= 3}
|
|
|
|
<div class="mediumText">{char}</div>
|
2023-11-19 20:27:22 +01:00
|
|
|
{:else if char.length === 0 || char === ' '}
|
|
|
|
<div class="digit"> </div>
|
|
|
|
{:else}
|
2024-09-05 01:59:05 +02:00
|
|
|
<div class="digit">{getCurrencySymbol(char)}</div>
|
2023-11-19 20:27:22 +01:00
|
|
|
{/if}
|
|
|
|
{/each}
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-07-29 20:10:26 +02:00
|
|
|
|
2024-12-18 01:24:21 +01:00
|
|
|
<style lang="scss">
|
2024-07-29 20:10:26 +02:00
|
|
|
.icon {
|
|
|
|
fill: currentColor;
|
|
|
|
}
|
2024-12-18 01:24:21 +01:00
|
|
|
|
|
|
|
.btclock-wrapper .btclock .icon.icon-img {
|
|
|
|
// padding: 0 15px;
|
|
|
|
aspect-ratio: 1;
|
|
|
|
width: calc(100 / 7);
|
|
|
|
|
|
|
|
img {
|
|
|
|
max-width: 95%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.bitaxelogo {
|
|
|
|
transform: rotate(-90deg);
|
|
|
|
}
|
2024-07-29 20:10:26 +02:00
|
|
|
</style>
|