diff options
-rw-r--r-- | views/layouts/main.tt | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/views/layouts/main.tt b/views/layouts/main.tt index 34b2e61..f4139ff 100644 --- a/views/layouts/main.tt +++ b/views/layouts/main.tt @@ -11,10 +11,29 @@ <script type="text/javascript" src="<% request.base%>/javascripts/ballet.js"></script> + <script> + var ws_path = "ws://localhost:5000/_hippie/ws"; + var socket = new WebSocket(ws_path); + + socket.onmessage = function(e) { + var data = JSON.parse(e.data); + console.debug(data); + if (data.msg) { + if (data.msg.type == 'notification') { + document.getElementById('notification-status').innerHTML = data.msg.message; + } + } + }; + function send_msg(message) { + socket.send(JSON.stringify({ msg: message })); + } + </script> + <title><% title %></title> </head> <body> + <div id="notification-status"></div> <% content %> </body> |