aboutsummaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorMaximilien Cuony <maximilien@theglu.org>2016-09-11 03:02:00 +0200
committerMaximilien Cuony <maximilien@theglu.org>2016-09-11 03:02:00 +0200
commit007ea5571e2dca4d2ce6db7b3e7f98b86bf929ab (patch)
tree1485b4bb170f99cf5937bac13aef98b021160810 /templates
parentd381c117e8ac5986805ede5db2beca273b967e2f (diff)
downloadglutte-serial-web-007ea5571e2dca4d2ce6db7b3e7f98b86bf929ab.tar.gz
glutte-serial-web-007ea5571e2dca4d2ce6db7b3e7f98b86bf929ab.tar.bz2
glutte-serial-web-007ea5571e2dca4d2ce6db7b3e7f98b86bf929ab.zip
Use websocket and add multiple-user at the same time
Diffstat (limited to 'templates')
-rw-r--r--templates/index.html27
1 files changed, 13 insertions, 14 deletions
diff --git a/templates/index.html b/templates/index.html
index 1b68ce2..038130d 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -5,19 +5,18 @@
<title>Moniteur de Glutte</title>
<link rel="stylesheet" href="static/style.css" type="text/css" media="screen" charset="utf-8"/>
</head>
-<body>
- <h1>Ceci n'est pas une Glutte</h1>
-<pre id="output"></pre>
-<script>
- var output = document.getElementById('output');
+ <body>
+ <h1>Ceci n'est pas une Glutte</h1>
+ <pre id="output"></pre>
+ <script>
+ var output = document.getElementById('output');
- var xhr = new XMLHttpRequest();
- xhr.open('GET', '{{ url_for('stream') }}');
- xhr.send();
+ var socket = new WebSocket("ws://" + window.location.host + "/stream");
- setInterval(function() {
- output.textContent = xhr.responseText;
- window.scrollTo(0, document.body.scrollHeight);
- }, 1000);
-</script>
-</body></html>
+ socket.onmessage = function(data) {
+ output.textContent += data.data;
+ window.scrollTo(0, document.body.scrollHeight);
+ }
+ </script>
+ </body>
+</html>