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 @@ + + + +