Reduce function sizes
This commit is contained in:
parent
9f93b82223
commit
6c27ee0789
1 changed files with 10 additions and 8 deletions
18
js/passwd.js
18
js/passwd.js
|
@ -3,18 +3,20 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#generate input').on('input', function() {
|
$('#generate input').on('input', function() {
|
||||||
var hash = $.md5($('#root').val() + ('#master').val());
|
hash = generatePassword($('#root').val(), $('#master').val());
|
||||||
|
|
||||||
hash = hash.replace(/[a-f]/, function(alpha) {
|
$('#password').val(specialCase($('#root').val(), hash));
|
||||||
|
});
|
||||||
|
|
||||||
|
function generatePassword(root, master) {
|
||||||
|
return $.md5(root + master).replace(/[a-f]/, function(alpha) {
|
||||||
return alpha.toUpperCase();
|
return alpha.toUpperCase();
|
||||||
});
|
});
|
||||||
|
|
||||||
if($('#root').val() in special) {
|
|
||||||
$('#password').val(special[$('#root').val()](hash));
|
|
||||||
} else {
|
|
||||||
$('#password').val(hash);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
function specialCase(root, hash) {
|
||||||
|
return (special[root] != undefined) ? special[root](hash) : hash;
|
||||||
|
}
|
||||||
|
|
||||||
var currentFocus;
|
var currentFocus;
|
||||||
var lastFocus;
|
var lastFocus;
|
||||||
|
|
Loading…
Reference in a new issue