Clean up layout deferral. Require login.

This commit is contained in:
Ian Gulliver
2015-12-27 19:50:37 -08:00
parent fe5eff8923
commit 29f0d7600c
2 changed files with 25 additions and 11 deletions

View File

@@ -24,20 +24,32 @@ var BabyStats = function(container) {
this.intervals_ = {};
this.cosmo_ = new Cosmopolite();
hogfather.PublicChat.Create(this.cosmo_).then(function(chat) {
this.chat_ = chat;
if (window.location.hash) {
var id = window.location.hash.substring(1);
hogfather.PublicChat.Join(this.cosmo_, id).then(
this.onChatReady_.bind(this));
} else {
hogfather.PublicChat.Create(this.cosmo_).then(
this.onChatReady_.bind(this));
}
};
this.buildCells_();
this.buildStylesheet_();
this.buildLayout_();
window.addEventListener('resize', this.rebuildIfNeeded_.bind(this));
BabyStats.prototype.onChatReady_ = function(chat) {
this.chat_ = chat;
var grid = this.calculateGrid_();
this.gridWidthCells_ = grid.gridWidthCells;
this.gridHeightCells_ = grid.gridHeightCells;
this.buildGrid_();
}.bind(this));
window.location.hash = this.chat_.getID();
this.buildCells_();
this.buildStylesheet_();
this.buildLayout_();
window.addEventListener('resize', this.rebuildIfNeeded_.bind(this));
var grid = this.calculateGrid_();
this.gridWidthCells_ = grid.gridWidthCells;
this.gridHeightCells_ = grid.gridHeightCells;
this.buildGrid_();
};