| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <html>
- <head>
- <style>
- #rx {
- font-family: 'Courier New', Courier, monospace;
- font-size: small;
- }
- </style>
- <script type="text/javascript" src="common.js?v=$COMMIT_HASH"></script>
- </head>
- <body>
- <div id="rx"></div>
- <script>
- var gateway = getDomainname().replace("http://", "ws://") + "/ws";
- var websocket;
-
- window.addEventListener('load', onLoad);
- function initWebSocket() {
- console.log('Trying to open a WebSocket connection...');
- addToLog('Trying to open a WebSocket connection...');
-
- websocket = new WebSocket(gateway);
- websocket.onopen = onOpen;
- websocket.onclose = onClose;
- websocket.onmessage = onMessage; // <-- add this line
- }
-
-
- function onOpen(event) {
- console.log('Connection opened');
- addToLog('Connection opened');
- }
-
- function onClose(event) {
- console.log('Connection closed');
- addToLog('Connection closed');
- setTimeout(initWebSocket, 2000);
- }
-
-
- function onMessage(event) {
- console.log(event);
- addToLog(event.data);
- }
-
-
-
- function onLoad(event) {
- initWebSocket();
- }
-
-
- function addToLog(msg) {
- document.getElementById('rx').innerHTML += "[" + new Date().toLocaleTimeString() + "] " +msg + "<br>\n";
- window.scrollBy(0,document.body.scrollHeight);
- }
-
- </script>
- </body>
- </html>
|