diff 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
line wrap: on
line diff
--- a/plugins/pubsub.js
+++ b/plugins/pubsub.js
@@ -81,28 +81,13 @@
       },
     },
     methods: {
-      items: function(aTo, aNode, aResult, aError) {
+      items: function(aTo, aNode, aOnSuccess, aOnError) {
         this.send(Lightstring.stanzas.pubsub.items(aTo, aNode), function(stanza) {
-          var items = [];
-          var elms = stanza.DOM.querySelectorAll('item');
-          for (var i = 0; i < elms.length; i++) {
-            var node = elms[i];
-            var item = {
-              id: node.getAttribute('id'),
-              name: node.querySelector('title').textContent,
-              src: node.querySelector('content').getAttribute('src'),
-              type: node.querySelector('content').getAttribute('type'),
-            }
-            var miniature = node.querySelector('link');
-            if (miniature)
-              item.miniature = miniature.getAttribute('href');
-            items.push(item);
-          };
+          var items = stanza.DOM.querySelectorAll('item') || [];
           stanza.items = items;
-
-          if (aResult)
-            aResult(stanza);
-        }, aError);
+          if (aOnSuccess)
+            aOnSuccess(stanza);
+        }, aOnError);
       },
       create: function(aTo, aNode, aFields, aResult, aError) {
         this.send(Lightstring.stanzas.pubsub.create(aTo, aNode, aFields), aResult, aError);