Skip to content

Instantly share code, notes, and snippets.

@satos---jp
Created April 19, 2017 14:15
Show Gist options
  • Save satos---jp/9061d69f32b73ea0b7cf9a6e515f3296 to your computer and use it in GitHub Desktop.
Save satos---jp/9061d69f32b73ea0b7cf9a6e515f3296 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>igoclock</title>
<script>
function hoge(){
if(document.timer.player.value>=0){
document.timer.remain.value -= 1;
if(document.timer.remain.value < 0){
document.timer.player.value = -1;
document.body.style.backgroundColor = 'red';
}
}
}
window.onload = function(){
setInterval("hoge()",1000);
document.onkeyup = function(e){
var pn = document.timer.player.value;
if(pn>=0){
var tpn = pn;
if('qazwsxedcrfv'.includes(e.key)){
tpn = 1;
}
else if('[]\\@:/p;.ol,'.includes(e.key)){
tpn = 0;
}
if(document.timer.player.value != tpn){
document.timer.remain.value = document.timer.interval.value;
document.timer.player.value = tpn;
}
}
}
}
</script>
</head>
<body>
<form name="timer">
<input type="text" name="remain" value="-1" style="font-size:300px;width:100%">
<input type="text" name="player" value="-1" style="font-size:100px;width:100%">
<input type="text" name="interval" value="-1" style="font-size:30px;width:100%">
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment