Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 53 lines (46 sloc) 1.43 kB
746e7af @Aqua-Ye new version of hello_chat made with opa-create
Aqua-Ye authored
1 module View {
2
3 function page_template(content) {
c562f3d @Aqua-Ye some HTML and CSS update
Aqua-Ye authored
4 <div class="navbar navbar-inverse navbar-fixed-top">
5 <div class=navbar-inner>
6 <div class=container>
7 <div id=#logo />
9d4cc14 @Aqua-Ye upgrade for bootstrap 2.1.0, and some HTML fix
Aqua-Ye authored
8 </div>
9 </div>
c562f3d @Aqua-Ye some HTML and CSS update
Aqua-Ye authored
10 </div>
11 <div id=#main>
746e7af @Aqua-Ye new version of hello_chat made with opa-create
Aqua-Ye authored
12 {content}
c562f3d @Aqua-Ye some HTML and CSS update
Aqua-Ye authored
13 </div>
746e7af @Aqua-Ye new version of hello_chat made with opa-create
Aqua-Ye authored
14 }
15
16 function user_update(message msg) {
9d4cc14 @Aqua-Ye upgrade for bootstrap 2.1.0, and some HTML fix
Aqua-Ye authored
17 line = <div class="row-fluid line">
18 <div class="span1 userpic" />
19 <div class="span2 user">{msg.author}:</>
20 <div class="span9 message">{msg.text}</>
21 </div>;
746e7af @Aqua-Ye new version of hello_chat made with opa-create
Aqua-Ye authored
22 #conversation =+ line;
23 Dom.scroll_to_bottom(#conversation);
24 }
25
26 function broadcast(author) {
27 text = Dom.get_value(#entry);
28 Model.broadcast(~{author, text});
29 Dom.clear_value(#entry);
30 }
31
32 function chat_html(author) {
33 <div id=#conversation class=container-fluid
34 onready={function(_) { Model.register_message_callback(user_update)}} />
c562f3d @Aqua-Ye some HTML and CSS update
Aqua-Ye authored
35 <div id=#footer class="navbar navbar-fixed-bottom">
746e7af @Aqua-Ye new version of hello_chat made with opa-create
Aqua-Ye authored
36 <div class=container>
37 <div class=input-append>
9d4cc14 @Aqua-Ye upgrade for bootstrap 2.1.0, and some HTML fix
Aqua-Ye authored
38 <input id=#entry class=input-xxlarge type=text
746e7af @Aqua-Ye new version of hello_chat made with opa-create
Aqua-Ye authored
39 onnewline={function(_) { broadcast(author) }}>
40 <button class="btn btn-primary" type=button
41 onclick={function(_) { broadcast(author) }}>Post</>
c562f3d @Aqua-Ye some HTML and CSS update
Aqua-Ye authored
42 </div>
43 </div>
44 </div>
746e7af @Aqua-Ye new version of hello_chat made with opa-create
Aqua-Ye authored
45 }
46
47 function default_page() {
48 author = Model.new_author();
49 Resource.page("Opa chat", page_template(chat_html(author)));
50 }
51
52 }
Something went wrong with that request. Please try again.