-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuserhist.html
185 lines (150 loc) · 4.6 KB
/
userhist.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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>JWChat - Chat History</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<script src="shared.js"></script>
<script src="emoticons.js"></script>
<script src="switchStyle.js"></script>
<script src="jsjac.js"></script>
<script>
<!--
function reloadHistory(iq) {
if (iq && iq.getType != 'result')
srcW.Debug.log(iq.xml(),1);
// clear iframes
selected_collection.document.body.innerHTML = '';
collections.document.body.innerHTML = '';
// get collections
var aIQ = new JSJaCIQ();
aIQ.setType('get');
aIQ.setTo(srcW.loghost);
var aNode = aIQ.appendNode(
'list',
{'xmlns': 'http://jabber.org/protocol/archive',
'with': jid});
srcW.con.send(aIQ,me.handleCollsGet);
return false;
}
function handleCollGet(iq) {
if (!iq || iq.getType() != 'result')
return;
srcW.Debug.log(iq.xml(),2);
var histHTML = '';
var aStore = iq.getNode().firstChild;
for (var i=0; i<aStore.childNodes.length; i++) {
var aChild = aStore.childNodes.item(i);
if (aChild.nodeName == 'to') // message from me
histHTML += "<font color=\"blue\"><" + srcW.nick + "></font> ";
else
histHTML += "<font color=\"red\"><" + user.name + "></font> ";
if (aChild.firstChild.firstChild)
histHTML += htmlEnc(aChild.firstChild.firstChild.nodeValue);
histHTML += '<br>';
continue;
}
selected_collection.document.body.innerHTML = histHTML;
}
function handleCollsGet(iq) {
if (!iq || iq.getType() != 'result')
return;
srcW.Debug.log(iq.getDoc().xml,2);
var items = iq.getNode().firstChild.getElementsByTagName('store');
var myTable = collections.document.createElement("TABLE");
var myTableBody = collections.document.createElement("TBODY");
myTable.appendChild(myTableBody);
var row, cell, textN;
for (var i=0; i<items.length; i++) {
var item = items.item(i);
row = collections.document.createElement("TR");
row.setAttribute("start",item.getAttribute('start'));
myTableBody.appendChild(row);
cell = collections.document.createElement("TD");
row.appendChild(cell);
textN = collections.document.createTextNode(hrTime(item.getAttribute('start')));
cell.appendChild(textN);
}
myTable.setAttribute("id","myTable");
myTable.setAttribute("WIDTH","100%");
myTable.setAttribute("BORDER","0");
myTable.setAttribute("CELLSPACING","0");
myTable.setAttribute("CELLPADDING","0");
myTable.setAttribute("RULES","rows");
// add table
collections.document.body.appendChild(myTable);
// tell frame about it
collections.init();
}
function deleteHistory() {
if (!confirm("Are you sure you want to delete this chat history completely?"))
return;
var aIQ = new JSJaCIQ();
aIQ.setType('set');
aIQ.setTo(srcW.loghost);
var aNode =
aIQ.appendNode('remove',
{'xmlns': 'http://jabber.org/protocol/archive',
'with': jid});
srcW.Debug.log(aIQ.xml(),2);
me = this;
srcW.con.send(aIQ,me.reloadHistory);
}
var srcW;
function init() {
// determine source window
if (opener.top.roster)
srcW = opener.top;
if (typeof(srcW) == 'undefined' || !srcW)
return;
getArgs();
jid = passedArgs['jid'];
if (typeof(jid) == 'undefined' || jid == '') {
alert("JID is missing.\nAborting...");
window.close();
}
user = srcW.roster.getUserByJID(jid);
var dtitle = "Chat history for "+user.name;
document.getElementById('title').innerHTML = dtitle;
document.title = dtitle;
// get collections
var aIQ = new JSJaCIQ();
aIQ.setType('get');
aIQ.setTo(srcW.loghost);
var aNode =
aIQ.appendNode('list',
{'xmlns': 'http://jabber.org/protocol/archive',
'with': jid});
me = this;
srcW.con.send(aIQ,me.handleCollsGet);
}
function keyPressed(e) {
if (e.keyCode == 27)
window.close();
return true;
}
onkeydown = keyPressed;
onload = init;
//-->
</script>
<script for="document" event="onkeydown()" language="JScript">
<!--
return keyPressed(window.event);
//-->
</script>
</head>
<body style="margin:8px;">
<table width="100%" height="100%" border=0>
<tr>
<td><h2 id="title"></h2></td><td align="right"><button onClick="deleteHistory();">Delete</button> <button onClick="reloadHistory();">Refresh</td>
</tr>
<tr height="100%">
<td>
<iframe id="collections" name="collections" src="userhist_collections_iframe.html" style="width:240px;height:100%;" scrolling="auto"></iframe>
</td>
<td width="100%">
<iframe id="selected_collection" name="selected_collection" src="chat_iframe.html" style="width:100%;height:100%;"></iframe>
</td>
</tr>
</table>
</body>
</html>