Switch from hashes to URL paths to hack around login issue.

This commit is contained in:
Ian Gulliver
2015-12-27 21:06:48 -08:00
parent 9a6d96a777
commit 478e8b4fd0
2 changed files with 17 additions and 10 deletions

View File

@@ -13,6 +13,14 @@ handlers:
http_headers:
X-Content-Type-Options: nosniff
- url: /baby/.*
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

View File

@@ -6,6 +6,14 @@
* @constructor
*/
var BabyStats = function(container) {
var urlRE = new RegExp('^/baby/([-0-9a-f]{36})$');
var match = window.location.pathname.match(urlRE);
if (!match) {
window.location.pathname = '/baby/' + Cosmopolite.uuid();
return;
}
var id = match[1];
this.container_ = container;
this.tileScaleHeight_ = 1;
@@ -24,22 +32,13 @@ var BabyStats = function(container) {
this.intervals_ = {};
this.cosmo_ = new Cosmopolite();
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));
}
hogfather.PublicChat.Join(this.cosmo_, id).then(this.onChatReady_.bind(this));
};
BabyStats.prototype.onChatReady_ = function(chat) {
this.chat_ = chat;
window.location.hash = this.chat_.getID();
this.buildCells_();
this.buildStylesheet_();
this.buildLayout_();