commit:be221ae155290b04705bd1a6deeb82f495def012
author:Chip Black
committer:Chip Black
date:Mon Sep 12 00:12:41 2011 -0500
parents:071769a909b6fdecea56c6badcea7a92603ced7d
Save/Load last hack index
diff --git a/Main.js b/Main.js
line changes: +12/-6
index 35c3a6c..8f9789e
--- 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');