From 29f0d7600c4c1a90cee91e8478ca183c9d4a2f37 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Sun, 27 Dec 2015 19:50:37 -0800 Subject: [PATCH] Clean up layout deferral. Require login. --- app.yaml | 2 ++ static/babystats.js | 34 +++++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/app.yaml b/app.yaml index ed07e05..f78a26a 100644 --- a/app.yaml +++ b/app.yaml @@ -9,12 +9,14 @@ handlers: static_files: static/babystats.html upload: static/babystats.html secure: always + login: required http_headers: X-Content-Type-Options: nosniff - url: /static static_dir: static secure: always + login: required http_headers: X-Content-Type-Options: nosniff diff --git a/static/babystats.js b/static/babystats.js index a4057a4..9445097 100644 --- a/static/babystats.js +++ b/static/babystats.js @@ -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_(); };