(() => {
function CountDown() {
var count = 10, tmID, info = document.getElementById("timeout");
function countDown() {
if (--count == 0) {
info.innerHTML = "ぼかーん";
} else {
info.innerHTML = count + "秒前";
tmID = setTimeout(countDown, 1000);
}
}
function startCountDown() {
tmID = setTimeout(countDown, 1000);
info.removeEventListener("click", startCountDown, false);
info.addEventListener("click", stopCountDown, false);
}
function stopCountDown() {
clearTimeout(tmID);
info.innerHTML = "停めました。";
info.removeEventListener("click", stopCountDown, false);
}
info.addEventListener("click", startCountDown, false);
}
document.addEventListener("DOMContentLoaded", CountDown, false);
})();