From ca2f9b30c3fc9dcc89ca1f620db686305892a0ff Mon Sep 17 00:00:00 2001 From: Eric Fredricksen Date: Sun, 27 Jun 2010 22:01:12 -0700 Subject: [PATCH] Sort of early start on roster page --- config.js | 19 +++++++++++++++++++ newguy.js | 2 +- roster.html | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 roster.html diff --git a/config.js b/config.js index f218ead..d84d65b 100644 --- a/config.js +++ b/config.js @@ -120,6 +120,25 @@ function GenerateName() { } +function loadRoster() { + if (!window.localStorage) { + return; + } else { + var roster = window.localStorage.getItem("roster"); + roster = roster ? JSON.parse(roster) : []; + //if (!$.isArray(roster)) + // roster = []; + return roster; + } +} + +function storeRoster(roster) { + window.localStorage.setItem("roster", JSON.stringify(roster)); +} + +function addToRoster(newguy) { + storeRoster(loadRoster().concat([newguy])); +} var K = {}; diff --git a/newguy.js b/newguy.js index 80e2151..fb33d50 100644 --- a/newguy.js +++ b/newguy.js @@ -144,7 +144,7 @@ function sold() { $.each('STR,CON,DEX,INT,WIS,CHA'.split(','), function (index,value) { newguy[value] = stats[value]; }); - alert(JSON.stringify(newguy)); + addToRoster(JSON.stringify(newguy)); } function GenClick() { diff --git a/roster.html b/roster.html new file mode 100644 index 0000000..1aebcb8 --- /dev/null +++ b/roster.html @@ -0,0 +1,43 @@ + + + +
+Here it goes +
+ + + + \ No newline at end of file