-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[1주차] 김지원 미션 제출합니다. #3
Open
geeoneee
wants to merge
18
commits into
CEOS-Developers:master
Choose a base branch
from
geeoneee:geeoneee
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+239
−3
Open
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
3ff0cd1
clock 생성
geeoneee a19b164
todolist update
geeoneee 56799cf
todolist 삭제 기능
geeoneee 0cc6068
todolist 저장 기능
geeoneee a1d01a9
todo 삭제기능 수정
geeoneee 7698c65
+버튼 기능 추가
geeoneee 23cacbd
html 구조
geeoneee d67be81
script.js 정리
geeoneee fd53864
feat: add DoneTodo
geeoneee 3e72996
style: clock css 적용
geeoneee 8039cd3
style: style.css 수정
geeoneee 2c59c49
style : background image, color
geeoneee 903ed80
style : style.css 수정
geeoneee e3b0e16
코드 복사
geeoneee fd56e71
css 최종 수정
geeoneee 394f342
배포용
geeoneee 9e49845
배포확인
geeoneee a197552
fix: 배경 주소 변경
geeoneee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
script.js 정리
commit d67be81fc595cd8094a4c0dc78e3ecb17b58ee87
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
const clock = document.querySelector("h1#clock"); | ||
const addButton = document.getElementById("add-button"); | ||
const toDoForm = document.getElementById("todo-form"); | ||
const toDoInput = toDoForm.querySelector("input"); | ||
const toDoList = document.getElementById("todo-list"); | ||
const TODOS_KEY = "todos"; | ||
const savedToDos = localStorage.getItem(TODOS_KEY); | ||
let toDos = []; | ||
|
||
addButton.addEventListener("click", handleAddButtonClick); | ||
toDoForm.addEventListener("submit", handleToDoSubmit); | ||
|
||
function getClock() { | ||
const date = new Date(); | ||
|
@@ -25,16 +34,21 @@ function handleAddButtonClick() { | |
} | ||
} | ||
|
||
addButton.addEventListener("click", handleAddButtonClick); | ||
|
||
function saveToDos() { | ||
localStorage.setItem("todos", JSON.stringify(toDos)); | ||
} | ||
|
||
if (savedToDos !== null) { | ||
const parsedToDos = JSON.parse(savedToDos); | ||
toDos = parsedToDos; | ||
parsedToDos.forEach(paintToDo); | ||
} | ||
|
||
function deleteToDo(event) { | ||
const li = event.target.parentElement; | ||
li.remove(); | ||
toDos = toDos.filter((toDo) => toDo.id !== parseInt(li.id)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. filter 함수를 통해 깔끔하게 코드를 구현하신것 같아요 ! 👍 |
||
saveToDos(); | ||
} | ||
|
||
function paintToDo(newTodo) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. paintTodo 보다 더 직관적인 함수명을 사용하는 것이 더 보기 쉬울 것 같아요 ! |
||
|
@@ -50,14 +64,6 @@ function paintToDo(newTodo) { | |
toDoList.appendChild(li); | ||
} | ||
|
||
const toDoForm = document.getElementById("todo-form"); | ||
const toDoInput = toDoForm.querySelector("input"); | ||
const toDoList = document.getElementById("todo-list"); | ||
|
||
const TODOS_KEY = "todos"; | ||
|
||
let toDos = []; | ||
|
||
function handleToDoSubmit(event) { | ||
event.preventDefault(); | ||
const newTodo = toDoInput.value; | ||
|
@@ -70,13 +76,3 @@ function handleToDoSubmit(event) { | |
paintToDo(newTodoObj); | ||
saveToDos(); | ||
} | ||
|
||
toDoForm.addEventListener("submit", handleToDoSubmit); | ||
|
||
const savedToDos = localStorage.getItem(TODOS_KEY); | ||
|
||
if (savedToDos !== null) { | ||
const parsedToDos = JSON.parse(savedToDos); | ||
toDos = parsedToDos; | ||
parsedToDos.forEach(paintToDo); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이렇게 선언해서 쉽게 이해할 수 있게 만들어서 좋은 것 같아요. 다시 사용하기도 좋을 것 같아요 저도 사용해야겠어요