master
bel 2021-08-01 01:33:51 -06:00
parent eaad03281c
commit 34101fa811
3 changed files with 79 additions and 0 deletions

60
public/index.html Normal file
View File

@ -0,0 +1,60 @@
<html>
<header>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/dark.css">
<script>
function init() {
http("get", "/ledger.json", (body, status) => {
body = JSON.parse(body)
loadTransactions(body.Transactions)
}, null)
}
function loadTransactions(transactions) {
if (transactions.length < 1) {
return
}
var innerHTML = ""
var keys = []
innerHTML += "<tr>"
innerHTML += "<th>" + "idx" + "</th>"
for(const key in transactions[0]) {
innerHTML += "<th>" + key + "</th>"
keys.push(key)
}
innerHTML += "</tr>"
for(var i in transactions) {
const transaction = transactions[i]
innerHTML += "<tr>"
innerHTML += "<th>" + i + "</th>"
for(var key of keys) {
innerHTML += "<td>" + transaction[key] + "</td>"
}
innerHTML += "</tr>"
}
document.getElementById("transactions").innerHTML = innerHTML
}
function http(method, remote, callback, body) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == XMLHttpRequest.DONE) {
callback(xmlhttp.responseText, xmlhttp.status)
}
};
xmlhttp.open(method, remote, true);
if (typeof body == "undefined") {
body = null
}
xmlhttp.send(body);
}
</script>
</header>
<body onload="init()">
<h1>hi</h1>
<table id="transactions">
</table>
</body>
<footer>
</footer>
</html>

1
public/ledger.json Symbolic link
View File

@ -0,0 +1 @@
../testdata/ledger.json

18
testdata/ledger.json vendored Normal file
View File

@ -0,0 +1,18 @@
{
"Transactions": [
{
"Date": "2021-07-29",
"Description": "Qt needs pizza n kodiak",
"Payer": "Debts:Credit:ChaseAarpChaseVisa",
"Payee": "Withdrawal:Home:Grocery+Resturaunt:Target",
"Amount": 37.86
},
{
"Date": "2021-07-30",
"Description": "Testing detecting deposits via email alerts 5421705162",
"Payer": "AssetAccount:Cash:Uccu",
"Payee": "Debts:Credit:ChaseAarpChaseVisa",
"Amount": 100.00
}
]
}