Mercurial > eldonilo > lightstring
comparison plugins/pubsub.js @ 96:646695bde8e9
better pubsub.items method
author | Sonny Piers <sonny.piers@gmail.com> |
---|---|
date | Thu, 03 May 2012 14:56:43 +0200 |
parents | 7affe7ac8fc7 |
children | c06ec02217ee |
comparison
equal
deleted
inserted
replaced
95:7affe7ac8fc7 | 96:646695bde8e9 |
---|---|
32 }, | 32 }, |
33 stanzas: { | 33 stanzas: { |
34 getConfig: function(aTo, aNode) { | 34 getConfig: function(aTo, aNode) { |
35 return "<iq type='get' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub_owner + "'><configure node='" + aNode + "'/></pubsub></iq>"; | 35 return "<iq type='get' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub_owner + "'><configure node='" + aNode + "'/></pubsub></iq>"; |
36 }, | 36 }, |
37 items: function(aTo, aNode) { | 37 items: function(aTo, aNode, aItems) { |
38 return "<iq type='get' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub + "'><items node='" + aNode + "'/></pubsub></iq>"; | 38 var stanza = "<iq type='get' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub + "'><items node='" + aNode + "'>"; |
39 if (aItems) { | |
40 aItems.forEach(function(item) { | |
41 stanza += "<item id='" + item + "'/>" | |
42 }); | |
43 } | |
44 return stanza + "</items></pubsub></iq>"; | |
39 }, | 45 }, |
40 affiliations: function(aTo, aNode) { | 46 affiliations: function(aTo, aNode) { |
41 return "<iq type='get' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub_owner + "'><affiliations node='" + aNode + "'/></pubsub></iq>"; | 47 return "<iq type='get' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub_owner + "'><affiliations node='" + aNode + "'/></pubsub></iq>"; |
42 }, | 48 }, |
43 publish: function(aTo, aNode, aItem, aId) { | 49 publish: function(aTo, aNode, aItem, aId) { |
79 iq += "</affiliations></pubsub></iq>"; | 85 iq += "</affiliations></pubsub></iq>"; |
80 return iq; | 86 return iq; |
81 }, | 87 }, |
82 }, | 88 }, |
83 methods: { | 89 methods: { |
84 items: function(aTo, aNode, aOnSuccess, aOnError) { | 90 items: function(aTo, aNode, aItems, aOnSuccess, aOnError) { |
85 this.send(Lightstring.stanzas.pubsub.items(aTo, aNode), function(stanza) { | 91 this.send(Lightstring.stanzas.pubsub.items(aTo, aNode, aItems), function(stanza) { |
86 var items = stanza.DOM.querySelectorAll('item') || []; | 92 var items = stanza.DOM.querySelectorAll('item') || []; |
87 stanza.items = items; | 93 stanza.items = items; |
88 if (aOnSuccess) | 94 if (aOnSuccess) |
89 aOnSuccess(stanza); | 95 aOnSuccess(stanza); |
90 }, aOnError); | 96 }, aOnError); |