From 9a8f5e16f47d4cf563458cf8aba57031f7fcaf67 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Sun, 27 Dec 2015 09:26:46 -0800 Subject: [PATCH] Local storage of your name. --- static/babystats.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/static/babystats.js b/static/babystats.js index af891c6..ef8b505 100644 --- a/static/babystats.js +++ b/static/babystats.js @@ -328,7 +328,9 @@ BabyStats.prototype.buildLayout_ = function() { this.yourName_ = document.createElement('input'); this.addCSSClass_(this.yourName_, 'babyStatsYourName'); this.yourName_.placeholder = 'Your name'; + this.yourName_.value = localStorage.getItem('babyStats:yourName') || ''; this.yourName_.addEventListener('input', this.checkOverlay_.bind(this)); + this.yourName_.addEventListener('input', this.onYourNameChange_.bind(this)); this.container_.appendChild(this.yourName_); this.gridContainer_ = document.createElement('babyStatsGridContainer'); @@ -336,6 +338,8 @@ BabyStats.prototype.buildLayout_ = function() { this.gridOverlay_ = document.createElement('babyStatsGridOverlay'); this.container_.appendChild(this.gridOverlay_); + + this.checkOverlay_(); }; @@ -352,6 +356,15 @@ BabyStats.prototype.checkOverlay_ = function() { }; +/** + * Store your name value locally. + * @private + */ +BabyStats.prototype.onYourNameChange_ = function() { + localStorage.setItem('babyStats:yourName', this.yourName_.value); +}; + + /** * Construct the grid objects in the DOM. * @private