added sats to $ Calc to the app

This commit is contained in:
0ceanSlim 2023-08-08 20:47:00 -04:00
parent 9303a38edb
commit 113a320850
5 changed files with 67 additions and 3 deletions

View File

@ -11,8 +11,8 @@ android {
applicationId = "com.example.satsmonitor"
minSdk = 24
targetSdk = 33
versionCode = 2
versionName = "0.1.41"
versionCode = 3
versionName = "0.1.5"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

View File

@ -40,6 +40,15 @@
</body>
<div class="satstodollars">
<h1>Sats to $'s Calc</h1>
<label for="sats-input">Enter the amount of Bitcoin in satoshis:</label>
<br>
<input type="number" id="sats-input">
<br>
<output id="dollars-output"></output>
</div>
<!--<div class="affiliates">
<div class="affiliate1"><a href="https://www.swanbitcoin.com/oceanslim"><img src="file:///android_asset/images/swan.png"> Dollar Cost Average Bitcoin with Swan!<br/>Free Automated withdrawal </a></div>
<div class="affiliate2"><a href="https://store.blockstream.com/?ref=3322"><img src="file:///android_asset/images/blockstream.jpg"> Shop Blockstream's Store (use code "HAPPYTAVERN" for 10% off Jade HW Wallet) </a></div>

View File

@ -0,0 +1,19 @@
fetch('https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd')
.then(response => response.json())
.then(data => {
const bitcoinPrice = data['bitcoin']['usd'];
const satoshisToDollars = (satoshis) => {
const bitcoinAmount = satoshis / 100000000;
const dollarsAmount = bitcoinAmount * bitcoinPrice;
return dollarsAmount.toFixed(2);
};
const satoshisInputElement = document.getElementById('sats-input');
const dollarsOutputElement = document.getElementById('dollars-output');
// Listen for changes to the satoshis input and update the dollars output
satoshisInputElement.addEventListener('input', (event) => {
const satoshis = event.target.value;
const dollars = satoshisToDollars(satoshis);
dollarsOutputElement.textContent = `$${dollars}`;
});
})
.catch(error => console.error(error));

View File

@ -73,6 +73,30 @@ a:hover {
margin: 10px;
}
.satstodollars {
width: auto;
margin-left: 20px;
margin-right: 20px;
margin-top: 20px;
background-color: #282828;
border: 3px solid #ccc;
border-radius: 8px;
padding: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
align-items: center; /* Center items vertically within the container */
justify-content: center; /* Center items horizontally within the container */
}
#sats-input {
font-size: 16px;
border-radius: 7px;
font-family: monospace;
font-style: bold;
color: rgb(196, 140, 0);
margin-right: 5px;
padding-right: 5px;
}
/*.affiliates {
max-width: 60%;
max-height: 25%;

View File

@ -35,7 +35,7 @@ class MainActivity : AppCompatActivity() {
}
// Load the JavaScript code from the "script.js" file
val javaScriptCode = try {
val firstScript = try {
assets.open("script.js").bufferedReader().use { it.readText() }
} catch (e: IOException) {
e.printStackTrace()
@ -43,6 +43,18 @@ class MainActivity : AppCompatActivity() {
""
}
// Load the content of the second script file
val secondScript = try {
assets.open("script2.js").bufferedReader().use { it.readText() }
} catch (e: IOException) {
e.printStackTrace()
// If loading the second script fails, set an empty script
""
}
// Combine the content of both scripts
val javaScriptCode = "$firstScript\n$secondScript"
// Load the CSS code from the "style.css" file
val cssCode = try {
assets.open("style.css").bufferedReader().use { it.readText() }