-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroster.js
81 lines (60 loc) · 1.84 KB
/
roster.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
function load() {
if (!window.localStorage) {
roster.html("<b>Hrumph:</b> This browser does not support local storage. You can still play fast and loose: your character will live only as long as the game stays running in your browser.");
return;
}
storage.loadRoster(loadGames);
}
function loadGames(games) {
var roster = $("#roster");
roster.empty();
var newone = window.location.href.split('#')[1];
var count = 0;
$.each(games, function (key, c) {
var name = c.Traits.Name;
var br = brag(c);
roster.append(br);
br.find("a.go").attr("href", "main.html#" + escape(name));
br.find("a.x").click(function () {
if (confirm("Terminate " + Pick(["faithful","noble","loyal","brave"])+
" " + name + "?")) {
delete games[name];
storage.storeRoster(games);
load();
}
});
br.find("a.sheet").click(function () {
alert(template($("#sheet").html(), games[name]));
// TODO: put in a window or whatev
});
if (name === newone)
br.addClass("lit");
/*
var p = $("<p style='font:6pt verdana'/>");
p.appendTo(roster);
p.text(JSON.stringify(c));
*/
++count;
});
if (!count)
roster.html("<i>Games you start can be loaded from this page, but no saved games were found. Roll up a new character to get started.</i>");
}
function brag(sheet) {
var brag = $(template($("#badge").html(), sheet));
if (sheet.motto)
brag.find(".bs").text('"' + sheet.motto + '"');
return brag;
}
function clearRoster() {
storage.storeRoster({}, load);
}
$(document).ready(function () {
load();
$("#roll").click(function () {
window.location = "newguy.html";
});
$("#test").click(function () {
window.location = "newguy.html?sold";
});
$("#clear").click(clearRoster);
});