summaryrefslogtreecommitdiff
path: root/index.html
diff options
context:
space:
mode:
authorYuval Adam <yuv.adm@gmail.com>2013-03-10 11:56:01 +0200
committerYuval Adam <yuv.adm@gmail.com>2013-03-10 11:56:01 +0200
commit7585a4509aa6df2368ae44ba0a42562f201b1937 (patch)
treeabb5ab8d12052fed6699b7eb3cefe0264b3364a7 /index.html
parent7d578212d4c2684f8e0428ca9792d8b0b8396a5e (diff)
Server, websockets and client boilerplate
Diffstat (limited to 'index.html')
-rw-r--r--index.html45
1 files changed, 45 insertions, 0 deletions
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..bbc2d6a
--- /dev/null
+++ b/index.html
@@ -0,0 +1,45 @@
+<!doctype html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+ <title>{{ title }}</title>
+ <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
+ <script>
+ $(document).ready(function() {
+ function show_message(msg){
+ $('#messages').prepend('<p>' + msg + '<p>');
+ }
+
+ var ws = new WebSocket('ws://127.0.0.1:9000/orders');
+ ws.onopen = function() {
+ show_message('B⃦ Connected.');
+ }
+ ws.onmessage = function(event) {
+ show_message('B⃦ ' + event.data);
+ }
+ ws.onclose = function() {
+ show_message('B⃦ Closed.');
+ }
+
+ $('#order').click(function() {
+ var order = $('#order-msg').val();
+ ws.send(order);
+ });
+ });
+ </script>
+ </head>
+
+ <body>
+
+ <h1>{{ title }}</h1>
+ <h2>Order</h2>
+ <p>
+ <input id="order-msg" value=""/>
+ <input id="order" type="submit" value="Send Order"/>
+ </p>
+
+ <h2>Messages</h2>
+ <div id="messages"></div>
+
+ </body>
+</html>