[42] | 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>Currently runnable parties</h1>
|
---|
| 15 | <div>
|
---|
| 16 | <table id="partiesTable" class="partiesTable">
|
---|
| 17 | <tr>
|
---|
| 18 | <th>Name</th>
|
---|
| 19 | <th>URI</th>
|
---|
| 20 | <th>Behaviour</th>
|
---|
| 21 | <th>Profile types</th>
|
---|
| 22 | <th>Description</th>
|
---|
| 23 | </tr>
|
---|
| 24 | <tr>
|
---|
| 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]+'/available';
|
---|
| 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 | //alert(event.data);
|
---|
| 57 | update(JSON.parse(event.data));
|
---|
| 58 | };
|
---|
| 59 | ws.onclose = function (event) {
|
---|
| 60 | alert('Info: Server closed connection. Code: ' + event.code + (event.reason == "" ? "" : ", Reason: " + event.reason));
|
---|
| 61 | };
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | /*
|
---|
| 65 | @param domains a list of GeneralPartyInfo elements.
|
---|
| 66 | The name can be used to start new instances.
|
---|
| 67 | */
|
---|
| 68 | function update(parties) {
|
---|
| 69 |
|
---|
| 70 | // Find a <table> element with id="myTable":
|
---|
| 71 | var table = document.getElementById("partiesTable");
|
---|
| 72 | var oldtablerows=document.querySelectorAll("#partiesTable tr:not(:first-child)");
|
---|
| 73 | for (var i = 0; i < oldtablerows.length; i++) {
|
---|
| 74 | oldtablerows[i].parentNode.removeChild(oldtablerows[i]);
|
---|
| 75 | }
|
---|
| 76 | for (i in parties) {
|
---|
| 77 | var party=parties[i];
|
---|
| 78 | var profiles=[];
|
---|
| 79 | for (var prof of party['capabilities']['profiles']) {
|
---|
| 80 | if (prof.includes('.')) {
|
---|
| 81 | prof=prof.substr(prof.lastIndexOf('.')+1)
|
---|
| 82 | }
|
---|
| 83 | profiles.push(prof);
|
---|
| 84 | }
|
---|
| 85 | var row = table.insertRow(-1); //-1 = end
|
---|
| 86 | row.insertCell(0).innerHTML = party['uri'].split('/').pop(); // last element of URI
|
---|
| 87 | row.insertCell(1).innerHTML = party['uri'];
|
---|
| 88 | row.insertCell(2).innerHTML = party['capabilities']['behaviours'];
|
---|
| 89 | row.insertCell(3).innerHTML = profiles;
|
---|
| 90 | row.insertCell(4).innerHTML = party['description'];
|
---|
| 91 |
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | /*
|
---|
| 97 | This is called when the window DOM is loaded. window.onload runs BEFORE the window is loaded
|
---|
| 98 | and therefore is too early to remove the noscript message.
|
---|
| 99 | */
|
---|
| 100 | document.addEventListener("DOMContentLoaded", function() {
|
---|
| 101 | // Remove elements with "noscript" class - <noscript> is not allowed in XHTML
|
---|
| 102 | var noscripts = document.getElementsByClassName("noscript");
|
---|
| 103 | for (var i = 0; i < noscripts.length; i++) {
|
---|
| 104 | noscripts[i].parentNode.removeChild(noscripts[i]);
|
---|
| 105 | }
|
---|
| 106 | connect();
|
---|
| 107 |
|
---|
| 108 | }, false);
|
---|
| 109 | ]]>
|
---|
| 110 |
|
---|
| 111 | </script>
|
---|
| 112 |
|
---|
| 113 | </html> |
---|