1
0
mirror of https://github.com/taigrr/wasm-experiments synced 2025-01-18 04:03:21 -08:00

Update to go binary

This commit is contained in:
Johan Brandhorst
2018-10-14 15:31:09 +01:00
parent fc4b173370
commit 5a07f70561
4 changed files with 27 additions and 22 deletions

View File

@@ -7,23 +7,28 @@ import (
"log"
"net/http"
"strings"
"github.com/dennwc/dom"
"syscall/js"
)
type writer dom.Element
var document js.Value
func init() {
document = js.Global().Get("document")
}
type writer js.Value
// Write implements io.Writer.
func (d writer) Write(p []byte) (n int, err error) {
node := dom.GetDocument().CreateElement("div")
node.SetTextContent(string(p))
(*dom.Element)(&d).AppendChild(node)
node := document.Call("createElement", "div")
node.Set("textContent", string(p))
js.Value(d).Call("appendChild", node)
return len(p), nil
}
func main() {
t := dom.GetDocument().GetElementById("target")
logger := log.New((*writer)(t), "", log.LstdFlags)
t := document.Call("getElementById", "target")
logger := log.New((*writer)(&t), "", log.LstdFlags)
c := http.Client{}
req, err := http.NewRequest(