From 47076b0833f3c777a55bddd99a2c65fef0f7a7ad Mon Sep 17 00:00:00 2001 From: William Lewis Date: Fri, 9 Jun 2023 06:59:54 -0500 Subject: [PATCH] Added CryptoCurrency table to budget site --- index.html | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index fd851d3..1e1c268 100644 --- a/index.html +++ b/index.html @@ -49,6 +49,9 @@

+ +
+
@@ -58,6 +61,7 @@ function main() { loadBudgetBalanceCheck(); + loadRecentCryptoCheck(); loadRecentTransactionsCheck(); } @@ -87,6 +91,33 @@ summation = Math.round(summation * 100) / 100; document.getElementById("sum").innerHTML = formatBalance(summation); } + + function addToCryptoTable(jsonData) { + let header = "" + + "Coin Name" + + "Coin Symbol" + + "Account Coin Balance" + + "Coin Current Price" + + "Account Value" + + "Number of Transactions" + + "" + + document.getElementById("crypto-table").innerHTML = header; + + for (const item of jsonData.body) { + + let row = ""; + row += "" + item.name + ""; + row += "" + item.symbol + ""; + row += "" + item.balance + ""; + row += "" + formatBalance(item.price_in_usd) + ""; + row += "" + formatBalance(item.balance_in_usd) + ""; + row += "" + item.number_of_transactions + ""; + row += ""; + + document.getElementById("crypto-table").innerHTML += row; + } + } function addToTransactionTable(jsonData) { let header = "" @@ -157,7 +188,7 @@ //maximumFractionDigits: 0, // (causes 2500.99 to be printed as $2,501) }); - console.log(formatter.format(num)); /* $2,500.00 */ + //console.log(formatter.format(num)); /* $2,500.00 */ let string = "" + prefix + formatter.format(num) + "" @@ -175,6 +206,17 @@ xhttp.send(); } + function loadRecentCryptoCheck() { + let value = null; + const xhttp = new XMLHttpRequest(); + xhttp.onload = function() { + addToCryptoTable(JSON.parse(this.responseText)) + }; + xhttp.open("GET", "https://n8n.veritablevalor.com/webhook/btc-check", true); + /*xhttp.setRequestHeader("access-control-allow-origin", "https://n8n.veritablevalor.com");*/ + xhttp.send(); + } + function loadRecentTransactionsCheck() { let value = null; const xhttp = new XMLHttpRequest(); @@ -185,6 +227,7 @@ /*xhttp.setRequestHeader("access-control-allow-origin", "https://n8n.veritablevalor.com");*/ xhttp.send(); } + //https://n8n.veritablevalor.com/webhook-test/btc-check //document.getElementById("budget-table").innerHTML = value;