X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=www%2Fjssrc%2Fblerg%2FAPI.js;h=ecf7cd3970e32ef3e081ae482ed58704b47daefa;hb=626be60457401042854cab447a01ed4120b78886;hp=986ac0963cfe01089017b6671671bc8f6dada3e0;hpb=0085ebfed447d3e7a828eb691a78c5ccc2c21a8c;p=blerg.git diff --git a/www/jssrc/blerg/API.js b/www/jssrc/blerg/API.js index 986ac09..ecf7cd3 100644 --- a/www/jssrc/blerg/API.js +++ b/www/jssrc/blerg/API.js @@ -128,7 +128,7 @@ enyo.kind({ var req = new enyo.Ajax({ url: url }); - req.response(function(inSender, inResponse) { + req.response(this, function(inSender, inResponse) { this.bubble('onItemsLoaded', { type: 'user', username: username, @@ -136,13 +136,13 @@ enyo.kind({ to: to, entries: inResponse }); - }.bind(this)); - req.error(function(inSender, inResponse) { + }); + req.error(this, function(inSender, inResponse) { if (inResponse == 404) this.bubble('onUserNotFound'); else this.bubble('onAPIError', {response: inResponse}); - }.bind(this)); + }); req.go(); }, loadTagRecords: function(type, tag) { @@ -181,19 +181,40 @@ enyo.kind({ }); req.go(); }, - getFeedInfo: function() { + getStatus: function() { if (!blerg.API.loggedIn) throw new Error('Cannot request feed status when not logged in'); var req = new enyo.Ajax({ - url: baseURL + '/feedinfo', + url: baseURL + '/status', method: 'POST', postBody: { username: blerg.API.username } }); req.response(this, function(inSender, inResponse) { - this.bubble('onFeedInfo', inResponse); + this.bubble('onStatus', inResponse); + }); + req.go(); + }, + clearStatus: function(type) { + if (!blerg.API.loggedIn) + throw new Error('Cannot request feed status when not logged in'); + + if (!(type == 'feed' || type == 'mentioned')) + throw new Error('Invalid status clear type: ' + type); + + var req = new enyo.Ajax({ + url: baseURL + '/status', + method: 'POST', + postBody: { + username: blerg.API.username, + clear: type + } + }); + req.response(this, function(inSender, inResponse) { + inResponse.type = type; + this.bubble('onClearStatus', inResponse); }); req.go(); }, @@ -218,7 +239,7 @@ enyo.kind({ }, getSubscriptionStatus: function(username) { var req = new enyo.Ajax({ - url: baseURL + '/feedinfo/' + username, + url: baseURL + '/status/' + username, method: 'POST', postBody: { username: blerg.API.username