mirror of
https://github.com/dmuth/diceware.git
synced 2024-11-21 16:36:28 -05:00
Moved 100+ lines from Diceware.go() into Diceware.rollDiceHandler().
This commit is contained in:
parent
4cb0e0e1c7
commit
1b625ad37a
1 changed files with 124 additions and 122 deletions
54
main.js
54
main.js
|
@ -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) {
|
||||
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue