function CountDown() {
var count = 4,
tmID,
atari = Math.floor(Math.random()*10) ;
hani = document.querySelectorAll("div");
infobox = document.getElementById("start"),
owari = document.getElementById("dore");
function countDown() {
if (--count == 0) {
owari.innerHTML = "しゅーりょー";
owari.setAttribute("class", "bad")
hani[atari].removeEventListener("click", stopCountDown, false) //あたり押したらカウントダウン止める?
} else {
owari.innerHTML = count + "秒前なのです";
tmID = setTimeout(countDown, 1000); //1000 = 1秒
}
}
function startCountDown() {
tmID = setTimeout(countDown, 1000);
infobox.removeEventListener("click", startCountDown, false);
hani[atari].addEventListener("click", stopCountDown, false);
console.timeLog(atari+1+"番なのです") //コンソールに表示
}
function stopCountDown() {
clearTimeout(tmID);
owari.innerHTML = "見つかったなり";
owari.setAttribute("class", "hit");
}
infobox.addEventListener("click", startCountDown, false);
};
document.addEventListener("DOMContentLoaded", CountDown, false);