Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
mnmn05 committed Aug 29, 2024
1 parent dcc0041 commit 2c28176
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 3 deletions.
7 changes: 5 additions & 2 deletions minkyong/JavaScript Study/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ <h1 id="greeting" class="hidden"></h1>

<h2 id="clock">00:00:00</h2>

<script src="app.js"></script>
<script src="clock.js"></script>
<script src="js/app.js"></script>
<script src="js/greetings.js"></script>
<script src="js/clock.js"></script>
<script src="js/background.js"></script>
<script src="js/todo.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const loginForm = document.querySelector("#login-form");
const loginInput = document.querySelector("#login-form input");
const greeting = document.querySelector("#greeting");

const HIDDEN_CLASSNAME = "hidden";


function onLoginSubmit(event){
event.preventDefalut();
Expand Down
7 changes: 7 additions & 0 deletions minkyong/JavaScript Study/js/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const images = ["0.jpeg", "1.jpeg", "2.jpeg"];
const chosenImage = images[Math.floor(Math.random() * images.length)];


const bgImage = document.createElement("img");
bgImage.src = `img/${chosenImage}`;
document.body.appendChild(bgImage);
File renamed without changes.
31 changes: 31 additions & 0 deletions minkyong/JavaScript Study/js/greetings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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) {
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);
}
11 changes: 11 additions & 0 deletions minkyong/JavaScript Study/js/todo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const toDoFrom = document.getElementById("todo-form");
const toDoInput = toDoFrom.querySelector("input");
const toDoList = document.getElementById("todo-list");

function handleToDoSubmit(event) {
event.preventDefault();
const newTodo = toDoInput.value;
toDoInput.value = "";
}

toDoFrom.addEventListener("submit", handleToDoSubmit);

0 comments on commit 2c28176

Please sign in to comment.