mirror of
https://bitbucket.org/grumdrig/pq-web.git
synced 2026-09-29 08:44:00 -06:00
Sort of early start on roster page
This commit is contained in:
@@ -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 = {};
|
var K = {};
|
||||||
|
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ function sold() {
|
|||||||
$.each('STR,CON,DEX,INT,WIS,CHA'.split(','), function (index,value) {
|
$.each('STR,CON,DEX,INT,WIS,CHA'.split(','), function (index,value) {
|
||||||
newguy[value] = stats[value];
|
newguy[value] = stats[value];
|
||||||
});
|
});
|
||||||
alert(JSON.stringify(newguy));
|
addToRoster(JSON.stringify(newguy));
|
||||||
}
|
}
|
||||||
|
|
||||||
function GenClick() {
|
function GenClick() {
|
||||||
|
|||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
<script src="jquery.js"></script>
|
||||||
|
<script src="config.js"></script>
|
||||||
|
|
||||||
|
<dl id=roster>
|
||||||
|
Here it goes
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
var roster = $("#roster");
|
||||||
|
roster.text("Loading...");
|
||||||
|
|
||||||
|
var games = loadRoster()
|
||||||
|
if (!games) {
|
||||||
|
roster.text("No local storage");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$.each(games, function (index, element) {
|
||||||
|
var p = $("<dt/>");
|
||||||
|
p.appendTo(roster);
|
||||||
|
p.text(element.name);
|
||||||
|
p = $("<dd/>");
|
||||||
|
p.appendTo(roster);
|
||||||
|
p.text(JSON.stringify(element));
|
||||||
|
});
|
||||||
|
|
||||||
|
var b = $("<button>Test</button>");
|
||||||
|
b.appendTo(roster);
|
||||||
|
b.click(function () {
|
||||||
|
games.push({testy: "betsy"});
|
||||||
|
storeRoster(games);
|
||||||
|
});
|
||||||
|
|
||||||
|
var b = $("<button>Clear</button>");
|
||||||
|
b.appendTo(roster);
|
||||||
|
b.click(function () {
|
||||||
|
games = [];
|
||||||
|
storeRoster();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user