Mercurial > eldonilo > lightstring
comparison plugins/pubsub.js @ 35:bdfbd58b4835
Fix plugins.
author | Sonny Piers <sonny.piers@gmail.com> |
---|---|
date | Sat, 28 Jan 2012 04:55:29 +0100 |
parents | 1506992c33e2 |
children | d1a7895b3dce |
comparison
equal
deleted
inserted
replaced
34:6ce66fba0242 | 35:bdfbd58b4835 |
---|---|
61 iq += "</affiliations></pubsub></iq>"; | 61 iq += "</affiliations></pubsub></iq>"; |
62 return iq; | 62 return iq; |
63 }, | 63 }, |
64 }; | 64 }; |
65 Lightstring.pubsubItems = function(aConnection, aTo, aNode, aCallback) { | 65 Lightstring.pubsubItems = function(aConnection, aTo, aNode, aCallback) { |
66 aConnection.send(Lightstring.stanza.pubsub.items(aTo, aNode), function(answer){ | 66 aConnection.send(Lightstring.stanza.pubsub.items(aTo, aNode), function(stanza){ |
67 var items = []; | 67 var items = []; |
68 var elms = answer.querySelectorAll('item'); | 68 var elms = stanza.DOM.querySelectorAll('item'); |
69 for(var i = 0; i < elms.length; i++) { | 69 for(var i = 0; i < elms.length; i++) { |
70 var node = elms[i]; | 70 var node = elms[i]; |
71 var item = { | 71 var item = { |
72 id: node.getAttribute('id'), | 72 id: node.getAttribute('id'), |
73 name: node.querySelector('title').textContent, | 73 name: node.querySelector('title').textContent, |
82 if(aCallback) | 82 if(aCallback) |
83 aCallback(items); | 83 aCallback(items); |
84 }); | 84 }); |
85 } | 85 } |
86 Lightstring.pubsubCreate = function(aConnection, aTo, aNode, aFields, aCallback) { | 86 Lightstring.pubsubCreate = function(aConnection, aTo, aNode, aFields, aCallback) { |
87 aConnection.send(Lightstring.stanza.pubsub.create(aTo, aNode, aFields), function(answer) { | 87 aConnection.send(Lightstring.stanza.pubsub.create(aTo, aNode, aFields), function(stanza) { |
88 if(answer.getAttribute('type') === 'result') | 88 if(stanza.DOM.getAttribute('type') === 'result') |
89 aCallback(null, answer); | 89 aCallback(null, stanza); |
90 else | 90 else |
91 aCallback(answer, null); | 91 aCallback(stanza, null); |
92 }); | 92 }); |
93 }; | 93 }; |
94 Lightstring.pubsubConfig = function(aConnection, aTo, aNode, aCallback) { | 94 Lightstring.pubsubConfig = function(aConnection, aTo, aNode, aCallback) { |
95 aConnection.send(Lightstring.stanza.pubsub.getConfig(aTo, aNode), function(answer){ | 95 aConnection.send(Lightstring.stanza.pubsub.getConfig(aTo, aNode), function(stanza){ |
96 var accessmodel = answer.querySelector('field[var="pubsub#access_model"]').lastChild.textContent; | 96 var accessmodel = stanza.DOM.querySelector('field[var="pubsub#access_model"]').lastChild.textContent; |
97 if(accessmodel) | 97 if(accessmodel) |
98 aCallback(accessmodel); | 98 aCallback(accessmodel); |
99 else | 99 else |
100 aCallback(null); | 100 aCallback(null); |
101 }); | 101 }); |
102 } | 102 } |
103 Lightstring.pubsubRetract = function(aConnection, aTo, aNode, aItem, aCallback) { | 103 Lightstring.pubsubRetract = function(aConnection, aTo, aNode, aItem, aCallback) { |
104 aConnection.send(Lightstring.stanza.pubsub.retract(aTo, aNode, aItem), function(answer){ | 104 aConnection.send(Lightstring.stanza.pubsub.retract(aTo, aNode, aItem), function(stanza){ |
105 if(aCallback) | 105 if(aCallback) |
106 aCallback(answer); | 106 aCallback(stanza); |
107 }); | 107 }); |
108 } | 108 } |
109 Lightstring.pubsubPublish = function(aConnection, aTo, aNode, aItem, aId, aCallback) { | 109 Lightstring.pubsubPublish = function(aConnection, aTo, aNode, aItem, aId, aCallback) { |
110 aConnection.send(Lightstring.stanza.pubsub.publish(aTo, aNode, aItem, aId), function(answer){ | 110 aConnection.send(Lightstring.stanza.pubsub.publish(aTo, aNode, aItem, aId), function(stanza){ |
111 if(answer.getAttribute('type') === 'result') | 111 if(answer.getAttribute('type') === 'result') |
112 aCallback(null, answer); | 112 aCallback(null, stanza); |
113 else | 113 else |
114 aCallback(answer, null); | 114 aCallback(stanza, null); |
115 }); | 115 }); |
116 } | 116 } |
117 Lightstring.pubsubDelete = function(aConnection, aTo, aNode, aCallback) { | 117 Lightstring.pubsubDelete = function(aConnection, aTo, aNode, aCallback) { |
118 aConnection.send(Lightstring.stanza.pubsub.delete(aTo, aNode), function(answer){ | 118 aConnection.send(Lightstring.stanza.pubsub.delete(aTo, aNode), function(stanza){ |
119 if(aCallback) | 119 if(aCallback) |
120 aCallback(answer); | 120 aCallback(stanza); |
121 }); | 121 }); |
122 } | 122 } |
123 Lightstring.pubsubGetAffiliations = function(aConnection, aTo, aNode, aCallback) { | 123 Lightstring.pubsubGetAffiliations = function(aConnection, aTo, aNode, aCallback) { |
124 aConnection.send(Lightstring.stanza.pubsub.affiliations(aTo, aNode), function(answer) { | 124 aConnection.send(Lightstring.stanza.pubsub.affiliations(aTo, aNode), function(stanza) { |
125 if((answer.getAttribute('type') === 'result') && aCallback) { | 125 if((stanza.DOM.getAttribute('type') === 'result') && aCallback) { |
126 var affiliations = {}; | 126 var affiliations = {}; |
127 answer.querySelectorAll('affiliation').forEach(function(affiliation) { | 127 stanza.DOM.querySelectorAll('affiliation').forEach(function(affiliation) { |
128 affiliations[affiliation.getAttribute("jid")] = affiliation.getAttribute("affiliation"); | 128 affiliations[affiliation.getAttribute("jid")] = affiliation.getAttribute("affiliation"); |
129 }) | 129 }) |
130 aCallback(affiliations); | 130 aCallback(affiliations); |
131 } | 131 } |
132 }); | 132 }); |