-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
126 lines (101 loc) · 2.14 KB
/
index.html
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<!DOCTYPE html>
<html>
<head>
<style>
* {
font-family: Tahoma, Arial;
}
div:not(#container) {
border: 1px solid #ccc;
}
.room {
background: #77DD77;
margin-bottom: 50px;
width: 50%;
}
#log {
width: 45%;
position: fixed;
right: 0px;
height: 600px;
border: 1px solid black;
background: black;
color: white;
}
.roster {
background: #63D1F4;
}
.val {
font-weight: bold;
}
.roster > ul > li, .playlist > ul> li {
border: 1px solid black;
list-style: none;
margin: 10px;
}
</style>
<script src="/socket.io/socket.io.js"></script>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
function obj2ULtree (obj, depth) {
if (typeof depth=='undefined') {depth=0};
if (typeof obj=='object' && obj ) {
var html='<ul>';
for (var item in obj) {
if (obj.hasOwnProperty(item) && obj[item] != "function" ) {
html+='<li>'+item+': ';
html+=(typeof obj[item]=='object' && obj[item] && depth<10)?
obj2ULtree(obj[item], (depth+1)): '<span class="val">' + obj[item] + '</span>';
html+='</li>';
}
}
}
return html+'</ul>';
}
function formatstate(state) {
var rooms = state.rooms;
var html = "<div id='rooms'>";
for (var room in rooms) {
html += "<div class='room' data-jid='" + room + "'>";
html += "<h1>JID: " + room + "</h1>";
if (rooms[room].config) {
html += "Subject: " + rooms[room].config.subject + "<br/>";
}
html += "Roster: <br/>";
html += "<div class='roster'>";
html += obj2ULtree(rooms[room].roster);
html += "</div>";
html += "</div>";
}
return html;
}
var socket = io.connect('http://localhost/');
socket.on('info', function (data) {
console.log(data);
if(data.state) {
var html1 = formatstate(data.state);
$('#showme').html(html1); //.find('.roster li:not(li li)').css('border', '1px solid #000');
}
});
socket.on('log', function (data) {
if (data.log) {
var html = "<li>" + data.log + "</li>";
}
logbox = $('#log');
logbox.append(html);
if (logbox.find('li').length > 20) {
logbox.find(">:first-child").remove();
}
});
</script>
</head>
<body>
<div id="container">
<div id="log">
<ul>
</ul>
</div>
<div id="showme">
</div>
</div>
</html>