From f2682d341f03254944b4398a473596a38478d145 Mon Sep 17 00:00:00 2001 From: Douglas Muth Date: Sun, 29 Jan 2017 13:43:25 -0500 Subject: [PATCH] Added ids to buttons and updated debug code to click the appropriate button. --- index.html | 14 +++++++------- main.js | 22 ++++++++++++++++++++-- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index 663f459..835fca0 100644 --- a/index.html +++ b/index.html @@ -127,13 +127,13 @@
- - - - - - - + + + + + + +

diff --git a/main.js b/main.js index 0f4b894..f42aecc 100644 --- a/main.js +++ b/main.js @@ -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(