From 0bf9ffc5d6f2c9300866381fb274d558d402097b Mon Sep 17 00:00:00 2001 From: Christopher Groskopf Date: Sun, 27 Mar 2011 19:19:39 -0500 Subject: [PATCH] Added advanced controls. Closes #2. --- assets/css/style.css | 32 ++++++++++++++++++++++++++++---- assets/js/roll.js | 24 ++++++++++++++++++++++++ templates/home.html | 43 +++++++++++++++++++++++++++++++++++++------ 3 files changed, 89 insertions(+), 10 deletions(-) diff --git a/assets/css/style.css b/assets/css/style.css index 3d1933e..2373d86 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -27,20 +27,44 @@ html, body { margin-top: 20px; } -#dice-controls .die { - width: 16%; +#dice-controls .wrapper { + width: 13%; + float: left; + margin-left: 4px; +} + +#dice-controls .wrapper:first-child { + margin-left: 0; +} + +#dice-controls .wrapper .die { + width: 100%; +} + +#dice-controls .wrapper .dec, #dice-controls .wrapper .inc { + width: 49%; + display: none; +} + +#dice-controls #dn { + font-weight: bold; +} + +#toggle-advanced { + width: 960px; + margin: 0 auto; } #rolling { margin: 0 auto; - margin-top: 120px; + margin-top: 100px; font-size: 48px; text-align: center; } #results { margin: 0 auto; - margin-top: 120px; + margin-top: 100px; } #results .roll { diff --git a/assets/js/roll.js b/assets/js/roll.js index 77ae67a..7c1e995 100644 --- a/assets/js/roll.js +++ b/assets/js/roll.js @@ -1,4 +1,28 @@ var DICE = ['d4', 'd6', 'd8', 'd10', 'd12', 'd20']; +var COUNTS = {'d4': 1, 'd6': 1, 'd8': 1, 'd10': 1, 'd12': 1, 'd20': 1} + +function show_advanced_controls() { + $("#dice-controls .wrapper .inc, #dice-controls .wrapper .dec").show(); + $("#toggle-advanced").hide(); +} + +function increment_die_count(die) { + COUNTS[die] += 1; + + $("button#" + die).text(COUNTS[die] + die); +} + +function decrement_die_count(die) { + if (COUNTS[die] > 0) { + COUNTS[die] -= 1; + } + + $("button#" + die).text(COUNTS[die] + die); +} + +function get_die_count(die) { + return COUNTS[die]; +} function roll(dice) { $("#results").hide(); diff --git a/templates/home.html b/templates/home.html index dae0b09..31801d6 100644 --- a/templates/home.html +++ b/templates/home.html @@ -2,12 +2,43 @@ {% block content %}
- - - - - - +
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+
+
+
+
+ Show advanced controls