Make login optional. Add login icon.
This commit is contained in:
3
app.yaml
3
app.yaml
@@ -9,7 +9,6 @@ handlers:
|
|||||||
static_files: static/babystats.html
|
static_files: static/babystats.html
|
||||||
upload: static/babystats.html
|
upload: static/babystats.html
|
||||||
secure: always
|
secure: always
|
||||||
login: required
|
|
||||||
http_headers:
|
http_headers:
|
||||||
X-Content-Type-Options: nosniff
|
X-Content-Type-Options: nosniff
|
||||||
|
|
||||||
@@ -17,14 +16,12 @@ handlers:
|
|||||||
static_files: static/babystats.html
|
static_files: static/babystats.html
|
||||||
upload: static/babystats.html
|
upload: static/babystats.html
|
||||||
secure: always
|
secure: always
|
||||||
login: required
|
|
||||||
http_headers:
|
http_headers:
|
||||||
X-Content-Type-Options: nosniff
|
X-Content-Type-Options: nosniff
|
||||||
|
|
||||||
- url: /static
|
- url: /static
|
||||||
static_dir: static
|
static_dir: static
|
||||||
secure: always
|
secure: always
|
||||||
login: required
|
|
||||||
http_headers:
|
http_headers:
|
||||||
X-Content-Type-Options: nosniff
|
X-Content-Type-Options: nosniff
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,12 @@ var BabyStats = function(container) {
|
|||||||
|
|
||||||
this.intervals_ = {};
|
this.intervals_ = {};
|
||||||
|
|
||||||
|
this.buildStylesheet_();
|
||||||
|
|
||||||
this.cosmo_ = new Cosmopolite();
|
this.cosmo_ = new Cosmopolite();
|
||||||
|
this.cosmo_.addEventListener('login', this.onLogin_.bind(this));
|
||||||
|
this.cosmo_.addEventListener('logout', this.onLogout_.bind(this));
|
||||||
|
|
||||||
this.client_id_ = this.cosmo_.uuid();
|
this.client_id_ = this.cosmo_.uuid();
|
||||||
hogfather.PublicChat.Join(this.cosmo_, id).then(this.onChatReady_.bind(this));
|
hogfather.PublicChat.Join(this.cosmo_, id).then(this.onChatReady_.bind(this));
|
||||||
};
|
};
|
||||||
@@ -78,7 +83,6 @@ BabyStats.prototype.onChatReady_ = function(chat) {
|
|||||||
this.chat_ = chat;
|
this.chat_ = chat;
|
||||||
|
|
||||||
this.buildCells_();
|
this.buildCells_();
|
||||||
this.buildStylesheet_();
|
|
||||||
this.buildLayout_();
|
this.buildLayout_();
|
||||||
|
|
||||||
window.addEventListener('resize', this.rebuildIfNeeded_.bind(this));
|
window.addEventListener('resize', this.rebuildIfNeeded_.bind(this));
|
||||||
@@ -97,6 +101,34 @@ BabyStats.prototype.onChatReady_ = function(chat) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Event} e
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
BabyStats.prototype.onLogin_ = function(e) {
|
||||||
|
this.loginRule_.style.visibility = 'hidden';
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Event} e
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
BabyStats.prototype.onLogout_ = function(e) {
|
||||||
|
this.loginURL_ = e.detail.login_url;
|
||||||
|
this.loginRule_.style.visibility = 'visible';
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
BabyStats.prototype.onLoginClick_ = function() {
|
||||||
|
window.open(this.loginURL_);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Event} e
|
* @param {Event} e
|
||||||
* @private
|
* @private
|
||||||
@@ -230,6 +262,16 @@ BabyStats.prototype.buildStylesheet_ = function() {
|
|||||||
var focus = style.sheet.cssRules[0];
|
var focus = style.sheet.cssRules[0];
|
||||||
focus.style.outline = 'none';
|
focus.style.outline = 'none';
|
||||||
|
|
||||||
|
style.sheet.insertRule('.babyStatsLogin {}', 0);
|
||||||
|
this.loginRule_ = style.sheet.cssRules[0];
|
||||||
|
this.loginRule_.style.position = 'absolute';
|
||||||
|
this.loginRule_.style.top = 0;
|
||||||
|
this.loginRule_.style.right = 0;
|
||||||
|
this.loginRule_.style.height = '32px';
|
||||||
|
this.loginRule_.style.width = '32px';
|
||||||
|
this.loginRule_.style.margin = '4px';
|
||||||
|
this.loginRule_.style.visibility = 'hidden';
|
||||||
|
|
||||||
style.sheet.insertRule('babyStatsGridOverlay {}', 0);
|
style.sheet.insertRule('babyStatsGridOverlay {}', 0);
|
||||||
var gridOverlay = style.sheet.cssRules[0];
|
var gridOverlay = style.sheet.cssRules[0];
|
||||||
gridOverlay.style.display = 'flex';
|
gridOverlay.style.display = 'flex';
|
||||||
@@ -522,6 +564,12 @@ BabyStats.prototype.buildLayout_ = function() {
|
|||||||
this.yourName_.addEventListener('input', this.onYourNameChange_.bind(this));
|
this.yourName_.addEventListener('input', this.onYourNameChange_.bind(this));
|
||||||
this.container_.appendChild(this.yourName_);
|
this.container_.appendChild(this.yourName_);
|
||||||
|
|
||||||
|
var login = document.createElement('img');
|
||||||
|
this.addCSSClass_(login, 'babyStatsLogin');
|
||||||
|
login.src = '/static/google.svg';
|
||||||
|
login.addEventListener('click', this.onLoginClick_.bind(this));
|
||||||
|
this.container_.appendChild(login);
|
||||||
|
|
||||||
this.gridContainer_ = document.createElement('babyStatsGridContainer');
|
this.gridContainer_ = document.createElement('babyStatsGridContainer');
|
||||||
this.container_.appendChild(this.gridContainer_);
|
this.container_.appendChild(this.gridContainer_);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user