X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=www%2Fjssrc%2Fblerg%2FBlerg.js;h=31d28a801c7560f6e57b5cf93294e2f9376b2cbc;hb=55431b133192e59138a51591d7ef4ef20b6ceb52;hp=080e644639961eb6a7594824f549f8a763ff6c4c;hpb=21db04ef3e4f66d7b5c4c9be2be36703b18cbcaa;p=blerg.git diff --git a/www/jssrc/blerg/Blerg.js b/www/jssrc/blerg/Blerg.js index 080e644..31d28a8 100644 --- a/www/jssrc/blerg/Blerg.js +++ b/www/jssrc/blerg/Blerg.js @@ -5,19 +5,25 @@ enyo.kind({ handlers: { onStartSignup: "showSignupDialog", onTryLogin: "tryLogin", - onSetTitle: "setTitle" + onTryLogout: "tryLogout", + onSetTitle: "setTitle", + onPostVisibility: "postVisibilityUpdate" }, components: [ {classes: "blerg-header", components: [ - {kind: "blerg.Title"}, - {kind: "blerg.Controls"}, + {name: "title", kind: "blerg.Title"}, + {name: "controls", kind: "blerg.Controls"}, {style: "clear: both"}, {name: "post", kind: "blerg.Post", showing: false}, {name: "help", kind: "blerg.Help"} ]}, {name: "main", kind: "blerg.Main"}, {name: "signupDialog", kind: "blerg.SignupDialog"}, - {name: "passwdDialog", kind: "blerg.PasswdDialog"} + {name: "passwdDialog", kind: "blerg.PasswdDialog"}, + {name: "api", kind: "blerg.API", + onLoginSuccessful: "loginSuccessful", + onLoginFailed: "loginFailed", + onLogoutSuccessful: "logout"} ], urlmap: [ ['search', /^\?post\/([^/]+)\/(.+)/, "blerg.ExternalURLPost"], @@ -66,17 +72,31 @@ enyo.kind({ this.$.signupDialog.show(); }, setTitle: function(inSender, inEvent) { - if (inEvent.section != undefined) - this.$.title.setSection(inEvent.section); - - if (inEvent.subscribed != undefined) - this.$.title.setSubscribed(inEvent.subscribed); - - if (inEvent.showControls) - this.$.title.showControls() - else - this.$.title.hideControls(); + this.$.title.waterfall('onSetTitle', inEvent); }, tryLogin: function(inSender, inEvent) { + this.$.api.login(inEvent.username, inEvent.password); + }, + tryLogout: function(inSender, inEvent) { + this.$.api.logout(); + }, + loginSuccessful: function(inSender, inEvent) { + this.$.api.requestFeedStatus(); + this.feedStatusUpdateInterval = setInterval(function() { + this.$.api.requestFeedStatus(); + }.bind(this), 900000); + this.waterfall('onLogin', inEvent); + }, + loginFailed: function(inSender, inEvent) { + alert('Login failed'); + this.logout(); + }, + logout: function(inSender, inEvent) { + clearInterval(this.feedStatusUpdateInterval); + this.waterfall('onLogout'); + }, + postVisibilityUpdate: function(inSender, inEvent) { + this.$.post.waterfall('onPostVisibility', inEvent); + this.$.controls.waterfall('onPostVisibility', inEvent); } });