-
Notifications
You must be signed in to change notification settings - Fork 0
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
[2주차 기본/심화/생각 과제 ] 웨비의 사진관 😋/가계부 #2
base: main
Are you sure you want to change the base?
Changes from all commits
fec2a47
26327ed
b6c0f2e
78b8f37
132c19a
fcce624
46c2b02
6730bf3
3392960
9b47c4d
796f96a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"liveServer.settings.port": 5501 | ||
} | ||
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,70 @@ | ||||||||||||
import {HISTORY_CATEGORY} from './initial.js'; | ||||||||||||
|
||||||||||||
const listIn = document.getElementById("list_in"); | ||||||||||||
const listOut = document.getElementById("list_out"); | ||||||||||||
|
||||||||||||
/*최초 렌더링*/ | ||||||||||||
HISTORY_CATEGORY.forEach((element)=>{ | ||||||||||||
addCategory(element); | ||||||||||||
}); | ||||||||||||
|
||||||||||||
/*카테고리 화면에 추가*/ | ||||||||||||
function addCategory(element){ | ||||||||||||
const list = document.createElement("li"); | ||||||||||||
|
||||||||||||
list.innerHTML = ` | ||||||||||||
<span>${element.name}</span> | ||||||||||||
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. 템플릿 리터럴 활용 조아요👏🏻👏🏻 |
||||||||||||
`; | ||||||||||||
|
||||||||||||
element.type === "input" | ||||||||||||
? listIn.appendChild(list) | ||||||||||||
: listOut.appendChild(list); | ||||||||||||
} | ||||||||||||
|
||||||||||||
/*새 카테고리 생성*/ | ||||||||||||
const inCategory = document.getElementById("categorypg_input"); | ||||||||||||
const outCategory = document.getElementById("categorypg_output"); | ||||||||||||
|
||||||||||||
function createCateogry(element){ | ||||||||||||
if(element.keyCode === 13){ | ||||||||||||
Comment on lines
+28
to
+29
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.
Suggested change
여기는 event 객체를 받아오는거니까, e나 event로 변수명을 지어줘야 event객체를 사용하고 있구나 한 눈에 알아보기 쉽겠죠 ?! |
||||||||||||
let tempVal = {}; | ||||||||||||
|
||||||||||||
element.target.id === "categorypg_input" | ||||||||||||
? tempVal.type = "input" | ||||||||||||
: tempVal.type = "output"; | ||||||||||||
Comment on lines
+32
to
+34
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.
Suggested change
요렇게 사용하면 된답니당 ~! |
||||||||||||
|
||||||||||||
tempVal.name = element.target.value; | ||||||||||||
|
||||||||||||
addCategory(tempVal); | ||||||||||||
addStorage(tempVal); | ||||||||||||
} | ||||||||||||
} | ||||||||||||
|
||||||||||||
/*로컬 저장소에 업데이트*/ | ||||||||||||
function addStorage(element){ | ||||||||||||
localStorage.setItem(localStorage.length, JSON.stringify(element)); | ||||||||||||
} | ||||||||||||
Comment on lines
+44
to
+46
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. key 값을 현재 로컬스토리지 length로 줘서 아이템 추가될때마다 순차적으로 인덱스 부여받도록 한 건가?? 신박하다😮 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. 엉,,ㅋㅋㅋ key 값을 도저히 뭘로 줘야될 지 모르겠더라고,,!!! 먼가 symbol을 써도 될 것 같기도 하고?! 일단 저 때는 제 최선이었슴다.... 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. 보통 key값은 해당 값이 무엇인지를 나타낼 수 있는 값으로 지정해줘요 ! 그래야 각 값의 key가 뭔지 매번 보지 않고, 해당하는 명명값만을 가지고 getItem을 할 수 있으니까용 ! |
||||||||||||
|
||||||||||||
inCategory.addEventListener("keypress",createCateogry); | ||||||||||||
outCategory.addEventListener("keypress",createCateogry); | ||||||||||||
|
||||||||||||
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. 키햐,,,심화과제 팜미,,, 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. 요기 createCateogry 부분 스펠링 오타 있어.....ㅎ 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. 오우싯~ㅋ;; 민망이슈;; 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. 현재 keypress는 deprecated된 이벤트리스너여서 keydown사용을 권장합니다! |
||||||||||||
/*카테고리 값 불러오기*/ | ||||||||||||
function loadCategory(){ | ||||||||||||
let keys = Object.keys(localStorage); | ||||||||||||
|
||||||||||||
for (let key of keys){ | ||||||||||||
let objOption = document.createElement("li"); | ||||||||||||
Comment on lines
+55
to
+56
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. 함수형 프로그래밍을 위해 forEach사용을 권장합니다! |
||||||||||||
let tempObj = JSON.parse(localStorage.getItem(key)); | ||||||||||||
|
||||||||||||
let type = tempObj.type; | ||||||||||||
let name = tempObj.name; | ||||||||||||
|
||||||||||||
objOption.innerHTML = name; | ||||||||||||
|
||||||||||||
type === "input" | ||||||||||||
?listIn.appendChild(objOption) | ||||||||||||
:listOut.appendChild(objOption); | ||||||||||||
}; | ||||||||||||
} | ||||||||||||
|
||||||||||||
loadCategory(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> | ||
<html lang="ko"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="sub-style.css"> | ||
<title>돈쪽이의 카테고리 관리</title> | ||
</head> | ||
<body> | ||
<header> | ||
<h1>돈쪽이의 카테고리 관리</h1> | ||
</header> | ||
<main> | ||
<section class="category"> | ||
<h2>수입 카테고리</h2> | ||
<section> | ||
<ul class="category_list" id="list_in"> | ||
</ul> | ||
<div class="insert_category"> | ||
<label for="categorypg_input">추가</label> | ||
<input type="text" name="categorypg_input" id="categorypg_input"/> | ||
</div> | ||
</section> | ||
</section> | ||
<hr> | ||
<section class="category"> | ||
<h2>지출 카테고리</h2> | ||
<section> | ||
<ul class="category_list" id="list_out"> | ||
</ul> | ||
<div class="insert_category"> | ||
<label for="categorypg_output">추가</label> | ||
<input type="text" name="categorypg_output" id="categorypg_output"/> | ||
</div> | ||
</section> | ||
</section> | ||
</main> | ||
<footer> | ||
<a href="./index.html"><img src="./home.png" class="btn" id="home_btn"></a> | ||
</footer> | ||
<script src="category-manage.js" type="module"></script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<!DOCTYPE html> | ||
<html lang="ko"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="main-style.css"> | ||
<title>돈쪽이의 가계부</title> | ||
</head> | ||
<body> | ||
<header> | ||
<h1>돈쪽이의 가계부</h1> | ||
</header> | ||
<main> | ||
<section id="asset"> | ||
<h2>나의 자산</h2> | ||
<span class="total_asset"></span> | ||
<div class="total_inout"> | ||
<span class="input" id="plus_ic">+</span><span class="input">-</span> | ||
| ||
<span class="output" id="minus_ic">-</span><span class="output">-</span> | ||
</div> | ||
</section> | ||
<hr> | ||
<section id="nav"> | ||
<nav id="nav_date"> | ||
<button><</button> | ||
<h3>10월 11일</h3> | ||
<button>></button> | ||
</nav> | ||
<div id="nav_list"> | ||
<span>내역 리스트</span> | ||
<div class="input_wrapper"> | ||
<input type="checkbox" id="input_box" name="input_box" checked /> | ||
<label for="input_box">수입</label> | ||
<input type="checkbox" id="output_box" name="output_box" checked /> | ||
<label for="output_box">지출</label> | ||
</div> | ||
</div> | ||
</section> | ||
<hr> | ||
<section id="list_wrapper"> | ||
<ul> | ||
</ul> | ||
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. 요기 빈 ul 안에는 js파일에서 무언가가 들어가는 곳인가여?! 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. 맞슴다!! 렌더링 하면서 리스트 항목이 들어가는 곳!! |
||
</section> | ||
</main> | ||
<section class="delete_modal"> | ||
<span>삭제하시겠습니까?</span> | ||
<div class="input_wrapper"> | ||
<button type="button" id="allow">예</button> | ||
<button type="button" id="reject">아니오</button> | ||
</div> | ||
</section> | ||
<section class="modal_wrapper"> | ||
<h2>내역 추가</h2> | ||
<div class="input_wrapper"> | ||
<input type="checkbox" id="input_modalbox" name="modalbox" checked /> | ||
<label for="input_modalbox">수입</label> | ||
<input type="checkbox" id="output_modalbox" name="modalbox" /> | ||
<label for="output_modalbox">지출</label> | ||
</div> | ||
<div class="modal_type" id="select_input"> | ||
<label for="category_input">카테고리</label> | ||
<select name="category" id="category_input"> | ||
<option value="" selected disabled hidden>선택해주세요</option> | ||
<option value="알바">알바</option> | ||
<option value="용돈">용돈</option> | ||
</select> | ||
</div> | ||
<div class="modal_type" id="select_output"> | ||
<label for="category_output">카테고리</label> | ||
<select name="category" id="category_output"> | ||
<option value="" selected disabled hidden>선택해주세요</option> | ||
<option value="food">음식</option> | ||
<option value="shop">쇼핑</option> | ||
</select> | ||
</div> | ||
<div class="modal_type"> | ||
<label for="amount">금액</label> | ||
<input type="text" name="amount" id="amount"/> | ||
</div> | ||
<div class="modal_type"> | ||
<label for="title">내역</label> | ||
<input type="text" name="title" id="title"/> | ||
</div> | ||
<button type="button" id="save">저장하기</button> | ||
<button type="button" id="close">닫기</button> | ||
</section> | ||
<footer> | ||
<button type="button" class="btn" id="add_btn">+</button> | ||
<a href="./category.html"><img src="./category.png" class="btn" id="category_btn"></a> | ||
</footer> | ||
<script src="main.js" type="module"></script> | ||
<script src="modal.js" type="module"></script> | ||
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.
|
||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
export const INIT_BALANCE = 0; | ||
|
||
export const HISTORY_LIST = [ | ||
{ | ||
category: "음식", | ||
title: "GS25 코엑스점", | ||
type: "output", | ||
amount: 3100, | ||
}, | ||
{ | ||
category: "음식", | ||
title: "그릭 요거트", | ||
type: "output", | ||
amount: 12000, | ||
}, | ||
{ | ||
category: "알바", | ||
title: "현대 백화점", | ||
type: "input", | ||
amount: 120000, | ||
}, | ||
{ | ||
category: "쇼핑", | ||
title: "지그재그", | ||
type: "output", | ||
amount: 24500, | ||
} | ||
]; | ||
|
||
export const HISTORY_CATEGORY = [ | ||
{ | ||
type: "input", | ||
name: "알바" | ||
}, | ||
{ | ||
type: "input", | ||
name: "용돈" | ||
}, | ||
{ | ||
type: "output", | ||
name: "음식" | ||
}, | ||
{ | ||
type: "output", | ||
name: "쇼핑" | ||
} | ||
]; | ||
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. 상수파일 따로 뺀거 구웃-! 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. 22!!!!👍🏻👍🏻 |
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.
오엥?
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.
어라 5500포트로 다른 거 돌아가고 잇나...?
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.
켈록켈록...아마 두 개를 동시에 돌렸나 봄...큼큼큼