Created
May 17, 2021 05:55
-
-
Save SkyLightQP/eb7b876c74e3ac37bb3f27dd4e899440 to your computer and use it in GitHub Desktop.
수업 끝날 때까지 남은 시간
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="ko"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>nojam</title> | |
<style> | |
@font-face { | |
font-family: "BMEuljiro10yearslater"; | |
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/[email protected]/BMEuljiro10yearslater.woff") | |
format("woff"); | |
font-weight: normal; | |
font-style: normal; | |
} | |
* { | |
box-sizing: border-box; | |
margin: 0; | |
padding: 0; | |
} | |
body { | |
background-color: hsl(0, 0%, 95%); | |
color: #111; | |
} | |
h1 { | |
font-size: 8rem; | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
transform: translate(-50%, -50%); | |
font-family: "BMEuljiro10yearslater", "sans-serif"; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>00:00:00</h1> | |
<script> | |
const text = document.querySelector("h1"); | |
const endTime = new Date(); | |
endTime.setHours(endTime.getDay() === 1 ? 15 : 16); | |
endTime.setMinutes(50); | |
function getLeftTime() { | |
const leftTime = Math.floor(Math.abs(new Date() - endTime) / 1000); | |
const hour = Math.floor(leftTime / 3600); | |
const min = Math.floor(leftTime / 60) % 60; | |
const sec = leftTime % 60; | |
const time = [hour, min, sec] | |
.map((s) => s.toString().padStart(2, "0")) | |
.join(":"); | |
text.innerHTML = time; | |
requestAnimationFrame(getLeftTime); | |
} | |
requestAnimationFrame(getLeftTime); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment