summaryrefslogtreecommitdiff
path: root/test/index.html
blob: 42657a1f8bee1b85a2e20bd14515052145998efe (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
35
36
37
38
39
40
41
42
43
44
45
46
<html>
  <head>
    <title>rhrdtime - Testclient</title>
    <style type="text/css">
      body {
        background-color: #555;
      }

      div.data {
        background-color: white;
        border: 1px solid;
        padding: 1em;
        font-family: monospace;
      }
    </style>
    <script src="jquery.min.js"></script>
    <script type="text/javascript">
      function NTP() {
        this.sock = new WebSocket("ws://localhost:3000/ntp");
        this.sock.onmessage = function (event) {
          $('#timedata').text(event.data);
        }

        this.sock.onmessage = function (event) {
          $('#ntpdata').text(event.data);
        }

        this.update = function() {
          this.sock.send(JSON.stringify({ t1: (+new Date()), t2: 0, t3: 0, t4: 0, tz_offset: 0, week: 0 }));
        }
      }

      function init() {
        ntp = new NTP();
        setInterval(ntp.update.bind(ntp), 1000);
      }
    </script>
  </head>
  <body onload="init()">

    <h1>Radio Helsinki Rivendell NTP:</h1>

    <div id="ntpdata" class="data"></div>

  </body>
</html>