Files
satshkd-vercel/views/sats.hbs
Claude 94ea921567 Merge branch 'main' into claude/fix-graph-data-error-011CUxVZRUxivkQ8eJPnMLK2
Resolved conflicts:
- Removed convert_btcticker.js (deleted in main, generated data already)
- Kept EUR banknote background in views/sats.hbs for EUR branding
- Merged in all EU language support from main branch
2025-11-09 15:40:31 +00:00

267 lines
12 KiB
Handlebars

<head>
<title>EURSAT</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-wEmeIV1mKuiNpC+IOBjI7aAzPcEZeedi5yW5f2yOq55WWLwNGmvvx4Um1vskeMj0" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="/static/skeleton.css">
<link rel="stylesheet" type="text/css" href="/static/normalize.css">
<link rel="stylesheet" type="text/css" href="/static/metricsgraphics.css">
<link rel="shortcut icon" type="image/png" href="/static/favicon.png" />
<link href="https://fonts.googleapis.com/css?family=Open+Sans|Raleway&display=swap" rel="stylesheet">
<script src="/static/jquery.min.js"></script>
<script src="/static/d3.v4.min.js"></script>
<script src="/static/metricsgraphics.js"></script>
<script async src="https://analytics.umami.is/script.js" data-website-id="d35ba036-3531-422c-be04-74711c97799c"></script>
<!-- JavaScript Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-p34f1UUtsS3wqzfto5wAAmdvj+osOnFyQFpp4Ua3gs/ZVWx6oOypYoCJhGGScy+8" crossorigin="anonymous"></script>
<style>
#historical svg {
overflow: visible !important;
}
@media screen and (min-width: 393px) and (max-width: 393px) {
.mg-y-axis text {
transform: translateX(5px);
}
}
</style>
</head>
<body>
<header class="p-1 bg-dark text-white">
<nav class="navbar navbar-expand-lg navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="http://bitcoin.org.hk">
<img src="/static/bahk-logo-big-white.svg" alt="Bitcoin HK Logo" width="60">
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarText" aria-controls="navbarText" aria-expanded="true" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active px-2 text-secondary" aria-current="page" href="http://sats.bitcoin.org.hk">Sats</a>
</li>
<li class="nav-item">
<a class="nav-link px-2 text-white" href="http://blocks.bitcoin.org.hk">Blocks</a>
</li>
<li class="nav-item">
<a class="nav-link px-2 text-white" href="https://rates.bitcoin.org.hk">Rates</a>
</li>
<li class="nav-item">
<a class="nav-link px-2 text-white" href="http://stack.bitcoin.org.hk/">Stack</a>
</li>
<li class="nav-item">
<a class="nav-link px-2 text-white" href="https://laisee.org">Laisee</a>
</li>
</ul>
<span class="navbar-item" style="color: #fff">
<a class="px-2" href="{{ lang1_link }}" style="color: rgb(6, 168, 231)"> {{ lang1 }} </a>{{#if lang2}} | <a class="px-2" href="{{ lang2_link }}" style="color: rgb(6, 168, 231)"> {{ lang2 }}</a>{{/if}}{{#if lang3}} | <a class="px-2" href="{{ lang3_link }}" style="color: rgb(6, 168, 231)"> {{ lang3 }}</a>{{/if}}{{#if lang4}} | <a class="px-2" href="{{ lang4_link }}" style="color: rgb(6, 168, 231)"> {{ lang4 }}</a>{{/if}}{{#if lang5}} | <a class="px-2" href="{{ lang5_link }}" style="color: rgb(6, 168, 231)"> {{ lang5 }}</a>{{/if}}{{#if lang6}} | <a class="px-2" href="{{ lang6_link }}" style="color: rgb(6, 168, 231)"> {{ lang6 }}</a>{{/if}}{{#if lang7}} | <a class="px-2" href="{{ lang7_link }}" style="color: rgb(6, 168, 231)"> {{ lang7 }}</a>{{/if}}
</span>
</div>
</div>
</nav>
</header>
<div class="container" style="margin-top: 40px;">
<div class="row">
<center>
<h3> {{ Title }} <span id="current"></span> sats</h3>
</center>
<script>
var currentPrice = 0;
var ws_ticker_id, t;
document.addEventListener('DOMContentLoaded', function() {
startWebSocket();
}, false);
function startWebSocket() {
t = new WebSocket("wss://api-pub.bitfinex.com/ws/2");
t.onmessage = function(e) {
var i = JSON.parse(e.data);
if (i.event === 'subscribed' && i.channel == 'ticker') {
ws_ticker_id = i.chanId;
}
if (ws_ticker_id == i[0]) {
updatePrice(i);
}
}
t.onopen = function(e) {
console.log('Web socket open.');
t.send(JSON.stringify({
"event": "subscribe",
"channel": "ticker",
"symbol": "BTCUSD"
}));
setPingTimer();
}
t.onclose = function(e) {
console.log('Web socket closed. Attempting to reopen.');
setTimeout(function() {
startWebSocket();
}, 2000);
}
t.onerror = function(e) {
console.log(e);
}
}
function setPingTimer() {
setInterval(function() {
t.send("ping");
}, 10000);
}
function updatePrice(i) {
if (Array.isArray(i)) {
i.forEach(function(item) {
if (Array.isArray(item)) {
var btc_price = item[0];
currentPrice = Math.round((1 / btc_price) * 100000000 / {{ exchange_rate }}); // satoshis per currency unit
document.title = currentPrice.toLocaleString() + " sats";
document.querySelector('#current').textContent = currentPrice.toLocaleString();
}
});
}
}
</script>
<div id='historical'>
</div>
<div class="container">
<table class="u-full-width">
<thead>
<tr>
<th style="text-align:-webkit-left;font-size:2rem;">{{ date }} </th>
<th style="text-align:end;font-size:2rem;">{{ price }}&nbsp;&nbsp;</th>
<th style="text-align:end;font-size:2rem;white-space: pre;"> {{ percentchange }} </th>
</tr>
</thead>
<tbody>
{{#each yeardata}}
<tr>
<td style="text-align:-webkit-left">{{ this.year }}</td>
<td style="text-align:end">{{ this.sats }} sats </td>
<td style="text-align:end">{{ this.percent }} % </td>
</tr>
{{/each}}
</tbody>
</table>
<p style="font-size: small;">
* {{ footnote }}
</p>
</div>
<script>
d3.json('/{{ data_file }}', function(data) {
data = MG.convert.date(data, 'date');
var windowWidth = $(window).width();
if (windowWidth < 550) {
var graphHeight = windowWidth / 1.9047;
} else if (windowWidth < 1200) {
var graphHeight = windowWidth * 0.8 / 1.9047;
} else {
var graphHeight = 500;
}
console.log("graph height: " , graphHeight)
var qhLink = function() {
window.open('https://en.bitcoin.it/wiki/Controlled_supply', '_blank');
};
var qeLink = function() {
window.open('https://en.wikipedia.org/wiki/Quantitative_easing', '_blank');
};
var markers = [{
'date': new Date('2008-11-25T00:00:00.000Z'),
'label': 'QE1',
'click': qeLink,
}, {
'date': new Date('2010-11-03T00:00:00.000Z'),
'label': 'QE2',
'click': qeLink,
}, {
'date': new Date('2012-09-13T00:00:00.000Z'),
'label': 'QE3',
'click': qeLink,
}, {
'date': new Date('2012-11-28T00:00:00.000Z'),
'label': 'QH1',
'click': qhLink,
}, {
'date': new Date('2016-07-09T00:00:00.000Z'),
'label': 'QH2',
'click': qhLink,
}, {
'date': new Date('2019-10-11T00:00:00.000Z'),
'label': 'QE4',
'click': qeLink,
}, {
'date': new Date('2020-05-11T00:00:00.000Z'),
'label': 'QH3',
'click': qhLink,
}];
MG.data_graphic({
title: '{{ subtitle }}',
data: data,
full_width: true,
height: graphHeight,
left: 0,
area: true,
color: '#FF9900',
markers: markers,
target: document.getElementById('historical'),
xax_count: 16,
yax_count: 12,
x_accessor: 'date',
y_accessor: '{{ rate_field }}',
y_scale_type: 'log',
y_extended_ticks: true,
yax_units: ' sats',
yax_units_append: true,
max_y: 1000000000,
});
$(document).ready(function() {
d3.select('svg')
.data(data)
.append('defs')
.append('pattern')
.attr('id', 'losermoney')
.attr('patternUnits', 'userSpaceOnUse')
.attr('width', '100%')
.attr('height', '100%')
.append('image')
.attr('width', '100%')
.attr('height', '100%')
.attr('xlink:href', 'https://ena.our-dogs.info/download.php?w=1280&h=720&img=https://c8.alamy.com/comp/CWNN3M/one-100-euro-banknote-one-hundred-euro-european-currency-isolated-CWNN3M.jpg');
$('svg path')
.css('opacity', 1)
.css('stroke', 'green')
.attr('fill', 'url(#losermoney)');
});
});
</script>
</body>