Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit 5bc992f80a90a01d78b798f3a932d8c7e4031433 0 parents
Henri Binsztok authored
1  README
@@ -0,0 +1 @@
+A sample Opa S4 application.
41 resources/css.css
@@ -0,0 +1,41 @@
+/***Header***/
+#logo {
+ background: url("/resources/opa-logo.png") no-repeat scroll 0 0 transparent;
+ height: 32px;
+ margin: 10px 0 5px;
+ width: 61px;
+}
+
+/***Conversation***/
+#conversation {
+ margin-top:58px;
+ margin-bottom:40px;
+ overflow:auto;
+}
+.line {
+ border-bottom:1px solid #ddd;
+ padding-bottom:8px;
+ margin-bottom:8px !important;
+}
+.user, .message {padding-top:8px;}
+.userpic {
+ background: url("/resources/user.png") no-repeat 0 0;
+ height: 40px;
+ width:40px;
+}
+.user {color: #000;font-weight:bold;}
+.message{color:#666;}
+
+/***Footer***/
+#footer {
+ background:#eee;
+ position:fixed;
+ bottom:0;
+ left:0;
+ width:100%;
+ padding:10px 0;
+ text-align:left;
+}
+
+
+
BIN  resources/opa-logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  resources/user.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 webchat.opa
@@ -0,0 +1,45 @@
+import stdlib.themes.bootstrap
+
+type message = { string author, string text }
+
+exposed Network.network(message) room = Network.cloud("room");
+
+function user_update(message x) {
+ line =
+ <div class="row line">
+ <div class="span1 columns userpic" />
+ <div class="span1 columns user">{x.author}:</>
+ <div class="span13 columns message">{x.text}</>
+ </div>;
+ #conversation =+ line;
+ Dom.scroll_to_bottom(#conversation);
+}
+
+function broadcast(x) {
+ Network.broadcast(x, room);
+ Dom.clear_value(#entry);
+}
+
+function main() {
+ author = Random.string(4);
+ send = function(_) {
+ broadcast({ ~author, text: Dom.get_value(#entry) });
+ };
+ <div class="topbar"><div class="fill"><div class="container">
+ <div id=#logo />
+ </div></div></div>
+ <div id=#conversation class="container" onready={
+ function(_) { Network.add_callback(user_update, room); }
+ }></div>
+ <div id=#footer><div class="container">
+ <input id=#entry class="xlarge" onnewline={send}/>
+ <div class="btn primary" onclick={send}>Post</div>
+ </div></div>
+}
+
+Server.start(
+ Server.http,
+ [ { resources: @static_resource_directory("resources") },
+ { register: ["resources/css.css"] },
+ { title: "Chat", page: main } ]
+)
Please sign in to comment.
Something went wrong with that request. Please try again.