logo showing!

This commit is contained in:
0ceanSlim 2023-07-30 11:30:38 -04:00
parent 81f8b6d8aa
commit 39ca1e5eb1
5 changed files with 50 additions and 5 deletions

View File

@ -6,9 +6,12 @@
</head>
<body>
<div class="bitcointodollars">
<h1>Bitcoin Price Tracker</h1>
<div class="container">
<span class="bitcoin-logo">
<img src='file:///android_asset/logo.png' alt='BTC' />
</span>
<div id="bitcoin-price"></div>
<div id="dollars-to-sats"></div>
</div>
</body>

View File

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

View File

@ -5,6 +5,20 @@ fetch('https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=u
const bitcoinPrice = data['bitcoin']['usd'];
// Update the Bitcoin price on the website
const bitcoinPriceElement = document.getElementById('bitcoin-price');
bitcoinPriceElement.textContent = '1 BTC = $' + bitcoinPrice.toFixed(2); // Display the Bitcoin price
// Format the Bitcoin price with a comma after every three digits and no decimals
const formattedPrice = '$' + bitcoinPrice.toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 0 });
bitcoinPriceElement.textContent = formattedPrice; // Display the formatted Bitcoin price
// Calculate dollars to sats
const dollarsToSatsElement = document.getElementById('dollars-to-sats');
const satsConversionFactor = 100000000; // 1 bitcoin = 100 million sats
// Calculate how many sats you can get for 1 dollar based on the fetched Bitcoin price
const dollars = 1;
const sats = (1 / bitcoinPrice) * satsConversionFactor;
dollarsToSatsElement.textContent = `$1.00 = ${sats.toFixed(0)} sats`; // Display the result
})
.catch(error => console.error(error));
.catch(error => console.error(error));

View File

@ -11,7 +11,7 @@ body {
text-align: center;
}
.bitcointodollars {
.container {
width: auto;
margin-left: 20px;
margin-right: 20px;
@ -28,6 +28,31 @@ h1 {
}
#bitcoin-price {
display: flex;
align-items: center;
justify-content: center;
font-size: 24px;
font-weight: bold;
text-align: center;
margin: 10px;
}
.bitcoin-logo {
height: 28px;
/* Adjust this to match the font size of the Bitcoin price */
width: 28px;
margin-right: 5px;
/* Add some space between the logo and the price */
}
.bitcoin-logo img {
height: 36px;
/* Adjust this to match the font size of the Bitcoin price */
width: 36px;
/* Add some space between the logo and the price */
}
#dollars-to-sats {
font-size: 24px;
font-weight: bold;
text-align: center;

View File

@ -65,6 +65,9 @@ val finalHtmlContent = """
</html>
""".trimIndent()
// Define the base URL for resolving relative paths (e.g., image source)
val baseUrl = "file:///android_asset/"
webView.loadDataWithBaseURL(null, finalHtmlContent, "text/html", "UTF-8", null)
}
}