mirror of
https://github.com/dmuth/diceware.git
synced 2024-11-24 17:56:35 -05:00
Wrote Diceware.extractGetData() and overhauled debug code to use it.
This commit is contained in:
parent
88312059f7
commit
6ca25671df
1 changed files with 32 additions and 6 deletions
38
main.js
38
main.js
|
@ -458,6 +458,34 @@ Diceware.rollDiceHandler = function(e) {
|
|||
} // End of rollDiceHandler()
|
||||
|
||||
|
||||
/**
|
||||
* Turn our GET method data into an associative array.
|
||||
*/
|
||||
Diceware.extractGetData = function(get_data) {
|
||||
|
||||
var retval = {};
|
||||
|
||||
if (!location.search) {
|
||||
return(retval);
|
||||
}
|
||||
|
||||
var get = get_data.substring(1);
|
||||
var pairs = get.split("&");
|
||||
|
||||
for (var k in pairs) {
|
||||
var row = pairs[k];
|
||||
var pair = row.split("=");
|
||||
var key = pair[0];
|
||||
var value = pair[1];
|
||||
retval[key] = value;
|
||||
|
||||
}
|
||||
|
||||
return(retval);
|
||||
|
||||
} // End of extractGetData()
|
||||
|
||||
|
||||
/**
|
||||
* Our main function when being used via the UI. We call this to set up our jQuery hooks.
|
||||
*
|
||||
|
@ -492,6 +520,8 @@ Diceware.go = function() {
|
|||
}
|
||||
|
||||
|
||||
var get_data = Diceware.extractGetData(location.search);
|
||||
|
||||
//
|
||||
// Load our wordlist.
|
||||
//
|
||||
|
@ -504,13 +534,9 @@ Diceware.go = function() {
|
|||
//
|
||||
var debug = location.search.indexOf("debug");
|
||||
|
||||
if (debug != -1) {
|
||||
if (get_data["debug"] && get_data["debug"] > 0) {
|
||||
|
||||
//
|
||||
// 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];
|
||||
var num = get_data["debug"];
|
||||
if (num < 2) {
|
||||
num = 2;
|
||||
} else if (num > 8) {
|
||||
|
|
Loading…
Reference in a new issue