From: Jan Michel Date: Wed, 19 Oct 2016 14:10:42 +0000 (+0200) Subject: update with finer time X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=c1ffbc337a1df04794fb972826d8c6e12430bbc6;p=labtools.git update with finer time --- diff --git a/timer/index.htm b/timer/index.htm index 29cdf3b..194a07a 100644 --- a/timer/index.htm +++ b/timer/index.htm @@ -13,26 +13,30 @@ var TO; var starttime = 100; + var timer = 0; function start() { starttime = document.getElementById('set').value; + document.getElementById('tim').className=''; if(!isInt(starttime)) { document.getElementById('tim').innerHTML = 'X'; return; } - document.getElementById('tim').innerHTML = starttime; + starttime = starttime*60; + timer = starttime+10; clearInterval(TO); - TO = setInterval('update()',60000); + TO = setInterval('update()',10000); + update(); } function update() { - x = document.getElementById('tim').innerHTML; - x = x-1; - document.getElementById('tim').innerHTML = x; + timer = timer-10; + document.getElementById('tim').innerHTML = Math.ceil(timer/60); + document.getElementById('timsmall').innerHTML = Math.floor(timer/60)+':'+((timer%60)?(timer%60):'00'); - if(x<= 0) document.getElementById('tim').className='shutup'; - else if(x <= starttime/10) document.getElementById('tim').className='hurry'; - else if(x<=starttime/3) document.getElementById('tim').className='warn'; + if(timer<= 0) document.getElementById('tim').className='shutup'; + else if(timer <= starttime/10) document.getElementById('tim').className='hurry'; + else if(timer<=starttime/3) document.getElementById('tim').className='warn'; else document.getElementById('tim').className=''; //if (x==0) {clearInterval(TO);} } @@ -45,6 +49,7 @@
00
+
diff --git a/timer/style.css b/timer/style.css index 91a9a51..22d4056 100644 --- a/timer/style.css +++ b/timer/style.css @@ -25,6 +25,14 @@ text-align:center; margin:auto; } +#timsmall { + font-size:5vw; + position:absolute; + bottom:10px; + width:100%; + text-align:center; + } + .warn{ background:yellow; color:black;