annotate plugins/pubsub.js @ 38:d38597574322

add the websocket protocol RFC in the references
author Sonny Piers <sonny.piers@gmail.com>
date Tue, 31 Jan 2012 01:17:55 +0100
parents bdfbd58b4835
children d1a7895b3dce
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
96898e3812a5 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
1 'use strict';
96898e3812a5 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
2
2
f31a75c3b6c8 code cleaning
Sonny Piers <sonny.piers@gmail.com>
parents: 0
diff changeset
3 /**
f31a75c3b6c8 code cleaning
Sonny Piers <sonny.piers@gmail.com>
parents: 0
diff changeset
4 Copyright (c) 2011, Sonny Piers <sonny at fastmail dot net>
f31a75c3b6c8 code cleaning
Sonny Piers <sonny.piers@gmail.com>
parents: 0
diff changeset
5
f31a75c3b6c8 code cleaning
Sonny Piers <sonny.piers@gmail.com>
parents: 0
diff changeset
6 Permission to use, copy, modify, and/or distribute this software for any
f31a75c3b6c8 code cleaning
Sonny Piers <sonny.piers@gmail.com>
parents: 0
diff changeset
7 purpose with or without fee is hereby granted, provided that the above
f31a75c3b6c8 code cleaning
Sonny Piers <sonny.piers@gmail.com>
parents: 0
diff changeset
8 copyright notice and this permission notice appear in all copies.
f31a75c3b6c8 code cleaning
Sonny Piers <sonny.piers@gmail.com>
parents: 0
diff changeset
9
f31a75c3b6c8 code cleaning
Sonny Piers <sonny.piers@gmail.com>
parents: 0
diff changeset
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
f31a75c3b6c8 code cleaning
Sonny Piers <sonny.piers@gmail.com>
parents: 0
diff changeset
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
f31a75c3b6c8 code cleaning
Sonny Piers <sonny.piers@gmail.com>
parents: 0
diff changeset
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
f31a75c3b6c8 code cleaning
Sonny Piers <sonny.piers@gmail.com>
parents: 0
diff changeset
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
f31a75c3b6c8 code cleaning
Sonny Piers <sonny.piers@gmail.com>
parents: 0
diff changeset
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
f31a75c3b6c8 code cleaning
Sonny Piers <sonny.piers@gmail.com>
parents: 0
diff changeset
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
f31a75c3b6c8 code cleaning
Sonny Piers <sonny.piers@gmail.com>
parents: 0
diff changeset
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
f31a75c3b6c8 code cleaning
Sonny Piers <sonny.piers@gmail.com>
parents: 0
diff changeset
17 */
f31a75c3b6c8 code cleaning
Sonny Piers <sonny.piers@gmail.com>
parents: 0
diff changeset
18
7
715726598b23 improvements on plugins
Sonny Piers <sonny.piers@gmail.com>
parents: 3
diff changeset
19 //////////
715726598b23 improvements on plugins
Sonny Piers <sonny.piers@gmail.com>
parents: 3
diff changeset
20 //PubSub//
715726598b23 improvements on plugins
Sonny Piers <sonny.piers@gmail.com>
parents: 3
diff changeset
21 //////////
3
029c12b8f048 various bug fixes and improvements
Sonny Piers <sonny.piers@gmail.com>
parents: 2
diff changeset
22 Lightstring.NS.x = "jabber:x:data";
029c12b8f048 various bug fixes and improvements
Sonny Piers <sonny.piers@gmail.com>
parents: 2
diff changeset
23 Lightstring.NS.pubsub = "http://jabber.org/protocol/pubsub";
029c12b8f048 various bug fixes and improvements
Sonny Piers <sonny.piers@gmail.com>
parents: 2
diff changeset
24 Lightstring.NS.pubsub_owner = "http://jabber.org/protocol/pubsub#owner";
029c12b8f048 various bug fixes and improvements
Sonny Piers <sonny.piers@gmail.com>
parents: 2
diff changeset
25 Lightstring.stanza.pubsub = {
20
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
26 getConfig: function(aTo, aNode) {
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
27 return "<iq type='get' to='"+aTo+"'><pubsub xmlns='"+Lightstring.NS.pubsub_owner+"'><configure node='"+aNode+"'/></pubsub></iq>";
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
28 },
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
29 items: function(aTo, aNode) {
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
30 return "<iq type='get' to='"+aTo+"'><pubsub xmlns='"+Lightstring.NS.pubsub+"'><items node='"+aNode+"'/></pubsub></iq>";
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
31 },
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
32 affiliations: function(aTo, aNode) {
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
33 return "<iq type='get' to='"+aTo+"'><pubsub xmlns='"+Lightstring.NS.pubsub_owner+"'><affiliations node='"+aNode+"'/></pubsub></iq>";
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
34 },
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
35 publish: function(aTo, aNode, aItem, aId) {
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
36 return "<iq type='set' to='"+aTo+"'><pubsub xmlns='"+Lightstring.NS.pubsub+"'><publish node='"+aNode+"'><item id='"+aId+"'>"+aItem+"</item></publish></pubsub></iq>";
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
37 },
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
38 retract: function(aTo, aNode, aItem) {
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
39 return "<iq type='set' to='"+aTo+"'><pubsub xmlns='"+Lightstring.NS.pubsub+"'><retract node='"+aNode+"'><item id='"+aItem+"'/></retract></pubsub></iq>";
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
40 },
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
41 'delete': function(aTo, aNode, aURI) {
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
42 return "<iq type='set' to='"+aTo+"'><pubsub xmlns='"+Lightstring.NS.pubsub_owner+"'><delete node='"+aNode+"'/></pubsub></iq>";
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
43 },
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
44 create: function(aTo, aNode, aFields) {
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
45 var iq = "<iq type='set' to='"+aTo+"'><pubsub xmlns='"+Lightstring.NS.pubsub+"'><create node='"+aNode+"'/>";
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
46 if(aFields) {
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
47 iq += "<configure><x xmlns='"+Lightstring.NS.x+"' type='submit'>"
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
48 aFields.forEach(function(field) {
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
49 iq += field;
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
50 });
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
51 iq += "</x></configure>";
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
52 }
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
53 iq += "</pubsub></iq>";
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
54 return iq;
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
55 },
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
56 setAffiliations: function(aTo, aNode, aAffiliations) {
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
57 var iq = "<iq type='set' to='"+aTo+"'><pubsub xmlns='"+Lightstring.NS.pubsub_owner+"'><affiliations node='"+aNode+"'>";
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
58 for(var i = 0; i < aAffiliations.length; i++) {
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
59 iq += "<affiliation jid='"+aAffiliations[i][0]+"' affiliation='"+aAffiliations[i][1]+"'/>"
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
60 }
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
61 iq += "</affiliations></pubsub></iq>";
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
62 return iq;
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
63 },
0
96898e3812a5 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
64 };
3
029c12b8f048 various bug fixes and improvements
Sonny Piers <sonny.piers@gmail.com>
parents: 2
diff changeset
65 Lightstring.pubsubItems = function(aConnection, aTo, aNode, aCallback) {
35
bdfbd58b4835 Fix plugins.
Sonny Piers <sonny.piers@gmail.com>
parents: 30
diff changeset
66 aConnection.send(Lightstring.stanza.pubsub.items(aTo, aNode), function(stanza){
20
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
67 var items = [];
35
bdfbd58b4835 Fix plugins.
Sonny Piers <sonny.piers@gmail.com>
parents: 30
diff changeset
68 var elms = stanza.DOM.querySelectorAll('item');
8
08a8d8c4c324 fixes on plugins
Sonny Piers <sonny.piers@gmail.com>
parents: 7
diff changeset
69 for(var i = 0; i < elms.length; i++) {
08a8d8c4c324 fixes on plugins
Sonny Piers <sonny.piers@gmail.com>
parents: 7
diff changeset
70 var node = elms[i];
20
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
71 var item = {
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
72 id: node.getAttribute('id'),
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
73 name: node.querySelector('title').textContent,
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
74 src: node.querySelector('content').getAttribute('src'),
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
75 type: node.querySelector('content').getAttribute('type'),
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
76 }
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
77 var miniature = node.querySelector('link');
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
78 if(miniature)
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
79 item.miniature = miniature.getAttribute('href');
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
80 items.push(item);
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
81 };
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
82 if(aCallback)
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
83 aCallback(items);
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
84 });
0
96898e3812a5 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
85 }
3
029c12b8f048 various bug fixes and improvements
Sonny Piers <sonny.piers@gmail.com>
parents: 2
diff changeset
86 Lightstring.pubsubCreate = function(aConnection, aTo, aNode, aFields, aCallback) {
35
bdfbd58b4835 Fix plugins.
Sonny Piers <sonny.piers@gmail.com>
parents: 30
diff changeset
87 aConnection.send(Lightstring.stanza.pubsub.create(aTo, aNode, aFields), function(stanza) {
bdfbd58b4835 Fix plugins.
Sonny Piers <sonny.piers@gmail.com>
parents: 30
diff changeset
88 if(stanza.DOM.getAttribute('type') === 'result')
bdfbd58b4835 Fix plugins.
Sonny Piers <sonny.piers@gmail.com>
parents: 30
diff changeset
89 aCallback(null, stanza);
20
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
90 else
35
bdfbd58b4835 Fix plugins.
Sonny Piers <sonny.piers@gmail.com>
parents: 30
diff changeset
91 aCallback(stanza, null);
20
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
92 });
0
96898e3812a5 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
93 };
3
029c12b8f048 various bug fixes and improvements
Sonny Piers <sonny.piers@gmail.com>
parents: 2
diff changeset
94 Lightstring.pubsubConfig = function(aConnection, aTo, aNode, aCallback) {
35
bdfbd58b4835 Fix plugins.
Sonny Piers <sonny.piers@gmail.com>
parents: 30
diff changeset
95 aConnection.send(Lightstring.stanza.pubsub.getConfig(aTo, aNode), function(stanza){
bdfbd58b4835 Fix plugins.
Sonny Piers <sonny.piers@gmail.com>
parents: 30
diff changeset
96 var accessmodel = stanza.DOM.querySelector('field[var="pubsub#access_model"]').lastChild.textContent;
20
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
97 if(accessmodel)
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
98 aCallback(accessmodel);
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
99 else
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
100 aCallback(null);
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
101 });
0
96898e3812a5 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
102 }
3
029c12b8f048 various bug fixes and improvements
Sonny Piers <sonny.piers@gmail.com>
parents: 2
diff changeset
103 Lightstring.pubsubRetract = function(aConnection, aTo, aNode, aItem, aCallback) {
35
bdfbd58b4835 Fix plugins.
Sonny Piers <sonny.piers@gmail.com>
parents: 30
diff changeset
104 aConnection.send(Lightstring.stanza.pubsub.retract(aTo, aNode, aItem), function(stanza){
20
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
105 if(aCallback)
35
bdfbd58b4835 Fix plugins.
Sonny Piers <sonny.piers@gmail.com>
parents: 30
diff changeset
106 aCallback(stanza);
20
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
107 });
0
96898e3812a5 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
108 }
3
029c12b8f048 various bug fixes and improvements
Sonny Piers <sonny.piers@gmail.com>
parents: 2
diff changeset
109 Lightstring.pubsubPublish = function(aConnection, aTo, aNode, aItem, aId, aCallback) {
35
bdfbd58b4835 Fix plugins.
Sonny Piers <sonny.piers@gmail.com>
parents: 30
diff changeset
110 aConnection.send(Lightstring.stanza.pubsub.publish(aTo, aNode, aItem, aId), function(stanza){
20
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
111 if(answer.getAttribute('type') === 'result')
35
bdfbd58b4835 Fix plugins.
Sonny Piers <sonny.piers@gmail.com>
parents: 30
diff changeset
112 aCallback(null, stanza);
20
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
113 else
35
bdfbd58b4835 Fix plugins.
Sonny Piers <sonny.piers@gmail.com>
parents: 30
diff changeset
114 aCallback(stanza, null);
20
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
115 });
0
96898e3812a5 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
116 }
3
029c12b8f048 various bug fixes and improvements
Sonny Piers <sonny.piers@gmail.com>
parents: 2
diff changeset
117 Lightstring.pubsubDelete = function(aConnection, aTo, aNode, aCallback) {
35
bdfbd58b4835 Fix plugins.
Sonny Piers <sonny.piers@gmail.com>
parents: 30
diff changeset
118 aConnection.send(Lightstring.stanza.pubsub.delete(aTo, aNode), function(stanza){
20
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
119 if(aCallback)
35
bdfbd58b4835 Fix plugins.
Sonny Piers <sonny.piers@gmail.com>
parents: 30
diff changeset
120 aCallback(stanza);
20
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
121 });
0
96898e3812a5 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
122 }
3
029c12b8f048 various bug fixes and improvements
Sonny Piers <sonny.piers@gmail.com>
parents: 2
diff changeset
123 Lightstring.pubsubGetAffiliations = function(aConnection, aTo, aNode, aCallback) {
35
bdfbd58b4835 Fix plugins.
Sonny Piers <sonny.piers@gmail.com>
parents: 30
diff changeset
124 aConnection.send(Lightstring.stanza.pubsub.affiliations(aTo, aNode), function(stanza) {
bdfbd58b4835 Fix plugins.
Sonny Piers <sonny.piers@gmail.com>
parents: 30
diff changeset
125 if((stanza.DOM.getAttribute('type') === 'result') && aCallback) {
20
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
126 var affiliations = {};
35
bdfbd58b4835 Fix plugins.
Sonny Piers <sonny.piers@gmail.com>
parents: 30
diff changeset
127 stanza.DOM.querySelectorAll('affiliation').forEach(function(affiliation) {
20
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
128 affiliations[affiliation.getAttribute("jid")] = affiliation.getAttribute("affiliation");
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
129 })
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
130 aCallback(affiliations);
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
131 }
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
132 });
0
96898e3812a5 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
133 };
3
029c12b8f048 various bug fixes and improvements
Sonny Piers <sonny.piers@gmail.com>
parents: 2
diff changeset
134 Lightstring.pubsubSetAffiliations = function(aConnection, aTo, aNode, aAffiliations, aCallback) {
20
7fcccf59e6ec Always use two-spaces indent.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 16
diff changeset
135 aConnection.send(Lightstring.stanza.pubsub.setAffiliations(aTo, aNode, aAffiliations));
0
96898e3812a5 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
136 };