~ubuntu-branches/ubuntu/natty/jwchat/natty

« back to all changes in this revision

Viewing changes to src/groupchat_modifylist.html

  • Committer: Bazaar Package Importer
  • Author(s): Lincoln de Sousa, Lincoln de Sousa, Marcelo Jorge Vieira
  • Date: 2010-09-16 11:42:28 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20100916114228-5s5ne28n1w6wrfbl
Tags: 1.0+dfsg-1
[Lincoln de Sousa]

* Switch to dpkg-source 3.0 (quilt) format
* Migrating package from cdbs to debhelper 7.0.50~
* Changing the rule get-orig-source to generate a dfsg compatible
  package striping swf files from the orig (Closes: #591962)
* Updated Standards-Version to 3.9.1
* Removing po-debconf from the Build-Depends-Indep list.

[Marcelo Jorge Vieira]

* Fixing the default backend
* Fixing Debugger dependency
* Changing information about packaging from old maintainers to
  Debian XMPP Team.
* Removing sound support.
* Setting a port for apache VirtualHost.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 
2
<html>
 
3
  <head>
 
4
    <title><l>JWChat - Modify</l></title>
 
5
    <script src="switchStyle.js"></script>
 
6
    <script src="shared.js"></script>
 
7
    <script src="jsjac.js"></script>
 
8
                <script>
 
9
var deltaItems = new Array(); // contains table rows
 
10
 
 
11
function add2deltaItems(row,state) {
 
12
        var item = new Object();
 
13
        if (row.childNodes.item(0).innerHTML == '' && row.childNodes.item(1).innerHTML == '') // neither nick nor jid supplied
 
14
                return;
 
15
        if (row.childNodes.item(0).innerHTML != '')
 
16
                item.nick = row.childNodes.item(0).innerHTML;
 
17
        if (row.childNodes.item(1).innerHTML != '')
 
18
                item.jid = row.childNodes.item(1).innerHTML;
 
19
        if (row.childNodes.item(2).innerHTML != '')
 
20
                item.reason = row.childNodes.item(2).innerHTML;
 
21
        
 
22
        if (queryType == 'role_based')
 
23
                item.state = "role="+state;
 
24
        else
 
25
                item.state = "affiliation="+state;
 
26
        
 
27
        deltaItems[deltaItems.length] = item;
 
28
}
 
29
 
 
30
function deltaAddItem(row,state) {
 
31
        var statExp = /(.+)=(.+)/;
 
32
        statExp.exec(state);
 
33
        add2deltaItems(row,RegExp.$2);
 
34
}
 
35
 
 
36
function deltaDelItem(row) {
 
37
        add2deltaItems(row,'none');
 
38
}
 
39
 
 
40
function handleIQSetList(iq) {
 
41
        // check for errors
 
42
 
 
43
        if (iq && iq.getType() == 'result') { // sucess
 
44
                srcW.Debug.log(iq.getDoc().xml,2);
 
45
                window.close();
 
46
                return true;
 
47
        }
 
48
 
 
49
        var html = '';
 
50
        if (iq && iq.getType() == 'error') {
 
51
                srcW.Debug.log(iq.getDoc().xml,1);
 
52
                for (var i=0; i<iq.getNode().getElementsByTagName('item').length; i++) {
 
53
                        var item = iq.getNode().getElementsByTagName('item').item(i);
 
54
                        if (item.getAttribute('jid'))
 
55
                                html += "Item: "+item.getAttribute('jid')+"<br>";
 
56
                        else if (item.getAttribute('nick'))
 
57
                                html += "Nick: "+item.getAttribute('nick')+"<br>";
 
58
                }
 
59
                for (var j=0; j<iq.getNode().getElementsByTagName('error').length; j++)
 
60
                        var error = iq.getNode().getElementsByTagName('error').item(j);
 
61
                html += loc("Error") + " " + error.getAttribute('code');
 
62
                if (error.getElementsByTagName('text').item(0))
 
63
                        html += ": " + error.getElementsByTagName('text').item(0).firstChild.nodeValue;
 
64
        }       
 
65
        
 
66
        document.getElementById('hint').innerHTML = '';
 
67
        document.getElementById('hint').innerHTML = html;
 
68
        
 
69
        deltaItems = new Array();
 
70
        
 
71
        updateListFrame(modItems);
 
72
}
 
73
 
 
74
function doSub() {
 
75
        var iq = new JSJaCIQ();
 
76
        iq.setType('set');
 
77
        iq.setTo(opener.parent.jid);
 
78
        var query = iq.setQuery(args[1]);
 
79
        
 
80
        for (var i=0; i<deltaItems.length; i++) {
 
81
                var item = query.appendChild(iq.getDoc().createElement('item'));
 
82
                item.setAttribute(deltaItems[i].state.split('=')[0],deltaItems[i].state.split('=')[1]);
 
83
                if (deltaItems[i].nick)
 
84
                        item.setAttribute('nick',deltaItems[i].nick);
 
85
                if (deltaItems[i].jid)
 
86
                        item.setAttribute('jid',deltaItems[i].jid);
 
87
                if (deltaItems[i].reason)
 
88
                        item.appendChild(iq.getDoc().createElement('reason')).appendChild(iq.getDoc().createTextNode(deltaItems[i].reason));
 
89
        }
 
90
 
 
91
        srcW.Debug.log(iq.getDoc().xml,2);
 
92
        srcW.con.send(iq,me.handleIQSetList);
 
93
        
 
94
        return false;
 
95
}
 
96
 
 
97
function deleteItem() {
 
98
        if (!modifylistF.selectedRow) {
 
99
                alert("Nothing selected");
 
100
                return;
 
101
        }
 
102
        
 
103
        deltaDelItem(modifylistF.selectedRow);
 
104
        
 
105
        var modTableBody = modifylistF.document.getElementById('modTable').getElementsByTagName("TBODY").item(0);
 
106
        modTableBody.removeChild(modifylistF.selectedRow);
 
107
        
 
108
        // reset form
 
109
        modifylistF.selectedRow = null;
 
110
        document.getElementById('delete_button').disabled = true;
 
111
        return false;
 
112
}
 
113
 
 
114
function addItem() {
 
115
        var row = modifylistF.document.createElement("TR");
 
116
        
 
117
        var cell = modifylistF.document.createElement("TD");
 
118
        var textN = modifylistF.document.createTextNode(document.forms['add_item'].nick.value);
 
119
        cell.appendChild(textN);
 
120
        row.appendChild(cell);
 
121
        
 
122
        cell = modifylistF.document.createElement("TD");
 
123
        textN = modifylistF.document.createTextNode(document.forms['add_item'].jid.value);
 
124
        cell.appendChild(textN);
 
125
        row.appendChild(cell);
 
126
        
 
127
        cell = modifylistF.document.createElement("TD");
 
128
        textN = modifylistF.document.createTextNode(document.forms['add_item'].reason.value);
 
129
        cell.appendChild(textN);
 
130
        row.appendChild(cell);
 
131
        
 
132
        deltaAddItem(row,args[0]);
 
133
        
 
134
        modifylistF.document.getElementById('modTable').getElementsByTagName('TBODY').item(0).appendChild(row);
 
135
        
 
136
        // tell frame about it
 
137
        modifylistF.init();
 
138
        
 
139
        // clear form
 
140
        document.forms['add_item'].reset();
 
141
        document.getElementById('add_button').disabled = true;
 
142
        return false;
 
143
}
 
144
 
 
145
function activateAddButton() {
 
146
        document.getElementById('add_button').disabled = false;
 
147
}
 
148
 
 
149
function updateListFrame(modItems) {
 
150
        // clear frame
 
151
        modifylistF.document.body.innerHTML = '';
 
152
        
 
153
        var myTable = modifylistF.document.createElement("TABLE");
 
154
        
 
155
        var myTableHead = modifylistF.document.createElement("THEAD");
 
156
        var myTableBody = modifylistF.document.createElement("TBODY");
 
157
        
 
158
        var row = modifylistF.document.createElement("TR");
 
159
        var header = new Array(loc('Nick'),loc('JID'),loc('Reason'));
 
160
        var cell; 
 
161
        for (var i=0; i<header.length; i++) {
 
162
                cell = modifylistF.document.createElement("TH");
 
163
                cell.appendChild(modifylistF.document.createTextNode(header[i]));
 
164
                row.appendChild(cell);
 
165
        }
 
166
        myTableHead.appendChild(row);
 
167
        myTable.appendChild(myTableHead);
 
168
        
 
169
        for (var i=0; i<modItems.length; i++) {
 
170
                var item = modItems.item(i);
 
171
                row = modifylistF.document.createElement("TR");
 
172
                        
 
173
                cell = modifylistF.document.createElement("TD");
 
174
                textN = modifylistF.document.createTextNode((typeof(item.getAttribute('nick')) != 'undefined')?item.getAttribute('nick'):'');
 
175
                cell.appendChild(textN);
 
176
                row.appendChild(cell);
 
177
                
 
178
                cell = modifylistF.document.createElement("TD");
 
179
                textN = modifylistF.document.createTextNode((typeof(item.getAttribute('jid')) != 'undefined')?item.getAttribute('jid'):'');
 
180
                cell.appendChild(textN);
 
181
                row.appendChild(cell);
 
182
                        
 
183
                cell = modifylistF.document.createElement("TD");
 
184
                textN = modifylistF.document.createTextNode((item.firstChild && item.firstChild.nodeName == 'reason' && item.firstChild.firstChild)?item.firstChild.firstChild.nodeValue:'');
 
185
                cell.appendChild(textN);
 
186
                row.appendChild(cell);
 
187
                
 
188
                myTableBody.appendChild(row);
 
189
        }
 
190
        
 
191
        myTable.appendChild(myTableBody);
 
192
        
 
193
        myTable.setAttribute("id","modTable");
 
194
        myTable.setAttribute("WIDTH","100%");
 
195
        myTable.setAttribute("BORDER","0");
 
196
        myTable.setAttribute("CELLSPACING","0");
 
197
        myTable.setAttribute("CELLPADDING","0");
 
198
        myTable.setAttribute("RULES","rows");
 
199
        
 
200
        // add table
 
201
        modifylistF.document.body.appendChild(myTable);
 
202
        
 
203
        // tell frame about it
 
204
        modifylistF.init();
 
205
}
 
206
 
 
207
var modItems;
 
208
function handleIQGetList(iq) {
 
209
        if (!iq || iq.getType() == 'error') {
 
210
                document.getElementById('hint').innerHTML = loc("An Error has occured");
 
211
                if (iq)
 
212
                        srcW.Debug.log(iq.getDoc().xml,1);
 
213
                return;
 
214
        }
 
215
 
 
216
        srcW.Debug.log(iq.getDoc().xml,2);
 
217
        
 
218
        if (!iq.getQuery().childNodes.length) {
 
219
                document.getElementById('hint').innerHTML = loc("No items found");
 
220
        }
 
221
        
 
222
        modItems = iq.getQuery().getElementsByTagName('item');
 
223
        
 
224
        updateListFrame(modItems);
 
225
        
 
226
}
 
227
 
 
228
var srcW;
 
229
var queryType;
 
230
function init() {
 
231
        srcW = opener.parent.top.srcW;
 
232
        
 
233
        // get args
 
234
        search = self.location.href;
 
235
        search = search.split('?');
 
236
        
 
237
        if(search.length>1){
 
238
                args = search[1];
 
239
                args = args.split('&');
 
240
                args[2] = unescape(args[2]);
 
241
        } else
 
242
                return;
 
243
        
 
244
        if (args[0].indexOf("role") != 0 && args[0].indexOf("affiliation") != 0)
 
245
                return; // it's your fault
 
246
        
 
247
        
 
248
        if (args[0].indexOf("role") == 0)
 
249
                queryType = 'role_based';
 
250
        else
 
251
                queryType = 'affiliation_based';
 
252
        
 
253
        roster = srcW.roster;
 
254
 
 
255
        var iq = new JSJaCIQ();
 
256
        iq.setType('get');
 
257
        iq.setTo(opener.parent.jid);
 
258
        var query = iq.setQuery(args[1]);
 
259
        query.appendChild(iq.getDoc().createElement('item')).setAttribute(args[0].split('=')[0],args[0].split('=')[1]);
 
260
        srcW.Debug.log(iq.getDoc().xml,2);
 
261
        me = this;
 
262
        srcW.con.send(iq,me.handleIQGetList);
 
263
        
 
264
        document.getElementById('title').innerHTML = loc("Modify [_1]",args[2]);
 
265
        document.title += " " + args[2];
 
266
        
 
267
        // reset selector
 
268
        opener.document.getElementById('list_selector').selectedIndex = 0;
 
269
        
 
270
        // disable buttons on start
 
271
        document.getElementById('add_button').disabled = true;
 
272
        document.getElementById('delete_button').disabled = true;
 
273
}
 
274
onload = init;
 
275
function keyPressed(e) {
 
276
        if (e.keyCode == 13)
 
277
                return doSub();
 
278
        if (e.keyCode == 27)
 
279
                window.close();
 
280
        return true;
 
281
}
 
282
 
 
283
onload = init;
 
284
onkeydown = keyPressed;
 
285
    </script>
 
286
    <script for="document" event="onkeydown()" language="JScript">
 
287
      <!--
 
288
      return keyPressed(window.event);
 
289
      //-->
 
290
    </script>
 
291
                <style type="text/css">
 
292
                        h1 { font-size: 1.5em; }
 
293
                        th { font-size: 0.8em; text-align: right; }
 
294
                </style>
 
295
  </head>
 
296
  <body style="margin:8px;">
 
297
                <table width="100%" height="100%">
 
298
                <tr><td><h1 id="title">&nbsp;</h1></td></tr>
 
299
                <tr><td><span id="hint">&nbsp;</span></td></tr>
 
300
                <tr><td width="100%" height="100%"><iframe src="groupchat_modifylist_iframe.html" id="modifylistF" name="modifylistF" scrolling="auto" style="width: 100%; height: 100%"></iframe></td></tr>
 
301
                <tr><td><form name="add_item">
 
302
                <table>
 
303
                <tr><th>Nick</th><td><input type="text" name="nick" onkeydown="activateAddButton();"></td></tr>
 
304
                <tr><th>JID</th><td><input type="text" name="jid" style="width: 100%;" onkeydown="activateAddButton();"></td></tr>
 
305
                <tr><th>Reason</th><td><input type="text" name="reason" style="width: 100%;" onkeydown="activateAddButton();"></td></tr>
 
306
                </table></form>
 
307
                </td></tr>
 
308
                <tr><td><hr noshade size=1></td></tr>
 
309
                <tr><td align="right">
 
310
                <button id="add_button" onClick="return addItem();"><l>Add</l></button>&nbsp;<button id="delete_button" onClick="return deleteItem();"><l>Delete</l></button>&nbsp;<button type="submit" id="save_button" onClick="return doSub();"><l>Save</l></button>
 
311
                </td>
 
312
                </tr>
 
313
                </table>
 
314
  </body>
 
315
</html>