Skip to content

Commit

Permalink
노마드(4.6~5.2)
Browse files Browse the repository at this point in the history
  • Loading branch information
syj318 committed Aug 22, 2024
1 parent 1a1f6b6 commit 0b3f569
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 25 deletions.
16 changes: 0 additions & 16 deletions yoojin/노마드/app.js

This file was deleted.

Empty file added yoojin/노마드/css/style.css
Empty file.
13 changes: 7 additions & 6 deletions yoojin/노마드/index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="css/style.css" />
<title>Momentum App</title>
</head>
<body>
<form id="login-form"></form>
<h1 id="greeting" class="hidden"></h1>
<script src="app.js"></script>
<form class="hidden" id="login-form"></form>

<h2 id="clock">00:00:00</h2>
<h1 class="hidden" id="greeting"></h1>
<script src="js/greetings.js"></script>
<script src="js/clock.js"></script>
</body>
</html>
11 changes: 11 additions & 0 deletions yoojin/노마드/js/clock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const clock = document.querySelector("h2#clock");

function getClock() {
const date = new Date();
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
const seconds = String(date.getSeconds()).padStart(2, "0");
clock.innerText = `${hours}:${minutes}:${seconds}`;
}
getClock();
setInterval(getClock, 1000);
28 changes: 28 additions & 0 deletions yoojin/노마드/js/greetings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const loginForm = document.querySelector("#login-form ");
const loginInput = document.querySelector("#login-form input");
const greeting = document.querySelector("#greeting");

const HIDDEN_CLASSNAME = "hidden";
const USERNAME_KEY = "username";

function onLoginSubmit(event) {
event.preventDefault();
loginForm.classList.add(HIDDEN_CLASSNAME);
const username = loginInput.value;
localStorage.setItem("USERNAME_KEY", username);
paintingGreetings(username);
}

function paintingGreetings(username) {
const username = localStorage.getItem(USERNAME_KEY);
greeting.innerText = "Hello" + username;
greeting.classList.remove(HIDDEN_CLASSNAME);
}
const savedUsername = localStorage.getItem("USERNAME_KEY");

if (savedUsername === null) {
loginForm.classList.remove(HIDDEN_CLASSNAME);
loginForm.addEventListener("submit", onLoginSubmit);
} else {
paintingGreetings(savedUsername);
}
3 changes: 0 additions & 3 deletions yoojin/노마드/style.css

This file was deleted.

0 comments on commit 0b3f569

Please sign in to comment.