commit
6286afe980
4 changed files with 45 additions and 52 deletions
50
index.html
50
index.html
|
@ -39,55 +39,9 @@
|
|||
<input type="text" id="password" readyonly="readyonly" tabindex="-1" />
|
||||
</div>
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script>
|
||||
<script src="js/jquery.corner.min.js"></script>
|
||||
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
|
||||
<script src="js/jquery.md5.min.js"></script>
|
||||
<script src="js/rules.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('input').corner('round 4px');
|
||||
$('button').corner('round 4px');
|
||||
$('#box').corner('round bottom');
|
||||
|
||||
$('#root').focus();
|
||||
|
||||
$('#generate input').on('input', function() {
|
||||
var root = $('#root').val();
|
||||
var master = $('#master').val()
|
||||
var hash = $.md5(root + master);
|
||||
|
||||
hash = hash.replace(/[a-f]/, function(alpha) {
|
||||
return alpha.toUpperCase();
|
||||
});
|
||||
|
||||
if(root in special) {
|
||||
$('#password').val(special[root](hash));
|
||||
} 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();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script src="js/passwd.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
1
js/jquery.corner.min.js
vendored
1
js/jquery.corner.min.js
vendored
File diff suppressed because one or more lines are too long
40
js/passwd.js
Normal file
40
js/passwd.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
$(document).ready(function() {
|
||||
$('#root').focus();
|
||||
});
|
||||
|
||||
$('#generate input').on('input', function() {
|
||||
hash = generatePassword($('#root').val(), $('#master').val());
|
||||
|
||||
$('#password').val(specialCase($('#root').val(), hash));
|
||||
});
|
||||
|
||||
function generatePassword(root, master) {
|
||||
return $.md5(root + master).replace(/[a-f]/, function(alpha) {
|
||||
return alpha.toUpperCase();
|
||||
});
|
||||
}
|
||||
|
||||
function specialCase(root, hash) {
|
||||
return (special[root] != undefined) ? special[root](hash) : 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();
|
||||
}
|
||||
});
|
Loading…
Reference in a new issue