handlers: {
onStartSignup: "showSignupDialog",
onTryLogin: "tryLogin",
+ onTryLogout: "tryLogout",
onSetTitle: "setTitle"
},
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"],
this.$.title.hideControls();
},
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');
}
});