Mercurial > eldonilo > lightstring
comparison plugins.js @ 8:08a8d8c4c324
fixes on plugins
author | Sonny Piers <sonny.piers@gmail.com> |
---|---|
date | Sun, 15 Jan 2012 01:38:45 +0100 |
parents | 715726598b23 |
children | 6707f450549e |
comparison
equal
deleted
inserted
replaced
7:715726598b23 | 8:08a8d8c4c324 |
---|---|
38 } | 38 } |
39 }; | 39 }; |
40 Lightstring.getRoster = function(connection, aCallback) { | 40 Lightstring.getRoster = function(connection, aCallback) { |
41 connection.send(this.stanza.roster.get(), function(answer){ | 41 connection.send(this.stanza.roster.get(), function(answer){ |
42 var contacts = []; | 42 var contacts = []; |
43 var items = answer.querySelectorAll('item'); | 43 var elems = answer.querySelectorAll('item'); |
44 for(var i = 0; i<items.length; i++) { | 44 for(var i = 0; i<elms.length; i++) { |
45 var item = items[i]; | 45 var item = elms[i]; |
46 var jid = item.getAttribute('jid'); | 46 var jid = item.getAttribute('jid'); |
47 var name = item.getAttribute('name'); | 47 var name = item.getAttribute('name'); |
48 var groups = item.querySelectorAll('group'); | 48 var groups = item.querySelectorAll('group'); |
49 var subscription = item.getAttribute('subscription'); | 49 var subscription = item.getAttribute('subscription'); |
50 var contact = {}; | 50 var contact = {}; |
123 } | 123 } |
124 }; | 124 }; |
125 Lightstring.discoItems = function(aConnection, aTo, aCallback) { | 125 Lightstring.discoItems = function(aConnection, aTo, aCallback) { |
126 aConnection.send(Lightstring.stanza.disco.items(aTo), function(answer){ | 126 aConnection.send(Lightstring.stanza.disco.items(aTo), function(answer){ |
127 var items = []; | 127 var items = []; |
128 answer.querySelectorAll('item').forEach(function(node) { | 128 var elms = answer.querySelectorAll('item'); |
129 for(var i = 0; i < elms.length; i++) { | |
130 var node = elms[i]; | |
129 var item = { | 131 var item = { |
130 jid: node.getAttribute('jid'), | 132 jid: node.getAttribute('jid'), |
131 name: node.getAttribute('name'), | 133 name: node.getAttribute('name'), |
132 node: node.getAttribute('node') | 134 node: node.getAttribute('node') |
133 } | 135 } |
134 items.push(item); | 136 items.push(item); |
135 }); | 137 }; |
136 if(aCallback) | 138 if(aCallback) |
137 aCallback(items); | 139 aCallback(items); |
138 }); | 140 }); |
139 }; | 141 }; |
140 Lightstring.discoInfo = function(aConnection, aTo, aNode, aCallback) { | 142 Lightstring.discoInfo = function(aConnection, aTo, aNode, aCallback) { |
192 }, | 194 }, |
193 }; | 195 }; |
194 Lightstring.pubsubItems = function(aConnection, aTo, aNode, aCallback) { | 196 Lightstring.pubsubItems = function(aConnection, aTo, aNode, aCallback) { |
195 aConnection.send(Lightstring.stanza.pubsub.items(aTo, aNode), function(answer){ | 197 aConnection.send(Lightstring.stanza.pubsub.items(aTo, aNode), function(answer){ |
196 var items = []; | 198 var items = []; |
197 answer.querySelectorAll('item').forEach(function(node) { | 199 var elms = answer.querySelectorAll('item'); |
200 for(var i = 0; i < elms.length; i++) { | |
201 var node = elms[i]; | |
198 var item = { | 202 var item = { |
199 id: node.getAttribute('id'), | 203 id: node.getAttribute('id'), |
200 name: node.querySelector('title').textContent, | 204 name: node.querySelector('title').textContent, |
201 src: node.querySelector('content').getAttribute('src'), | 205 src: node.querySelector('content').getAttribute('src'), |
202 type: node.querySelector('content').getAttribute('type'), | 206 type: node.querySelector('content').getAttribute('type'), |
203 } | 207 } |
204 var miniature = node.querySelector('link'); | 208 var miniature = node.querySelector('link'); |
205 if(miniature) | 209 if(miniature) |
206 item.miniature = miniature.getAttribute('href'); | 210 item.miniature = miniature.getAttribute('href'); |
207 items.push(item); | 211 items.push(item); |
208 }) | 212 }; |
209 if(aCallback) | 213 if(aCallback) |
210 aCallback(items); | 214 aCallback(items); |
211 }); | 215 }); |
212 } | 216 } |
213 Lightstring.pubsubCreate = function(aConnection, aTo, aNode, aFields, aCallback) { | 217 Lightstring.pubsubCreate = function(aConnection, aTo, aNode, aFields, aCallback) { |