passwdgen/js/passwd.js

39 lines
813 B
JavaScript
Raw Normal View History

2013-08-26 23:57:28 -04:00
$(document).ready(function() {
$('#root').focus();
});
$('#generate input').on('input', function() {
2013-08-27 00:42:23 -04:00
var hash = $.md5($('#root').val() + ('#master').val());
2013-08-26 23:57:28 -04:00
hash = hash.replace(/[a-f]/, function(alpha) {
return alpha.toUpperCase();
});
2013-08-27 00:42:23 -04:00
if($('#root').val() in special) {
$('#password').val(special[$('#root').val()](hash));
2013-08-26 23:57:28 -04:00
} else {
$('#password').val(hash);
}
});
var currentFocus;
var lastFocus;
$(':input').focus(function() {
currentFocus = this;
});
$(document).keydown(function(e) {
var keycode = e.keycode || e.which;
if(keycode == 17 || keycode == 91) {
lastFocus = currentFocus;
$('#password').focus().select();
}
});
$(document).keyup(function(e) {
var keycode = e.keycode || e.which;
if(keycode == 17 || keycode == 91) {
lastFocus.focus();
}
});