Moved 100+ lines from Diceware.go() into Diceware.rollDiceHandler().

This commit is contained in:
Douglas Muth 2017-02-17 23:40:34 -05:00
parent 4cb0e0e1c7
commit 1b625ad37a

54
main.js
View file

@ -337,29 +337,10 @@ Diceware.is_mobile = function() {
/**
* Our main function when being used via the UI. We call this to set up our jQuery hooks.
*
* I should probably refactor this more in the future--this function came about
* when I changed the code from self-contained to contained in an external object
* in preparation fro Qunit testing...
*
* Our handler for what to do when the "Roll Dice" button is clicked".
* It generates the passphrase and updates the HTML.
*/
Diceware.go = function() {
//
// Handler to mark the clicked number of dice button as active.
//
jQuery(".dice_button").on("click", function(e) {
jQuery(".dice_button").removeClass("active");
jQuery(e.target).addClass("active");
});
//
// Handler when the "Roll Dice" button is clicked. It gets the
// passphrase and updates the HTML with it.
//
jQuery("#roll_dice").on("click", function(e) {
Diceware.rollDiceHandler = function(e) {
//
// Clear out more space when mobile
@ -470,12 +451,34 @@ Diceware.go = function() {
var new_height = jQuery(".results").height();
jQuery(".results").height(height);
jQuery(".results").animate({height: new_height}, 400);
});
});
});
} // End of rollDiceHandler()
/**
* Our main function when being used via the UI. We call this to set up our jQuery hooks.
*
* I should probably refactor this more in the future--this function came about
* when I changed the code from self-contained to contained in an external object
* in preparation fro Qunit testing...
*
*/
Diceware.go = function() {
//
// Handler to mark the clicked number of dice button as active.
//
jQuery(".dice_button").on("click", function(e) {
jQuery(".dice_button").removeClass("active");
jQuery(e.target).addClass("active");
});
jQuery("#roll_dice").on("click", Diceware.rollDiceHandler);
//
// If we're not on a mobile, bring in the GitHub ribbon.
@ -493,8 +496,7 @@ Diceware.go = function() {
//
// Load our wordlist.
//
//jQuery.getScript("./wordlist.js").done(
jQuery.getScript("./wordlist/wordlist.js").done(
jQuery.getScript("./wordlist/wordlist-5-dice.js").done(
function(data) {
//