diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/index.html | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/test/index.html b/test/index.html index 41d0a3a..031b458 100644 --- a/test/index.html +++ b/test/index.html @@ -6,7 +6,7 @@ background-color: #555; } - #timedata { + div.data { background-color: white; border: 1px solid; padding: 1em; @@ -15,12 +15,30 @@ </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() { - var sock = new WebSocket("ws://localhost:3000/time"); + var tusock = new WebSocket("ws://localhost:3000/time"); - sock.onmessage = function (event) { - $('#timedata').text(event.data); + tusock.onmessage = function (event) { + $('#tudata').text(event.data); } + + ntp = new NTP(); + setInterval(ntp.update.bind(ntp), 1000); } </script> </head> @@ -28,7 +46,11 @@ <h1>Radio Helsinki Rivendell Time:</h1> - <div id="timedata"></div> + <div id="tudata" class="data"></div> + + <h1>Radio Helsinki Rivendell NTP:</h1> + + <div id="ntpdata" class="data"></div> </body> </html> |