Add feed reading functionality
[blerg.git] / www / jssrc / blerg / API.js
index 1370234..203706a 100644 (file)
@@ -68,11 +68,6 @@ enyo.kind({
         });
         enyo.setCookie('username', '', {"Max-Age": 0});
     },
-    requestFeedStatus: function() {
-        if (!blerg.API.loggedIn)
-            throw new Error('Cannot request feed status when not logged in');
-        // TODO
-    },
     loadUserRecords: function(username, from ,to) {
         var url;
         if (from != undefined && to != undefined) {
@@ -123,6 +118,39 @@ enyo.kind({
         }.bind(this));
         req.go();
     },
+    getFeedInfo: function() {
+        if (!blerg.API.loggedIn)
+            throw new Error('Cannot request feed status when not logged in');
+
+        var req = new enyo.Ajax({
+            url: baseURL + '/feedinfo',
+            method: 'POST'
+        });
+        req.response(function(inSender, inResponse) {
+            this.bubble('onFeedInfo', inResponse);
+        }.bind(this));
+        req.go({
+            username: blerg.API.username
+        });
+    },
+    loadFeed: function() {
+        if (!blerg.API.loggedIn)
+            throw new Error('Cannot request feed status when not logged in');
+
+        var req = new enyo.Ajax({
+            url: baseURL + '/feed',
+            method: 'POST'
+        });
+        req.response(function(inSender, inResponse) {
+            this.bubble('onItemsLoaded', {
+                type: "feed",
+                entries: inResponse
+            });
+        }.bind(this));
+        req.go({
+            username: blerg.API.username
+        });
+    },
     getSubscriptionStatus: function(username) {
         var req = new enyo.Ajax({
             url: baseURL + '/feedinfo/' + username,