6 onStartSignup: "showSignupDialog",
7 onTryLogin: "tryLogin",
8 onTryLogout: "tryLogout",
12 {classes: "blerg-header", components: [
13 {name: "title", kind: "blerg.Title"},
14 {name: "controls", kind: "blerg.Controls"},
15 {style: "clear: both"},
16 {name: "post", kind: "blerg.Post", showing: false},
17 {name: "help", kind: "blerg.Help"}
19 {name: "main", kind: "blerg.Main"},
20 {name: "signupDialog", kind: "blerg.SignupDialog"},
21 {name: "passwdDialog", kind: "blerg.PasswdDialog"},
22 {name: "api", kind: "blerg.API",
23 onLoginSuccessful: "loginSuccessful",
24 onLoginFailed: "loginFailed",
25 onLogoutSuccessful: "logout"}
28 ['search', /^\?post\/([^/]+)\/(.+)/, "blerg.ExternalURLPost"],
29 ['hash', /^#\/(ref|tag)\/([A-Za-z0-9_-]+)(?:\/p(\d+))?$/, "blerg.Tag"],
30 ['hash', /^#\/feed(?:\/p(\d+))?$/, "blerg.Feed"],
31 ['hash', /^#([A-Za-z0-9_-]+)(?:\/(p)?(\d+))?$/, "blerg.User"]
33 pathHandlers: [ blerg.Welcome ],
34 rendered: function() {
35 this.inherited(arguments);
37 this.lastHash = location.hash;
40 //setInterval(this.hashCheck.bind(this), 250);
42 document.body.addEventListener('keyup', function(event) {
43 if (event.shiftKey && event.keyCode == 32) {
45 event.stopPropagation();
49 hashCheck: function() {
50 if (location.hash != this.lastHash) {
51 this.lastHash = location.hash;
55 urlSwitch: function() {
59 for (var i = 0; i < this.pathHandlers.length; i++) {
60 var handler = this.pathHandlers[i];
61 objdef = handler.locationDetect(window.location);
66 objdef = {classes: "blerg-error", content: "No handler found"}
68 this.$.main.updateView(objdef);
70 showSignupDialog: function() {
71 this.$.signupDialog.show();
73 setTitle: function(inSender, inEvent) {
74 if (inEvent.section != undefined)
75 this.$.title.setSection(inEvent.section);
77 if (inEvent.subscribed != undefined)
78 this.$.title.setSubscribed(inEvent.subscribed);
80 if (inEvent.showControls)
81 this.$.title.showControls()
83 this.$.title.hideControls();
85 tryLogin: function(inSender, inEvent) {
86 this.$.api.login(inEvent.username, inEvent.password);
88 tryLogout: function(inSender, inEvent) {
91 loginSuccessful: function(inSender, inEvent) {
92 this.$.api.requestFeedStatus();
93 this.feedStatusUpdateInterval = setInterval(function() {
94 this.$.api.requestFeedStatus();
95 }.bind(this), 900000);
96 this.waterfall('onLogin', inEvent);
98 loginFailed: function(inSender, inEvent) {
99 alert('Login failed');
102 logout: function(inSender, inEvent) {
103 clearInterval(this.feedStatusUpdateInterval);
104 this.waterfall('onLogout');