This commit is contained in:
Logen
2025-03-21 03:54:35 -04:00
parent e20ee5031b
commit 41b4fd652f
4 changed files with 13 additions and 51 deletions

View File

@@ -53,6 +53,7 @@ body {
margin: auto;
padding: 10px;
padding-top: 10px;
box-sizing: border-box;
text-align: center;
background: var(--container-background);
@@ -64,6 +65,7 @@ body {
@media (max-width: 768px) {
.container {
max-width: 96%; /* Full width for mobile */
padding-top: 10px;
}
}

View File

@@ -1,43 +1,3 @@
// Fetch Bitcoin Price, Percentage Change, and Block Time
async function fetchBitcoinData() {
try {
// Fetch Bitcoin price and percentage change from CoinDesk API
const priceResponse = await fetch('https://api.coindesk.com/v1/bpi/currentprice.json');
if (!priceResponse.ok) {
throw new Error('Failed to fetch Bitcoin price');
}
const priceData = await priceResponse.json();
const price = parseFloat(priceData.bpi.USD.rate.replace(',', '')); // Remove commas
const percentageChange = Math.random() * 4 - 2; // Mock % change as CoinDesk doesn't provide it
const updatedAt = new Date(priceData.time.updatedISO).toLocaleString();
// Fetch block height (Mocked API)
const blockResponse = await fetch('https://mempool.space/api/blocks/tip/height');
if (!blockResponse.ok) {
throw new Error('Failed to fetch block height');
}
const blockHeight = await blockResponse.json();
// Update the banner
const banner = document.getElementById('btc-price-banner');
banner.innerHTML = `
<strong>$${price.toFixed(2)}</strong>
<span style="color: ${percentageChange >= 0 ? 'green' : 'red'};">
${percentageChange >= 0 ? '⬆' : '⬇'} ${percentageChange.toFixed(2)}%
</span>
| Block #${blockHeight}
`;
} catch (error) {
console.error('Error fetching Bitcoin data:', error);
document.getElementById('btc-price-banner').textContent = 'Unable to fetch Bitcoin data.';
}
}
// Refresh Bitcoin data every 60 seconds
fetchBitcoinData();
setInterval(fetchBitcoinData, 60000);
// Folder Toggle Function
function toggleFolder(folderId, buttonId) {
const folder = document.getElementById(folderId);