This commit is contained in:
bel
2023-10-29 09:21:06 -06:00
parent a623dcc195
commit 227de17951
2 changed files with 22 additions and 6 deletions

View File

@@ -27,10 +27,12 @@ import (
//go:embed public/*
var _staticFileDir embed.FS
var staticFileDir = func() embed.FS {
panic("if dev mode then return live")
return _staticFileDir
}
var publicHandler = func() http.Handler {
if os.Getenv("DEBUG") != "" {
return http.FileServer(http.Dir("./http"))
}
return http.FileServer(http.FS(_staticFileDir))
}()
func Main() {
foo := flag.String("foo", "bal", "bal or reg")
@@ -65,7 +67,7 @@ func Main() {
if *httpOutput != "" {
foo := func(w http.ResponseWriter, r *http.Request) {
if !strings.HasPrefix(r.URL.Path, "/api") {
http.FileServer(http.FS(staticFileDir)).ServeHTTP(w, r)
publicHandler.ServeHTTP(w, r)
return
}

View File

@@ -37,6 +37,7 @@
var d = JSON.parse(body)
loadBalances(d.balances)
loadDeltas(d.deltas)
loadLastNLines(d.lastNLines)
})
}
function loadBalances(balances) {
@@ -68,6 +69,14 @@
result += `</table>`
document.getElementById("reg").innerHTML = result
}
function loadLastNLines(lastNLines) {
var result = `<textarea>`
for (var k in lastNLines) {
result += lastNLines[k] + "\n"
}
result += `</textarea>`
document.getElementById("lastNLines").innerHTML = result
}
</script>
</header>
<body onload="init();" style="min-width: 1024px;">
@@ -81,7 +90,12 @@
<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=YYYY-MM"></iframe>
</details>
</details>
<details open>
<details>
<summary>Edit</summary>
<div id="lastNLines">
</div>
</details>
<details>
<summary>Register</summary>
<div id="reg">
</div>