(load "scheme/simple_seq_webapp.scm")
(with-handlers ((click-handler "#div1")
(click-handler "#div2")
(keydown-handler "#button1")
(keydown-handler "#button2")
(timeout-handler test-timeout 10000))
(display (get-input))
(display (get-input))
(display (get-input))
(display (get-input))
(display (get-input)))
(display "Test finished.")
The full app is here. (load "scheme/calculator.scm")
Be ready to wait a ridiculous amount of time for the application to load, up to 15 seconds or more, because this demo is not optimized. (Being an alpha prototype, the demo still has bugs and does not yet work in Explorer or mobile browsers.) The slow part is the loading of the caluculator button web component. The second time the application is loaded, it should load fast.
Then click the calculator's purple keys in the test area and watch the results in the Biwascheme console. The calculator does addition, subtraction, multiplication, and division, printing the results in the Biwascheme console.
Here is the main part of the app:
(with-handlers ((click-handler ".button"))
(let* ((btn (js-ref (second (get-input)) "target"))
(text (js-ref btn "innerText")))
(case text
(("+" "-" "*" "/")
(when (not (= value2 0))
(set! value1 value2))
(set! value2 0)
(set! op (string->symbol text)))
(("=")
(when op
(set! value1 ((eval op) value1 value2))
(set! value2 0)))
(else
(set! value2 (+ (* value2 10) (string->number text)))))
(if op
(format #t "~a ~a ~a~%" value1 (symbol->string op) value2)
(format #t "~a~%" value2))))
The full app is at calculator.scm The calculator program is practically self explanatory.