Skip to content

Instantly share code, notes, and snippets.

@lazyhacker
Created June 11, 2018 04:41
Show Gist options
  • Save lazyhacker/bfc97fefbbb270cdee53b38a85925d48 to your computer and use it in GitHub Desktop.
Save lazyhacker/bfc97fefbbb270cdee53b38a85925d48 to your computer and use it in GitHub Desktop.
func cbRunIvy(e js.Value) {
window := browser.GetWindow()
if e.Get("keyCode").Int() == 13 {
express := window.Document.GetElementById("expression")
expr := express.Value()
res, err := mobile.Eval(expr)
if err != nil {
window.Console.Warn(err.Error())
return
}
element := window.Document.GetElementById("ivy-out")
content := element.InnerHTML()
element.SetInnerHTML(content + "> " + expr + "<br/>" + res + "<br/>")
express.SetValue("")
window.ScrollTo(0, window.InnerHeight())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment