Added ids to buttons and updated debug code to click the appropriate

button.
This commit is contained in:
Douglas Muth 2017-01-29 13:43:25 -05:00
parent 7598f49c4a
commit f2682d341f
2 changed files with 27 additions and 9 deletions

View file

@ -127,13 +127,13 @@
</h2>
<div class="btn-group-lg" role="group" aria-label="...">
<button type="button" class="btn btn-default dice_button">2</button>
<button type="button" class="btn btn-default dice_button">3</button>
<button type="button" class="btn btn-default dice_button active">4</button>
<button type="button" class="btn btn-default dice_button">5</button>
<button type="button" class="btn btn-default dice_button">6</button>
<button type="button" class="btn btn-default dice_button">7</button>
<button type="button" class="btn btn-default dice_button">8</button>
<button id="button-dice-2" type="button" class="btn btn-default dice_button">2</button>
<button id="button-dice-3" type="button" class="btn btn-default dice_button">3</button>
<button id="button-dice-4" type="button" class="btn btn-default dice_button active">4</button>
<button id="button-dice-5" type="button" class="btn btn-default dice_button">5</button>
<button id="button-dice-6" type="button" class="btn btn-default dice_button">6</button>
<button id="button-dice-7" type="button" class="btn btn-default dice_button">7</button>
<button id="button-dice-8" type="button" class="btn btn-default dice_button">8</button>
</div>
<br/>

22
main.js
View file

@ -377,8 +377,26 @@ Diceware.go = function() {
// If "debug" is set in the GET data, roll the dice on page load.
// Speed up my development a bit. :-)
//
if (location.search.indexOf("debug") != -1) {
jQuery("#roll_dice").click(); // Debugging
var debug = location.search.indexOf("debug");
if (debug != -1) {
//
// Grab our number in the GET data, sanitize it, and click the appropriate button.
//
var offset = location.search.search("=");
var num = location.search[offset + 1];
if (num < 2) {
num = 2;
} else if (num > 8) {
num = 8;
}
var id="#button-dice-" + num;
jQuery(id).click();
jQuery("#roll_dice").click();
}
}).fail(