Clear the output element before running the program.
Chris Pressey
5 years ago
14 | 14 | putCh :: Char -> IO () |
15 | 15 | putCh = ffi "(function(c) {var o=document.getElementById('prog-output'); o.textContent += String.fromCharCode(c);})" |
16 | 16 | |
17 | clearOutput :: IO () | |
18 | clearOutput = ffi "(function(c) {var o=document.getElementById('prog-output'); o.textContent = '';})" | |
19 | ||
17 | 20 | main = withElems ["prog", "result", "run-button"] driver |
18 | 21 | |
19 | 22 | driver [progElem, resultElem, runButtonElem] = |
20 | 23 | onEvent runButtonElem Click $ \_ -> do |
21 | 24 | Just prog <- getValue progElem |
25 | clearOutput | |
22 | 26 | r <- emmentalWithIO (getCh) (putCh) prog |
23 | 27 | setProp resultElem "textContent" $ show $ r |