Last active
June 16, 2019 15:23
-
-
Save wmohanlon/38b57a7cdad8a5ce21b3c804940cc606 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// ideas... Add realtime tracking plus path plotting | |
// turn it on and off by throwing URLs at it | |
// More fun | |
import ( | |
"fmt" | |
"log" | |
"net" | |
"net/http" | |
"os" | |
"strings" | |
"sync" | |
"time" | |
"github.com/zserge/webview" | |
) | |
var w webview.WebView | |
func tick() { | |
for { | |
time.Sleep(1 * time.Second) | |
// fmt.Println("Tick") | |
} | |
} | |
func webh(myw webview.WebView) { | |
ln, err := net.Listen("tcp", "127.0.0.1:9999") | |
if err != nil { | |
log.Fatal(err) | |
} | |
fmt.Println("opened localhost") | |
http.HandleFunc("/exit", func(w http.ResponseWriter, r *http.Request) { | |
os.Exit(0) | |
}) | |
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | |
message := r.URL.Path | |
message = strings.TrimPrefix(message, "/text=") | |
sendm := `document.getElementById("footer").innerHTML += "<br>` + message + `";` | |
myw.Dispatch(func() { | |
myw.Eval(sendm) | |
}) | |
}) | |
http.Serve(ln, nil) | |
fmt.Println("opened http") | |
} | |
func main() { | |
var wg sync.WaitGroup | |
var path string | |
wg.Add(1) | |
w = webview.New(webview.Settings{ | |
URL: "http://willymartini.com:8989/map2.html", | |
Width: 450, | |
Height: 800, | |
Resizable: true, | |
}) | |
go webh(w) | |
// w.Eval("document.getElementById('footer').innerHTML += '<br>';") | |
w.Eval(`dopath('` + path + `');`) | |
go tick() | |
w.Run() | |
wg.Wait() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment