summaryrefslogtreecommitdiff
path: root/orig/pq-web/roster.js
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-08-12 14:05:45 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-08-12 14:05:45 +0200
commit14a6aa4c488bcd2d49103cbee1424b2769d77ce0 (patch)
tree93e3875919eeb0e60d0a8da70f5d96152a4e527a /orig/pq-web/roster.js
Initial import
Diffstat (limited to 'orig/pq-web/roster.js')
-rw-r--r--orig/pq-web/roster.js81
1 files changed, 81 insertions, 0 deletions
diff --git a/orig/pq-web/roster.js b/orig/pq-web/roster.js
new file mode 100644
index 0000000..b005a7e
--- /dev/null
+++ b/orig/pq-web/roster.js
@@ -0,0 +1,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);
+});