Skip to content

Commit

Permalink
Added a display of how many passwords were possible with the rolls.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmuth committed Nov 11, 2015
1 parent a109bfb commit 3bf6c46
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
3 changes: 3 additions & 0 deletions index.html
Expand Up @@ -89,6 +89,9 @@ <h1>Diceware Password Generator</h1>
<div class="results_phrase_key" >Your passphrase is: </div>
<div class="results_phrase_value" ></div>

<div class="results_num_possible_key" ># of possible passwords: </div>
<div class="results_num_possible_value" ></div>

</div>

<div class="alert alert-danger bad_crypto" role="alert">
Expand Down
21 changes: 18 additions & 3 deletions main.js
Expand Up @@ -99,6 +99,7 @@ function display_row(rows, cb) {

var fadein_duration = 250;
var fadeout_delay = 750;
console.log(rows.length, fadein_duration, fadeout_delay);

if (rows.length) {
//
Expand Down Expand Up @@ -156,20 +157,29 @@ function display_results(cb) {
jQuery(".results_words_key").hide().clone().appendTo(".results");
jQuery(".results_words_value").hide().clone().appendTo(".results");
jQuery(".results").append("<br clear=\"all\" />");

jQuery(".results_phrase_key").hide().clone().appendTo(".results");
jQuery(".results_phrase_value").hide().clone().appendTo(".results");
jQuery(".results").append("<br clear=\"all\" />");

jQuery(".results_num_possible_key").hide().clone().appendTo(".results");
jQuery(".results_num_possible_value").hide().clone().appendTo(".results");

jQuery(".results .results_words_key").fadeIn(500, function() {
jQuery(".results .results_words_value").fadeIn(500, function() {
jQuery(".results .results_phrase_key").fadeIn(500, function() {
jQuery(".results .results_phrase_value").fadeIn(500, function() {
jQuery(".results .results_phrase_key").fadeIn(400, function() {
jQuery(".results .results_phrase_value").fadeIn(400, function() {
jQuery(".results .results_num_possible_key").fadeIn(300, function() {
jQuery(".results .results_num_possible_value").fadeIn(300, function() {
if (cb) {
cb();
}
});
});
});
});
});
});

} // End of display_results()

Expand Down Expand Up @@ -202,7 +212,10 @@ function is_mobile() {
//
jQuery("#roll_dice").on("click", function(e) {

var target_height = 200;
//
// Clear out more space when mobile
//
var target_height = 300;
if (is_mobile()) {
target_height = 400;
}
Expand All @@ -227,6 +240,7 @@ jQuery("#roll_dice").on("click", function(e) {
// Make our dice rolls
//
var num_dice = jQuery(".dice_button.active").html();
var num_passwords = Number(Math.pow(6, (5 * num_dice)));
var passphrase = new Array();

var rolls = new Array();
Expand All @@ -246,6 +260,7 @@ jQuery("#roll_dice").on("click", function(e) {
//
jQuery(".results_words_value").html(passphrase.join(" "));
jQuery(".results_phrase_value").html(passphrase.join(""));
jQuery(".results_num_possible_value").html(num_passwords.toLocaleString("en"));

var rows = new Array();
for (key in rolls) {
Expand Down
1 change: 1 addition & 0 deletions starter-template.css
Expand Up @@ -9,6 +9,7 @@ body {

.results_words_key, .results_words_value,
.results_phrase_key, .results_phrase_value,
.results_num_possible_key, .results_num_possible_value,
.dice_word
{
font-size: x-large;
Expand Down

0 comments on commit 3bf6c46

Please sign in to comment.