Created
July 14, 2011 14:50
-
-
Save basyura/1082597 to your computer and use it in GitHub Desktop.
timer その 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script> | |
var timer_ = null; | |
var start_ = null; | |
var background_ = null; | |
function initialize() { | |
background_ = document.body.background; | |
} | |
function start() { | |
start_ = Date.now(); | |
timer_ = setInterval(down , 100); | |
} | |
function stop() { | |
clearTimeout(timer_); | |
} | |
function reset() { | |
clearTimeout(timer_); | |
document.getElementById("timer").innerHTML = 120; | |
} | |
function down() { | |
var diff = Date.now() - start_; | |
var txt = parseInt(((120000 - diff) / 1000).toString().split("\.")[0],10); | |
if (txt == 0) { | |
stop(); | |
return; | |
} | |
if (document.body.background != background_) { | |
document.body.background = background_; | |
back_flg_ = true; | |
} | |
if (txt % 10 == 0) { | |
document.body.background = ''; | |
} | |
document.getElementById("timer").innerHTML = txt; | |
} | |
</script> | |
</head> | |
<body background="yamiwall.jpeg" bgcolor="black" onload="initialize()"> | |
<div align="center"> | |
<input type="button" onclick="start()" value="start"> | |
<input type="button" onclick="stop()" value="stop"> | |
<input type="button" onclick="reset()" value="reset"> | |
</div> | |
<div align="center"> | |
<span id="timer" style="color:white;font-size:360pt;">120</span> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment