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 | <div>
|
---|
15 | <table id="domainsTable" class="domainsTable">
|
---|
16 | <tr>
|
---|
17 | <th>Domain</th>
|
---|
18 | <th>Available Profiles</th>
|
---|
19 | </tr>
|
---|
20 | <tr>
|
---|
21 | <td>-</td>
|
---|
22 | <td>-</td>
|
---|
23 | </tr>
|
---|
24 | </table>
|
---|
25 |
|
---|
26 | </div>
|
---|
27 | </body>
|
---|
28 |
|
---|
29 | <!-- Script to get/update the list and put it into the table. -->
|
---|
30 | <script type="application/javascript">
|
---|
31 |
|
---|
32 | <![CDATA[
|
---|
33 | "use strict";
|
---|
34 |
|
---|
35 | var ws = null;
|
---|
36 |
|
---|
37 | function connect() {
|
---|
38 | // manually construct relative path.......
|
---|
39 | var target = 'ws://'+location.host+"/"+location.pathname.split("/")[1]+'/websocket/liststream'+window.location.search;
|
---|
40 | if ('WebSocket' in window) {
|
---|
41 | ws = new WebSocket(target);
|
---|
42 | } else if ('MozWebSocket' in window) {
|
---|
43 | ws = new MozWebSocket(target);
|
---|
44 | } else {
|
---|
45 | alert('WebSocket is not supported by this browser. Please use a newer browser');
|
---|
46 | return;
|
---|
47 | }
|
---|
48 | ws.onopen = function () {
|
---|
49 | // whatever.
|
---|
50 | };
|
---|
51 | ws.onmessage = function (event) {
|
---|
52 | update(JSON.parse(event.data));
|
---|
53 | };
|
---|
54 | ws.onclose = function (event) {
|
---|
55 | alert('Info: Server closed connection. Code: ' + event.code + (event.reason == "" ? "" : ", Reason: " + event.reason));
|
---|
56 | };
|
---|
57 | }
|
---|
58 |
|
---|
59 | /*
|
---|
60 | @param domains a map of the form {"jobs":["jobs1","jobs2"]}
|
---|
61 | where the keys are the names of the available domains nd the values a list of the available profiles in that domain.
|
---|
62 | */
|
---|
63 | function update(domains) {
|
---|
64 | //alert("update!");
|
---|
65 | //log(JSON.stringify(domains))
|
---|
66 |
|
---|
67 | // Find a <table> element with id="myTable":
|
---|
68 | var table = document.getElementById("domainsTable");
|
---|
69 | var oldtablerows=document.querySelectorAll("#domainsTable tr:not(:first-child)");
|
---|
70 | for (var i = 0; i < oldtablerows.length; i++) {
|
---|
71 | oldtablerows[i].parentNode.removeChild(oldtablerows[i]);
|
---|
72 | }
|
---|
73 | for (var domainname in domains) {
|
---|
74 | var row = table.insertRow(-1);
|
---|
75 | row.insertCell(0).innerHTML = domainname;
|
---|
76 | row.insertCell(1).innerHTML = domains[domainname];
|
---|
77 | }
|
---|
78 |
|
---|
79 | }
|
---|
80 |
|
---|
81 | /*
|
---|
82 | This is called when the window DOM is loaded. window.onload runs BEFORE the window is loaded
|
---|
83 | and therefore is too early to remove the noscript message.
|
---|
84 | */
|
---|
85 | document.addEventListener("DOMContentLoaded", function() {
|
---|
86 | // Remove elements with "noscript" class - <noscript> is not allowed in XHTML
|
---|
87 | var noscripts = document.getElementsByClassName("noscript");
|
---|
88 | for (var i = 0; i < noscripts.length; i++) {
|
---|
89 | noscripts[i].parentNode.removeChild(noscripts[i]);
|
---|
90 | }
|
---|
91 | connect();
|
---|
92 |
|
---|
93 | }, false);
|
---|
94 | ]]>
|
---|
95 |
|
---|
96 | </script>
|
---|
97 |
|
---|
98 | </html> |
---|