Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 53 lines (46 sloc) 1.43 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
module View {

  function page_template(content) {
    <div class="navbar navbar-inverse navbar-fixed-top">
<div class=navbar-inner>
<div class=container>
<div id=#logo />
</div>
</div>
</div>
    <div id=#main>
{content}
</div>
  }

  function user_update(message msg) {
    line = <div class="row-fluid line">
<div class="span1 userpic" />
<div class="span2 user">{msg.author}:</>
<div class="span9 message">{msg.text}</>
</div>;
    #conversation =+ line;
    Dom.scroll_to_bottom(#conversation);
  }

  function broadcast(author) {
    text = Dom.get_value(#entry);
    Model.broadcast(~{author, text});
    Dom.clear_value(#entry);
  }

  function chat_html(author) {
    <div id=#conversation class=container-fluid
onready={function(_) { Model.register_message_callback(user_update)}} />
    <div id=#footer class="navbar navbar-fixed-bottom">
<div class=container>
<div class=input-append>
<input id=#entry class=input-xxlarge type=text
            onnewline={function(_) { broadcast(author) }}>
<button class="btn btn-primary" type=button
onclick={function(_) { broadcast(author) }}>Post</>
</div>
</div>
</div>
}

function default_page() {
    author = Model.new_author();
    Resource.page("Opa chat", page_template(chat_html(author)));
  }

}
Something went wrong with that request. Please try again.