Compare commits

...

2 commits

Author SHA1 Message Date
Quantum 6b540a940e Load settings earlier to avoid race condition 2025-06-15 19:56:40 -04:00
Quantum ab7e4d0138 Generate a password on load 2025-06-15 19:52:37 -04:00

View file

@ -55,15 +55,26 @@ $(() => {
updateBitMeter()
}
function generatePassword () {
const options = $options.serializeObject()
$output.text(generate(options)).removeClass('placeholder')
$('#copy-password').prop('disabled', false)
return false
}
const settings = window.localStorage.getItem('settings')
if (settings) {
try {
loadSettings(JSON.parse(settings))
} catch (e) {
console.log(e)
}
}
if (window.crypto && window.crypto.getRandomValues) {
$('#too-old').hide()
$('#run-generator').click(() => {
const options = $options.serializeObject()
$output.text(generate(options)).removeClass('placeholder')
$('#copy-password').prop('disabled', false)
return false
})
$('#run-generator').click(generatePassword)
$('#save-settings').click(() => {
const options = $options.serializeObject()
@ -80,14 +91,6 @@ $(() => {
$options.find('select, input').change(updateBitMeter)
$options.find('input[type=number]').on('input', updateBitMeter)
updateBitMeter()
}
const settings = window.localStorage.getItem('settings')
if (settings) {
try {
loadSettings(JSON.parse(settings))
} catch (e) {
console.log(e)
}
generatePassword()
}
})