Listing 2: The generate Function
// Executes when the Generate Passwords button is clicked.
function generate() {
var chars, len, num, m, n, pwds, pwd;
// Build a string based on the check boxes.
chars = "";
if (id("uppercase").checked) chars += UPPER_CHARS;
if (id("lowercase").checked) chars += LOWER_CHARS;
if (id("numbers").checked) chars += NUMBER_CHARS;
if (id("symbols").checked) chars += SYMBOL_CHARS;
// Complain if none of the check boxes are selected.
if (chars "" ? pwd : "\n" + pwd;
// End Callout B
}
// Update the password list and enable the Copy to Clipboard and
// Clear List buttons.
// Begin Callout C
id("passwords").value = pwds;
id("copydata").disabled = false;
id("clear").disabled = false;
// End Callout C
}