2013-08-26 23:57:28 -04:00
|
|
|
$(document).ready(function() {
|
|
|
|
$('#root').focus();
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#generate input').on('input', function() {
|
2013-08-27 00:59:21 -04:00
|
|
|
hash = generatePassword($('#root').val(), $('#master').val());
|
2013-08-26 23:57:28 -04:00
|
|
|
|
2013-08-27 00:59:21 -04:00
|
|
|
$('#password').val(specialCase($('#root').val(), hash));
|
|
|
|
});
|
|
|
|
|
|
|
|
function generatePassword(root, master) {
|
|
|
|
return $.md5(root + master).replace(/[a-f]/, function(alpha) {
|
2013-08-26 23:57:28 -04:00
|
|
|
return alpha.toUpperCase();
|
|
|
|
});
|
2013-08-27 00:59:21 -04:00
|
|
|
}
|
2013-08-26 23:57:28 -04:00
|
|
|
|
2013-08-27 00:59:21 -04:00
|
|
|
function specialCase(root, hash) {
|
|
|
|
return (special[root] != undefined) ? special[root](hash) : hash;
|
|
|
|
}
|
2013-08-26 23:57:28 -04:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
});
|