2 name: "blerg.Controls",
4 classes: "blerg-controls",
13 onPostVisibility: "postVisibilityUpdate"
16 {name: "loggedOutControls", components: [
17 {tag: "form", onsubmit: "loginClicked", classes: "login", components: [
18 {kind: "onyx.Groupbox", components: [
19 {kind: "onyx.InputDecorator", components: [
20 {name: "username", kind: "onyx.Input", placeholder: "Username"}
22 {kind: "onyx.InputDecorator", components: [
23 {name: "password", kind: "onyx.Input", placeholder: "Password", type: "password"}
26 {kind: "onyx.Button", content: "Login", onclick: "loginClicked"}
29 {name: "loggedInControls", showing: false, components: [
30 {name: "greeting", components: [
31 {noDom: true, content: "Hello, "},
32 {name: "userlink", tag: "a"},
33 {noDom: true, content: ". "},
34 {kind: "blerg.Link", content: "Logout", onNavigate: "logoutClicked"},
35 {noDom: true, content: "."}
38 {name: "rssButton", kind: "blerg.Link", showing: false, components: [
39 {kind: "Image", src: "/images/rss.png", width: 16, height: 16},
40 {noDom: true, content: " RSS"}
43 {classes: "blerg-controls-toolbar", components: [
44 {kind: "onyx.Button", content: "Feed Your Vanity", onclick: "chatterClicked"},
45 {name: "feedButton", kind: "onyx.Button", classes: "feed-button", content: "Stalk Your Victims", onclick: "feedClicked"},
46 {name: "spewButton", kind: "onyx.Button", classes: "spew-button", content: "Spew It!", onclick: "spewToggle"}
49 {name: "api", kind: "blerg.API",
50 onFeedInfo: "gotFeedInfo"}
52 showRSS: function(url) {
53 this.$.rssButton.show();
55 this.$.rssButton.setAttribute('href', url);
58 this.$.rssButton.hide();
60 loggedInChanged: function() {
62 this.$.loggedOutControls.hide();
63 this.$.loggedInControls.show();
65 this.$.loggedOutControls.show();
66 this.$.loggedInControls.hide();
69 loginClicked: function(inSender, inEvent) {
70 this.bubble('onTryLogin', {
71 username: this.$.username.getValue(),
72 password: this.$.password.getValue()
74 inEvent.preventDefault();
77 logoutClicked: function() {
78 this.bubble('onTryLogout');
81 login: function(inSender, inEvent) {
82 this.$.password.setValue('');
83 this.setLoggedIn(true);
84 this.$.userlink.setAttribute('href', '/#' + inEvent.username);
85 this.$.userlink.setContent('@' + inEvent.username);
86 this.username = inEvent.username;
88 this.$.api.getFeedInfo();
89 this.feedStatusUpdateInterval = setInterval(function() {
90 this.$.api.getFeedInfo();
91 }.bind(this), 900000);
93 logout: function(inSender, inEvent) {
94 this.setLoggedIn(false);
95 clearInterval(this.feedStatusUpdateInterval);
97 spewToggle: function(inSender, inEvent) {
98 this.postShowing = !this.postShowing;
99 this.bubble('onPostVisibility', {showing: this.postShowing});
101 postVisibilityUpdate: function(inSender, inEvent) {
102 this.postShowing = inEvent.showing;
103 this.$.spewButton.addRemoveClass('active', inEvent.showing);
105 gotFeedInfo: function(inSender, inEvent) {
106 this.$.feedButton.addRemoveClass('new', inEvent.new > 0);
107 if (inEvent.new > 0) {
108 this.$.feedButton.setContent('Stalk Your Victims (' + inEvent.new + ')');
110 this.$.feedButton.setContent('Stalk Your Victims');
113 chatterClicked: function() {
114 window.location.href = '/#/ref/' + this.username;
115 this.bubble('onNavigate');
117 feedClicked: function() {
118 window.location.href = '/#/feed';
119 this.bubble('onNavigate');