120-timer

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

index.html (942B)


      1 <!DOCTYPE html>
      2 <html lang="ja">
      3 	<head>
      4 		<meta charset="utf-8">
      5 		<title>120-timer</title>
      6 	</head>
      7 	<body>
      8 		<header>
      9 			<h1>120-timer</h1>
     10 			<h3>by minerva_juppiter</h3>
     11 		</header>
     12 		<nav>
     13 			<a href="https://www.minervajuppiter.net">My Home Page</a>
     14 			/
     15 			<a href="https://github.com/minerva-jupiter/120-timer">repository</a>
     16 		</nav>
     17 		<article>
     18 			<h2><span id="sec"></span></h2>
     19 			<p>second left</p>
     20 		</article>
     21 		<script>
     22 			const sec = document.getElementById("sec");
     23 			let startTime;
     24 			function initialise(){
     25 				startTime = new Date();
     26 				console.log("initialised")
     27 			}
     28 			function countdown(){
     29 				const now = new Date();
     30 				const leastTime = now.getTime() - startTime.getTime() 
     31 				if(leastTime >= 120000){
     32 					console.log("time is up");
     33 					alert("time is up");
     34 				}else{
     35 					sec.innerHTML = Math.trunc(leastTime / 1000);
     36 				}
     37 			}
     38 			initialise();
     39 			setInterval(countdown,1000);
     40 		</script>
     41 	</body>
     42 </html>