Beispiel #1
0
func main() {
	log.SetFlags(log.Ldate | log.Ltime | log.Llongfile)
	b, err := browser.New("localhost:7000", new(GUI))
	if err != nil {
		log.Fatal(err)
	}
	//	defer b.Close()
	jQuery(INPUT).On(jquery.KEYUP, func(e jquery.Event) {
		go func() {
			args := Args{A: 17, B: 8}
			var reply int
			err = b.Call("Arith.Multiply", args, &reply)
			if err != nil {
				log.Fatal("arith error:", err)
			}
			//show welcome message:
			jQuery(OUTPUT2).SetText("result of mult" + strconv.Itoa(reply))
		}()
	})

}
Beispiel #2
0
func main() {
	log.SetFlags(log.Ldate | log.Ltime | log.Llongfile)
	b, err := browser.New("localhost:7000", new(GUI))
	if err != nil {
		log.Fatal(err)
	}
	//	defer b.Close()
	i := 0
	jQuery(INPUT).On(jquery.CLICK, func(e jquery.Event) {
		go func() {
			i++
			args := shared.Args{A: i, B: i}
			var reply int
			err = b.Call("Arith.Multiply", args, &reply)
			if err != nil {
				log.Fatal("arith error:", err)
			}
			//show welcome message:
			ii := strconv.Itoa(i)
			jQuery(OUTPUT).SetText("result of " + ii + "x" + ii + " from server:" + strconv.Itoa(reply))
		}()
	})

}