Move javascript to separate file.
This commit is contained in:
parent
3296aa1765
commit
37599d7a4f
2 changed files with 45 additions and 46 deletions
47
index.html
47
index.html
|
@ -43,51 +43,6 @@
|
|||
<script src="js/jquery.corner.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>
|
||||
|
|
44
js/passwd.js
Normal file
44
js/passwd.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
$(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();
|
||||
}
|
||||
});
|
Loading…
Reference in a new issue