From be221ae155290b04705bd1a6deeb82f495def012 Mon Sep 17 00:00:00 2001 From: Chip Black Date: Mon, 12 Sep 2011 00:12:41 -0500 Subject: [PATCH] Save/Load last hack index --- Main.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Main.js b/Main.js index 35c3a6c..8f9789e 100644 --- a/Main.js +++ b/Main.js @@ -32,12 +32,14 @@ enyo.kind({ ], create: function() { this.inherited(arguments); - /* - this.index = localStorage.getItem('hack.index'); - if (!this.index) + try { + this.index = localStorage.getItem('hack.index'); + if (!this.index) + this.index = 0; + } catch(e) { + enyo.log("Could not load last hack index"); this.index = 0; - */ - this.index = 0; + } this.lastScrollPos = 0; this.$.hacksCarousel.setCenterView(this.getHack(this.index)); }, @@ -117,7 +119,11 @@ enyo.kind({ //enyo.log('starting view ' + view); if (view) view.start(); - //localStorage.setItem('hack.index', this.index); + try { + localStorage.setItem('hack.index', this.index); + } catch(e) { + enyo.log("Could not set hack index"); + } }, stopHack: function(direction) { var view = this.$.hacksCarousel.fetchView(direction || 'center'); -- 2.25.1