// external.js
var doc, bod, htm, C, E, T; // for use on other loads
addEventListener('load', function(){
doc = document; bod = doc.body; htm = doc.documentElement;
C = function(tag){
return doc.createElement(tag);
}
E = function(id){
return doc.getElementById(id);
}
T = function(tag){
return doc.getElementByTagName(tag);
}
var form = E('form'), fS = form.style, sub = E('sub'), tO;
function tF(){
// code within this func inside logout ajax
fS.display = 'block';
}
form.addEventListener('submit', function(ev){
ev.preventDefault();
});
sub.addEventListener('click', function(){
// run code within this func inside login ajax
fS.display = 'none'; E('un').value = E('pw').value = '';
tO = setTimeout(tF, 10000);
addEventListener('mousemove', function(){
if(tO)clearTimeout(tO);
tO = setTimeout(tF, 10000);
});
});
form.addEventListener('keydown', function(ev){
if(ev.keyCode === 13)sub.click();
});
});
/* external.css */
html,body{
background:#000; padding:0; margin:0;
}
.main{
width:980px; background:#fff; margin:0 auto;
}
#form{
width:250px; background:green; padding:10px;
}
#form>label,#form>input{
display:block;
}
#form>label{
float:left; width:100px; color:#fff;
}
#form>input{
width:140px; margin-bottom:10px;
}
#form>#sub{
width:70px; height:30px; margin:0 auto;
}
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<meta http-equiv='content-type' content='text/html;charset=utf-8' />
<title>Lockout</title>
<link type='text/css' rel='stylesheet' href='external.css' />
<script type='text/javascript' src='external.js'></script>
</head>
<body>
<div class='main'>
<form id='form'>
<label for='un'>USERNAME</label><input id='un' name='un' type='text' value='' />
<label for='pw'>PASSWORD</label><input id='pw' name='pw' type='password' value='' />
<input id='sub' type='button' value='LOGIN' />
</form>
</div>
</body>
</html>
'mousemove'の中で' setTImeout'を実行します。それを 'clearTimeout'にして、マウスが動くたびにリセットしてください。 – PHPglue