source: src/main/webapp/runlist.xhtml@ 22

Last change on this file since 22 was 1, checked in by bart, 5 years ago

Initial Release

File size: 3.2 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
3<head>
4<title>Profiles and Domains list</title>
5<link rel="stylesheet" type="text/css" href="css/list.css" />
6
7</head>
8<body>
9 <div class="noscript">
10 <h2 style="color: #ff0000">Seems your browser doesn't support
11 Javascript! Websockets rely on Javascript being enabled. Please
12 enable Javascript and reload this page!</h2>
13 </div>
14 <h1>Running parties</h1>
15 <div>
16 <table id="partiesTable" class="partiesTable">
17 <tr>
18 <th>id</th>
19 <th>name</th>
20 <th>started at</th>
21 <th>ends before</th>
22 </tr>
23 <tr>
24 <td>-</td>
25 <td>-</td>
26 <td>-</td>
27 <td>-</td>
28 </tr>
29 </table>
30
31 </div>
32</body>
33
34<!-- Script to get/update the list and put it into the table. -->
35<script type="application/javascript">
36
37 <![CDATA[
38 "use strict";
39
40 var ws = null;
41
42 function connect() {
43 var target = 'ws://'+location.host+"/"+location.pathname.split("/")[1]+'/running';
44 if ('WebSocket' in window) {
45 ws = new WebSocket(target);
46 } else if ('MozWebSocket' in window) {
47 ws = new MozWebSocket(target);
48 } else {
49 alert('WebSocket is not supported by this browser. Please use a newer browser');
50 return;
51 }
52 ws.onopen = function () {
53 // whatever.
54 };
55 ws.onmessage = function (event) {
56 update(JSON.parse(event.data));
57 };
58 ws.onclose = function (event) {
59 alert('Info: Server closed connection. Code: ' + event.code + (event.reason == "" ? "" : ", Reason: " + event.reason));
60 };
61 }
62
63 /*
64 @param parties a list of RunningPartyInfo elements.
65 */
66 function update(parties) {
67 //(JSON.stringify(parties))
68
69 // Find a <table> element with id="myTable":
70 var table = document.getElementById("partiesTable");
71 var oldtablerows=document.querySelectorAll("#partiesTable tr:not(:first-child)");
72 for (var i = 0; i < oldtablerows.length; i++) {
73 oldtablerows[i].parentNode.removeChild(oldtablerows[i]);
74 }
75 for (var i=0; i<parties.length; i++) {
76 var party=parties[i];
77 var row = table.insertRow(-1); //-1 = end
78 row.insertCell(0).innerHTML = party['id'];
79 row.insertCell(1).innerHTML = party['name'];
80 row.insertCell(2).innerHTML = new Date(party['startDate']);
81 row.insertCell(3).innerHTML = new Date(party['endDate']);
82
83 }
84
85 }
86
87 /*
88 This is called when the window DOM is loaded. window.onload runs BEFORE the window is loaded
89 and therefore is too early to remove the noscript message.
90 */
91 document.addEventListener("DOMContentLoaded", function() {
92 // Remove elements with "noscript" class - <noscript> is not allowed in XHTML
93 var noscripts = document.getElementsByClassName("noscript");
94 for (var i = 0; i < noscripts.length; i++) {
95 noscripts[i].parentNode.removeChild(noscripts[i]);
96 }
97 connect();
98
99 }, false);
100 ]]>
101
102</script>
103
104</html>
Note: See TracBrowser for help on using the repository browser.