6 onStartSignup: "showSignupDialog",
7 onTryLogin: "tryLogin",
8 onTryLogout: "tryLogout",
9 onSetTitle: "setTitle",
10 onPostVisibility: "postVisibilityUpdate"
13 {classes: "blerg-header", components: [
14 {name: "title", kind: "blerg.Title"},
15 {name: "controls", kind: "blerg.Controls"},
16 {style: "clear: both"},
17 {name: "post", kind: "blerg.Post", showing: false},
18 {name: "help", kind: "blerg.Help"}
20 {name: "main", kind: "blerg.Main"},
21 {name: "signupDialog", kind: "blerg.SignupDialog"},
22 {name: "passwdDialog", kind: "blerg.PasswdDialog"},
23 {name: "api", kind: "blerg.API",
24 onLoginSuccessful: "loginSuccessful",
25 onLoginFailed: "loginFailed",
26 onLogoutSuccessful: "logout"}
29 ['search', /^\?post\/([^/]+)\/(.+)/, "blerg.ExternalURLPost"],
30 ['hash', /^#\/(ref|tag)\/([A-Za-z0-9_-]+)(?:\/p(\d+))?$/, "blerg.Tag"],
31 ['hash', /^#\/feed(?:\/p(\d+))?$/, "blerg.Feed"],
32 ['hash', /^#([A-Za-z0-9_-]+)(?:\/(p)?(\d+))?$/, "blerg.User"]
34 pathHandlers: [ blerg.User, blerg.Welcome ],
35 rendered: function() {
36 this.inherited(arguments);
38 this.lastHash = location.hash;
41 setInterval(this.hashCheck.bind(this), 250);
43 document.body.addEventListener('keyup', function(event) {
44 if (event.shiftKey && event.keyCode == 32) {
46 event.stopPropagation();
50 hashCheck: function() {
51 if (location.hash != this.lastHash) {
52 this.lastHash = location.hash;
56 urlSwitch: function() {
60 for (var i = 0; i < this.pathHandlers.length; i++) {
61 var handler = this.pathHandlers[i];
62 objdef = handler.locationDetect(window.location);
67 objdef = {classes: "blerg-error", content: "No handler found"}
69 this.$.main.updateView(objdef);
71 showSignupDialog: function() {
72 this.$.signupDialog.show();
74 setTitle: function(inSender, inEvent) {
75 this.$.title.waterfall('onSetTitle', inEvent);
77 tryLogin: function(inSender, inEvent) {
78 this.$.api.login(inEvent.username, inEvent.password);
80 tryLogout: function(inSender, inEvent) {
83 loginSuccessful: function(inSender, inEvent) {
84 this.$.api.requestFeedStatus();
85 this.feedStatusUpdateInterval = setInterval(function() {
86 this.$.api.requestFeedStatus();
87 }.bind(this), 900000);
88 this.waterfall('onLogin', inEvent);
90 loginFailed: function(inSender, inEvent) {
91 alert('Login failed');
94 logout: function(inSender, inEvent) {
95 clearInterval(this.feedStatusUpdateInterval);
96 this.waterfall('onLogout');
98 postVisibilityUpdate: function(inSender, inEvent) {
99 this.$.post.waterfall('onPostVisibility', inEvent);
100 this.$.controls.waterfall('onPostVisibility', inEvent);