This commit is contained in:
Bel LaPointe
2021-09-07 16:07:51 -06:00
parent 3e9349078c
commit 0939bc0c41
2 changed files with 102 additions and 8 deletions

View File

@@ -136,22 +136,41 @@
}
http("put", "/api/transactions", () => {init()}, JSON.stringify(kvs))
}
function setRowKeyValue(row, wantkey, wantvalue) {
function getRowKeyValue(row, wantkey) {
const inputs = row.getElementsByTagName("td")
for (var i = 0; i < inputs.length; i++) {
const key = inputs[i].getAttribute("key")
if (key == wantkey) {
return inputs[i].innerText + ""
}
}
return null
}
function setRowKeyValues(row, wantKeysWantValues) {
const inputs = row.getElementsByTagName("td")
var kvs = {}
for (var i = 0; i < inputs.length; i++) {
const key = inputs[i].getAttribute("key")
if (key == wantkey) {
inputs[i].innerHTML = wantvalue
break
if (key in wantKeysWantValues) {
inputs[i].innerHTML = wantKeysWantValues[key]
}
}
saveTransaction(row)
}
zachsPayment = (x) => setRowKeyValue(x, "Payer", "AssetAccount:Zach")
belsPayment = (x) => setRowKeyValue(x, "Payer", "AssetAccount:Bel")
zachsCharge = (x) => setRowKeyValue(x, "Payee", "AssetAccount:Zach")
belsCharge = (x) => setRowKeyValue(x, "Payee", "AssetAccount:Bel")
zachsPayment = (x) => {
setRowKeyValues(x, {
"Payee": getRowKeyValue(x, "Payer"),
"Payer": "AssetAccount:Zach",
})
}
belsPayment = (x) => {
setRowKeyValues(x, {
"Payee": getRowKeyValue(x, "Payer"),
"Payer": "AssetAccount:Bel",
})
}
zachsCharge = (x) => setRowKeyValues(x, {"Payee": "AssetAccount:Zach"})
belsCharge = (x) => setRowKeyValues(x, {"Payee": "AssetAccount:Bel"})
function http(method, remote, callback, body) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {