-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearchrooms.html
217 lines (188 loc) · 7.02 KB
/
searchrooms.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>JWChat - Search for Rooms</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<script src="shared.js"></script>
<script src="switchStyle.js"></script>
<script src="jsjac.js"></script>
<script>
<!--
var srcW; // the source window with necessary data
var conference_server;
function doSub() {
conference_server = document.forms[0].conference_server.value;
/* check for errors */
if (conference_server.indexOf('@') != -1 || conference_server.indexOf('/') != -1) {
alert("this doesn't look like a valid hostname");
return false;
}
document.getElementById("search_tab").style.display = 'none';
document.getElementById("search_result_tab").style.display = '';
document.getElementById("search_result_iframe").style.display = 'none';
document.getElementById("addbookmark_button").style.display = 'none';
document.getElementById("join_room_button").style.display = 'none';
document.getElementById("search_result_header").innerHTML = "Search results for "+conference_server;
document.getElementById("search_result_info").innerHTML = "Querying "+conference_server+". Please stand by...";
search_result_iframe.document.body.innerHTML = '';
search_result_iframe.selectedRow = null;
var iq = new JSJaCIQ();
iq.setType('get');
iq.setTo(conference_server);
iq.setID(conference_server+"IQ");
iq.setQuery('http://jabber.org/protocol/disco#items');
me = this;
srcW.con.send(iq,me.getDiscoItems);
return false;
}
function getDiscoItems(iq) {
if (!iq || iq.getType() != 'result') {
document.getElementById("search_result_info").innerHTML = "An Error Occured!";
if (iq)
srcW.Debug.log(iq.getDoc().xml,1);
return false;
}
srcW.Debug.log(iq.getDoc().xml,2);
var myTable = search_result_iframe.document.createElement("TABLE");
var myTableHead = search_result_iframe.document.createElement("THEAD");
myTableBody = search_result_iframe.document.createElement("TBODY");
var row = search_result_iframe.document.createElement("TR");
var header = new Array("Room");
var cell;
for (var i=0; i<header.length; i++) {
cell = search_result_iframe.document.createElement("TH");
cell.appendChild(search_result_iframe.document.createTextNode(header[i]));
row.appendChild(cell);
}
myTableHead.appendChild(row);
myTable.appendChild(myTableHead);
myTable.appendChild(myTableBody);
myTable.setAttribute("id","modTable");
myTable.setAttribute("WIDTH","100%");
myTable.setAttribute("BORDER","0");
myTable.setAttribute("CELLSPACING","0");
myTable.setAttribute("CELLPADDING","0");
myTable.setAttribute("RULES","rows");
// add table
search_result_iframe.document.body.appendChild(myTable);
document.getElementById("search_result_iframe").style.display = '';
document.getElementById("addbookmark_button").style.display = 'none';
document.getElementById("join_room_button").style.display = '';
document.getElementById("addbookmark_button").disabled = true;
document.getElementById("join_room_button").disabled = true;
disco_items = new Array();
anode_jids = new Array();
disco_at = 0;
disco_items_length = iq.getQuery().getElementsByTagName('item').length;
for (var i=0; i<iq.getQuery().getElementsByTagName('item').length; i++) {
var aNode = iq.getQuery().getElementsByTagName('item').item(i);
disco_items[aNode.getAttribute('jid')] = aNode;
anode_jids[i] = aNode.getAttribute('jid')
}
anode_jids.sort();
for (var i=0; i<anode_jids.length; i++) {
// get vcard
var aIQ = new JSJaCIQ();
aIQ.setTo(disco_items[anode_jids[i]].getAttribute('jid'));
aIQ.setType('get');
aIQ.appendNode('vCard', {'xmlns': 'vcard-temp'});
srcW.con.send(aIQ, me.getVCard);
}
return false;
}
function getVCard(iq) {
var aNode = disco_items[iq.getFrom()];
row = search_result_iframe.document.createElement("TR");
cell = search_result_iframe.document.createElement("TD");
textN = search_result_iframe.document.createTextNode(aNode.getAttribute('name'));
cell.appendChild(textN);
row.appendChild(cell);
cell = search_result_iframe.document.createElement("TD");
if (iq.getType() == 'result' && iq.getNode().getElementsByTagName('DESC').item(0) && iq.getNode().getElementsByTagName('DESC').item(0).firstChild)
textN = search_result_iframe.document.createTextNode(iq.getNode().getElementsByTagName('DESC').item(0).firstChild.nodeValue);
else
textN = search_result_iframe.document.createTextNode('\ ');
cell.appendChild(textN);
row.appendChild(cell);
row.setAttribute("jid",aNode.getAttribute('jid'));
myTableBody.appendChild(row);
disco_at++;
if (disco_at == disco_items_length) {
// we're done tell frame about it
search_result_iframe.init();
document.getElementById("search_result_info").innerHTML = "Finished.";
}
}
function joinRoom() {
srcW.openGroupchat(search_result_iframe.selectedRow.getAttribute('jid'),srcW.nick);
window.close();
return false;
}
function backtosearch() {
document.getElementById("search_result_tab").style.display = 'none';
document.getElementById("search_tab").style.display = '';
return false;
}
function init() {
if (opener.top.roster)
srcW = opener.top;
else
srcW = opener.srcW;
document.getElementById("search_result_tab").style.display = 'none';
if (srcW.DEFAULTCONFERENCESERVER) {
document.forms[0].conference_server.value = srcW.DEFAULTCONFERENCESERVER;
doSub();
}
}
function cleanUp() {
}
function keyPressed(e) {
if (e.keyCode == 13)
return doSub();
if (e.keyCode == 27)
window.close();
return true;
}
onkeydown = keyPressed;
onload = init;
onunload = cleanUp;
//-->
</script>
<script for="document" event="onkeydown()" language="JScript">
<!--
return keyPressed(window.event);
//-->
</script>
</head>
<body style="margin:8px;">
<div id="search_tab">
<h2>Search for Rooms</h2>
<form name="sub" onsubmit="return doSub();">
<table width="100%">
<tr>
<td nowrap>
<label for="conference_server">Search Server:
</td>
<td width="100%">
<input type="text" name="conference_server" style="width:100%;">
</td>
<td>
<button type="submit">Search</button>
</td>
</tr>
</table>
</form>
</div>
<table id="search_result_tab" width="100%" height="100%">
<tr><td><h2 id="search_result_header"></h2></td></tr>
<tr><td id="search_result_info"></td></tr>
<tr><td width="100%" height="100%"><iframe id="search_result_iframe" name="search_result_iframe" src="searchrooms_results_iframe.html" style="width:100%;height:100%;"></iframe></tr></td>
<tr><td><hr noshade size=1></td></tr>
<tr>
<td align=right>
<button id="addbookmark_button" style="display:none;" onClick="return addBookmark();" disabled>Bookmark</button> <button id="join_room_button" onClick="return joinRoom();">Join</button> <button style="display:none;" onClick="return backtosearch();">Back</button>
</td>
</tr>
</table>
</body>
</html>