aboutsummaryrefslogtreecommitdiff
path: root/picarones-elm/slide.html
blob: 4c63f97f16d07e36280b892ee4e4782d2841a620 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="UTF-8">
  <title>Main</title>
  <script src="Switcher.js"></script>
  <link rel="stylesheet" type="text/css" href="document.css" />
</head>

<body>
  <div id="elm"></div>
  <script>
    let args = location.hash.split("#").slice(1);

    var app = Elm.Switcher.init({
        node: document.getElementById('elm'),
        flags: [args[0], parseInt(args[1])]
    });

    let ws = new WebSocket("{{ serverurl }}")
    
    ws.onopen = () => ws.send (JSON.stringify ({room:args[0]}));

    ws.onmessage = function(msg) {
        console.log(msg.data)
        app.ports.recvPort.send(msg.data)
    }

    app.ports.sendPort.subscribe(function(msg) {
        ws.send(msg)
    })
  </script>
</body>
</html>