Save/Load last hack index
authorChip Black <bytex64@bytex64.net>
Mon, 12 Sep 2011 05:12:41 +0000 (00:12 -0500)
committerChip Black <bytex64@bytex64.net>
Mon, 12 Sep 2011 05:12:41 +0000 (00:12 -0500)
Main.js

diff --git a/Main.js b/Main.js
index 35c3a6c..8f9789e 100644 (file)
--- 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');