Skip to content

Instantly share code, notes, and snippets.

@beber89
Created September 17, 2019 15:28
Show Gist options
  • Save beber89/6dd9fdce39505168741c0f244f0619c8 to your computer and use it in GitHub Desktop.
Save beber89/6dd9fdce39505168741c0f244f0619c8 to your computer and use it in GitHub Desktop.
renderer.go
// renderPage reloads elements of the page when change to wallet occurs
func RenderPage() {
wlt := *GetWallet()
document := js.Global().Get("document")
chainView := (*wlt.GetBlockchain()).Draw()
if chn := document.Call("getElementById", "chain"); chn != js.Null() {
document.Call("getElementById", "blockchain-placeholder").Call("removeChild", chn)
}
document.Call("getElementById", "blockchain-placeholder").Call("appendChild", chainView)
networthLabel := document.Call("getElementById", "networth")
networthLabel.Set("innerHTML", wlt.Networth())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment