diff options
-rw-r--r-- | Handler/Home.hs | 4 | ||||
-rw-r--r-- | templates/home.hamlet | 3 | ||||
-rw-r--r-- | templates/home.julius | 10 |
3 files changed, 14 insertions, 3 deletions
diff --git a/Handler/Home.hs b/Handler/Home.hs index ce0a584..42dde92 100644 --- a/Handler/Home.hs +++ b/Handler/Home.hs @@ -12,7 +12,8 @@ import Turing.Machine data Cmd = Beginning | Backward | Forward | Poll deriving Read wsTuring :: WebSocketsT Handler () -wsTuring = evalLoop defaultMachine [defaultConfig] +wsTuring = do sendTextData . T.pack $ showTrans (trans defaultMachine) + evalLoop defaultMachine [defaultConfig] where defaultMachine = mWriteStr "Hello!" defaultConfig = mkConfig . map charToSym $ "_" evalLoop m [] = evalLoop m [defaultConfig] @@ -42,6 +43,7 @@ getHomeR = do -- Identifiers used in HTML/JS code results <- newIdent + state <- newIdent butBeginning <- newIdent butBackward <- newIdent butTogglePlay <- newIdent diff --git a/templates/home.hamlet b/templates/home.hamlet index ed377e9..4155dbb 100644 --- a/templates/home.hamlet +++ b/templates/home.hamlet @@ -15,3 +15,6 @@ <span class="glyphicon glyphicon-play"> <button id="#{butForward}" class="btn"> <span class="glyphicon glyphicon-step-forward"> + <div class="row"> + <div class="col-sm-12 col-md-12"> + <pre id="#{state}"> diff --git a/templates/home.julius b/templates/home.julius index b454de8..0c33c09 100644 --- a/templates/home.julius +++ b/templates/home.julius @@ -4,7 +4,8 @@ $(function() { bBackward : $("##{rawJS butBackward}"), bTogglePlay : $("##{rawJS butTogglePlay}"), bForward : $("##{rawJS butForward}"), - results : $("##{rawJS results}") + results : $("##{rawJS results}"), + state : $("##{rawJS state}") }; var pollInterval = 10000; var playing = false; @@ -65,7 +66,12 @@ $(function() { }; sock.onmessage = function (e) { // var data = JSON.parse(e.data); - ui.results.html(e.data); + var data = e.data; + if (data[1] === "+") { + ui.state.html(data); + } else { + ui.results.html(data); + } }; sock.onerror = function (e) { alert("ERROR! D: (" + e + ")"); |