Mercurial > eldonilo > lightstring
comparison plugins/pubsub.js @ 95:7affe7ac8fc7
fix the items method on the PubSub plugin
author | Sonny Piers <sonny.piers@gmail.com> |
---|---|
date | Fri, 20 Apr 2012 15:44:47 +0200 |
parents | c1566c6981e5 |
children | 646695bde8e9 |
comparison
equal
deleted
inserted
replaced
94:90fdbe5454c4 | 95:7affe7ac8fc7 |
---|---|
79 iq += "</affiliations></pubsub></iq>"; | 79 iq += "</affiliations></pubsub></iq>"; |
80 return iq; | 80 return iq; |
81 }, | 81 }, |
82 }, | 82 }, |
83 methods: { | 83 methods: { |
84 items: function(aTo, aNode, aResult, aError) { | 84 items: function(aTo, aNode, aOnSuccess, aOnError) { |
85 this.send(Lightstring.stanzas.pubsub.items(aTo, aNode), function(stanza) { | 85 this.send(Lightstring.stanzas.pubsub.items(aTo, aNode), function(stanza) { |
86 var items = []; | 86 var items = stanza.DOM.querySelectorAll('item') || []; |
87 var elms = stanza.DOM.querySelectorAll('item'); | |
88 for (var i = 0; i < elms.length; i++) { | |
89 var node = elms[i]; | |
90 var item = { | |
91 id: node.getAttribute('id'), | |
92 name: node.querySelector('title').textContent, | |
93 src: node.querySelector('content').getAttribute('src'), | |
94 type: node.querySelector('content').getAttribute('type'), | |
95 } | |
96 var miniature = node.querySelector('link'); | |
97 if (miniature) | |
98 item.miniature = miniature.getAttribute('href'); | |
99 items.push(item); | |
100 }; | |
101 stanza.items = items; | 87 stanza.items = items; |
102 | 88 if (aOnSuccess) |
103 if (aResult) | 89 aOnSuccess(stanza); |
104 aResult(stanza); | 90 }, aOnError); |
105 }, aError); | |
106 }, | 91 }, |
107 create: function(aTo, aNode, aFields, aResult, aError) { | 92 create: function(aTo, aNode, aFields, aResult, aError) { |
108 this.send(Lightstring.stanzas.pubsub.create(aTo, aNode, aFields), aResult, aError); | 93 this.send(Lightstring.stanzas.pubsub.create(aTo, aNode, aFields), aResult, aError); |
109 }, | 94 }, |
110 configure: function(aTo, aNode, aFields, aResult, aError) { | 95 configure: function(aTo, aNode, aFields, aResult, aError) { |