move cmd into cmd/http as subcommand
All checks were successful
cicd / cicd (push) Successful in 44s
All checks were successful
cicd / cicd (push) Successful in 44s
This commit is contained in:
85
cmd/http/public/transactions.html
Normal file
85
cmd/http/public/transactions.html
Normal file
@@ -0,0 +1,85 @@
|
||||
<html>
|
||||
<header>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/dark.css">
|
||||
<script>
|
||||
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);
|
||||
}
|
||||
function callback(responseBody, responseStatus) {
|
||||
}
|
||||
var f = String(window.location).split("/transactions.html")[1]
|
||||
if (!f) {
|
||||
f = "/moolah.dat"
|
||||
}
|
||||
f = "." + f
|
||||
function init() {
|
||||
load(f)
|
||||
}
|
||||
function load(f) {
|
||||
http("GET", "/api/transactions?f="+f, (body, status) => {
|
||||
var d = JSON.parse(body)
|
||||
loadBalances(d.balances)
|
||||
loadDeltas(d.deltas)
|
||||
})
|
||||
}
|
||||
function loadBalances(balances) {
|
||||
var result = `<table>`
|
||||
for (var k in balances) {
|
||||
result += `<tr style="display: flex; flex-direction: row; width: 100%; justify-content: space-between;"><td>${k}</td><td>${Math.floor(balances[k]["$"])}</td></tr>`
|
||||
}
|
||||
result += `</table>`
|
||||
document.getElementById("bal").innerHTML = result
|
||||
}
|
||||
function loadDeltas(deltas) {
|
||||
console.log(deltas[0])
|
||||
for (var i = 0; i < deltas.length/2; i++) {
|
||||
tmp = deltas[i]
|
||||
deltas[i] = deltas[deltas.length-1-i]
|
||||
deltas[deltas.length-1-i] = tmp
|
||||
}
|
||||
console.log(deltas[0])
|
||||
var result = `<table>`
|
||||
for (var k of deltas) {
|
||||
result += `<tr>`
|
||||
result += ` <td>${k.Date}</td>`
|
||||
result += ` <td>${k.Description}</td>`
|
||||
result += ` <td>${k.Name}</td>`
|
||||
result += ` <td style="text-align: right">${k.Currency}</td>`
|
||||
result += ` <td style="text-align: right">${k.Value}</td>`
|
||||
result += `</tr>`
|
||||
}
|
||||
result += `</table>`
|
||||
document.getElementById("reg").innerHTML = result
|
||||
}
|
||||
</script>
|
||||
</header>
|
||||
<body onload="init();">
|
||||
<h2>Moolah2</h2>
|
||||
<details>
|
||||
<summary>Balance</summary>
|
||||
<div id="bal">
|
||||
</div>
|
||||
<details>
|
||||
<summary><i>Look at this graph</i></summary>
|
||||
<iframe style="background: white; width: 100%;" src="/api/reg?x=y&mode=reg&likeName=Withdrawal:[0123]&chart=stack&predictionMonths=6&prediction=autoContributions=&bpi=true&zoomStart=2023-01"></iframe>
|
||||
</details>
|
||||
</details>
|
||||
<details open>
|
||||
<summary>Register</summary>
|
||||
<div id="reg">
|
||||
</div>
|
||||
</details>
|
||||
</body>
|
||||
<footer>
|
||||
</footer>
|
||||
</html>
|
||||
Reference in New Issue
Block a user