Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update index.html #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
212 changes: 69 additions & 143 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@
</li>
<li>
<div class="tags has-addons has-addons-centered"style="border-style: solid; border-width: 2px; border-color:#FF3860;">
<span class="tag is-large is-size-6" style="width: 100%;">Zcash</span>
<span class="tag is-large is-danger is-size-6" style="width: 100%;">t1ef9cxzpToGJcaSMXbTGRUDyrp76GfDLJG</span>
<span class="tag is-large is-size-6" style="width: 100%;">Binance</span>
<span class="tag is-large is-danger is-size-6" style="width: 100%;">0xd9fa5b8480dfc2a86488eaf500d729dd26dda981</span>
</div>
</li>
<li>
Expand Down Expand Up @@ -181,42 +181,42 @@
<div>
<p class="heading">BITCOINZ PRICE</p>
<p id="btczUsd">Loading...</p>
<p>BTCZ: <span id="btczBalance"></span></p>
<p><span id="btczBalance"></span></p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">ETHEREUM PRICE</p>
<p id="ethUsd">Loading...</p>
<p>ETH: <span id="ethBalance"></span></p>
<p><span id="ethBalance"></span></p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">BITCOIN PRICE</p>
<p id="btcUsd">Loading...</p>
<p>BTC: <span id="btcBalance"></span></p>
<p><span id="btcBalance"></span></p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">ZCASH PRICE</p>
<p id="zecUsd">Loading...</p>
<p>ZEC: <span id="zecBalance"></span></p>
<p class="heading">BINANCE PRICE</p>
<p id="bnbUsd">Loading...</p>
<p><span id="bnbBalance"></span></p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">LITECOIN PRICE</p>
<p id="ltcUsd">Loading...</p>
<p>LTC: <span id="ltcBalance"></span></p>
<p><span id="ltcBalance"></span></p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">USDT PRICE</p>
<p id="USDTEUsd">Loading...</p>
<p>USDT: <span id="USDTEBalance"></span></p>
<p><span id="USDTEBalance"></span></p>

</div>
</div>
Expand All @@ -234,145 +234,71 @@
<script type="text/javascript">
var goal = 15000; // donation goal in USD
var current = 0; // current chest value

var formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
minimumFractionDigits: 2,
style: 'currency',
currency: 'USD',
minimumFractionDigits: 2,
});

var formatterBtcz = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
minimumFractionDigits: 8,
style: 'currency',
currency: 'USD',
minimumFractionDigits: 8,
});

function updateData() {
$('#goal').html(formatter.format(goal));
$('#progress').attr('max', goal);
$('#icon').addClass('fa-spin');
$('#icon').attr('title', "Refreshing...");

$.getJSON("api.php", function(data) {
// Update BTCZ USD price
if (data.btczBalance !== undefined) {
$('#btczBalance').html(data.btczBalance + " BTCZ");
} else {
$('#btczBalance').html('Error');
}

if (data.ethBalance !== undefined) {
$('#ethBalance').html(data.ethBalance + " ETH");
} else {
$('#ethBalance').html('Error');
}

if (data.btcBalance !== undefined) {
$('#btcBalance').html(data.btcBalance + " BTC");
} else {
$('#btcBalance').html('Error');
}

if (data.zecBalance !== undefined) {
$('#zecBalance').html(data.zecBalance + " ZEC");
} else {
$('#zecBalance').html('Error');
}

if (data.ltcBalance !== undefined) {
$('#ltcBalance').html(data.ltcBalance + " LTC");
} else {
$('#ltcBalance').html('Error');
}

if (data.USDTEBalance !== undefined) {
$('#USDTEBalance').html(data.USDTEBalance + " USDT");
} else {
$('#USDTEBalance').html('Error');
}



if(data.btczUsd && !data.btczUsd.error) {
$('#btczUsd').html(formatterBtcz.format(data.btczUsd.value));
} else {
$('#btczUsd').html('Error');
}

// Update ETH USD price
if(data.ethUsd && !data.ethUsd.error) {
$('#ethUsd').html(formatter.format(data.ethUsd.value));
} else {
$('#ethUsd').html('Error');
}

// Update BTC USD price
if(data.btcUsd && !data.btcUsd.error) {
$('#btcUsd').html(formatter.format(data.btcUsd.value));
} else {
$('#btcUsd').html('Error');
}

// Update ZEC USD price
if(data.zecUsd && !data.zecUsd.error) {
$('#zecUsd').html(formatter.format(data.zecUsd.value));
} else {
$('#zecUsd').html('Error');
}

// Update LTC USD price
if(data.ltcUsd && !data.ltcUsd.error) {
$('#ltcUsd').html(formatter.format(data.ltcUsd.value));
} else {
$('#ltcUsd').html('Error');
}

// Update USDT USD price
if(data.USDTEUsd && !data.USDTEUsd.error) {
$('#USDTEUsd').html(formatter.format(data.USDTEUsd.value));
} else {
$('#USDTEUsd').html('Error');
}

var current = 0;
if(data.btczUsd && !data.btczUsd.error) {
current += data.btczBalance * data.btczUsd.value;
}
if(data.ethUsd && !data.ethUsd.error) {
current += data.ethBalance * data.ethUsd.value;
}
if(data.btcUsd && !data.btcUsd.error) {
current += data.btcBalance * data.btcUsd.value;
}
if(data.zecUsd && !data.zecUsd.error) {
current += data.zecBalance * data.zecUsd.value;
}
if(data.ltcUsd && !data.ltcUsd.error) {
current += data.ltcBalance * data.ltcUsd.value;
}
if(data.USDTEUsd && !data.USDTEUsd.error) {
current += data.USDTEBalance * data.USDTEUsd.value;
}


$('#current').html(formatter.format(current));
$('#progress').attr('value', current);
$('#progress').html(current + '%');
})
.fail(function(jqxhr, textStatus, error) {
alert('Error loading price data!');
})
.done(function() {
$('#icon').removeClass('fa-spin');
$('#icon').attr('title', "Refreshed every minute.");
});
}

$('#goal').html(formatter.format(goal));
$('#progress').attr('max', goal);
$('#icon').addClass('fa-spin');
$('#icon').attr('title', "Refreshing...");

$.getJSON("api.php", function(data) {
// Update balances and prices
$('#btczBalance').html(data.btczBalance !== undefined ? data.btczBalance + " BTCZ" : 'Error');
$('#ethBalance').html(data.ethBalance !== undefined ? data.ethBalance + " ETH" : 'Error');
$('#btcBalance').html(data.btcBalance !== undefined ? data.btcBalance + " BTC" : 'Error');
$('#bnbBalance').html(data.bnbBalance !== undefined ? data.bnbBalance + " BNB" : 'Error');
$('#ltcBalance').html(data.ltcBalance !== undefined ? data.ltcBalance + " LTC" : 'Error');
$('#USDTEBalance').html(data.USDTEBalance !== undefined ? data.USDTEBalance + " USDT" : 'Error');

// Update cryptocurrency prices
$('#btczUsd').html(data.btczUsd && !data.btczUsd.error ? formatterBtcz.format(data.btczUsd.value) : 'Error');
$('#ethUsd').html(data.ethUsd && !data.ethUsd.error ? formatter.format(data.ethUsd.value) : 'Error');
$('#btcUsd').html(data.btcUsd && !data.btcUsd.error ? formatter.format(data.btcUsd.value) : 'Error');
$('#bnbUsd').html(data.bnbUsd && !data.bnbUsd.error ? formatter.format(data.bnbUsd.value) : 'Error');
$('#ltcUsd').html(data.ltcUsd && !data.ltcUsd.error ? formatter.format(data.ltcUsd.value) : 'Error');
$('#USDTEUsd').html(data.USDTEUsd && !data.USDTEUsd.error ? formatter.format(data.USDTEUsd.value) : 'Error');

// Calculate and update the current total value
current = 0;
if(data.btczUsd && !data.btczUsd.error) current += data.btczBalance * data.btczUsd.value;
if(data.ethUsd && !data.ethUsd.error) current += data.ethBalance * data.ethUsd.value;
if(data.btcUsd && !data.btcUsd.error) current += data.btcBalance * data.btcUsd.value;
if(data.bnbUsd && !data.bnbUsd.error) current += data.bnbBalance * data.bnbUsd.value;
if(data.ltcUsd && !data.ltcUsd.error) current += data.ltcBalance * data.ltcUsd.value;
if(data.USDTEUsd && !data.USDTEUsd.error) current += data.USDTEBalance * data.USDTEUsd.value;

$('#current').html(formatter.format(current));
$('#progress').attr('value', current);
$('#progress').html(current + '%');
})
.fail(function() {
alert('Error loading price data!');
})
.always(function() {
$('#icon').removeClass('fa-spin');
$('#icon').attr('title', "Refreshed every minute.");
});
}

// Initial call to update data
updateData();
setInterval(updateData, 1000 * 60); // update every minute

</script>


// Set an interval to update data periodically (e.g., every 5 minutes)
//setInterval(updateData, 1000 * 60 * 5);
</script>

</body>
</html>