-
Notifications
You must be signed in to change notification settings - Fork 20
[유선향] - sprint4 #40
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
The head ref may contain hidden characters: "part1-\uC720\uC120\uD5A5-sprint4"
[유선향] - sprint4 #40
Changes from all commits
95bf2ff
e2acf9c
2e65279
6bf93ef
d630e4d
d9c4ff6
22f3069
b416887
9cb5029
195c9d1
9411055
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 |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| 코드잇 프론트 엔드 13기 유선향 스프린트 미션 3입니다. | ||
| 제출일 12월 27일 | ||
| 13기 프론트엔드 개인 스프린트 미션4 | ||
| 제출일 12월 3일 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "name": "13-sprint-mission", | ||
| "version": "1.0.0", | ||
| "description": "13기 프론트엔드 개인 스프린트 미션4 제출일 12월 3일", | ||
| "main": "", | ||
| "type": "module", | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1" | ||
| }, | ||
| "keywords": [], | ||
| "author": "", | ||
| "license": "ISC" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> </head> | ||
| <body> | ||
| signin페이지 | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,105 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const Email = document.querySelector("#user_email"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const password = document.querySelector("#login_password"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const Error_message = document.querySelectorAll(".error_message"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const Btn = document.querySelector("#Btn"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const eyes = document.querySelector("i"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const Input = document.querySelectorAll(".input_area"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const pattern = /^[A-Za-z0-9_\.\-]+@[A-Za-z0-9\-]+\.[A-za-z0-9\-]+/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.addEventListener("DOMContentLoaded", () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Button_inactive(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); //초기 Button 상태 설정 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Btn.addEventListener("click", () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!Btn.disabled) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| location.href = "./items.html"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //이메일 유효성 검사 함수 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function email_check(email) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return pattern.test(email); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //비밀번호 8자리 이상 체크 함수 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function password_checked(password) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return password.length > 7; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //a태그 존재시 삭제 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function tag_delete(i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let isTag = Error_message[i].querySelector("a"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (isTag) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Error_message[i].lastChild.remove(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function Email_focus_out(e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Collaborator
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
일반적으로 변수는 명사, 함수는 동사로 지어요. 함수의 경우 다음과 같은 단어들이 접두사가 될 수 있어요:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let input = e.target.value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tag_delete(0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!email_check(input)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| e.target.classList.add("input_red_border"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const text = document.createElement("a"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (input == "") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| text.textContent = "이메일을 입력해주세요"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Error_message[0].prepend(text); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| text.textContent = "잘못된 이메일 형식 입니다."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Error_message[0].prepend(text); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| e.target.classList.remove("input_red_border"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //비밀번호 함수 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function Password_focus_out(e, x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let input = e.target.value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tag_delete(x); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!password_checked(input)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| e.target.classList.add("input_red_border"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const text = document.createElement("a"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| text.textContent = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input === "" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? "비밀번호를 입력해주세요" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : "비밀번호를 8자 이상 입력해주세요"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Error_message[x].prepend(text); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| e.target.classList.remove("input_red_border"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+56
to
+70
Collaborator
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
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //버튼 함수 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function Button_inactive(e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| switch (email_check(Email.value) && password_checked(password.value)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case true: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Btn.disabled = false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case false: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Btn.disabled = true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+74
to
+83
Collaborator
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
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //패스워드 숨김 핸들러 함수 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function Password_hide(e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (password.type == "password") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| password.type = "text"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| e.target.classList.remove("fa-eye-slash"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| e.target.classList.add("fa-eye"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| password.type = "password"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| e.target.classList.remove("fa-eye"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| e.target.classList.add("fa-eye-slash"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //이벤트 핸들러 등록 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| password.addEventListener("focusout", Password_focus_out); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Email.addEventListener("focusout", Email_focus_out); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| password.addEventListener("focusout", (e) => Password_focus_out(e, 1)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| eyes.addEventListener("click", Password_hide); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Input.forEach((input) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input.addEventListener("change", Button_inactive); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
줄임말 보다는 의도를 명확히 전달해보는건 어떨까요?
물론
btn,pw등 편의를 위해서 사용되기도 하나, 명확한 클래스 이름을 사용하시는게 더욱 의도된 바를 전달하기 쉽습니다.이는 "닌자 코드"에 해당하는 문법입니다:
약어 사용하기
팀에 한 글자 짜리 변수나 모호한 변수명을 사용하지 못하게 하는 제약이 있다면 약어를 쓰는 기지를 발휘하세요. 변수명은 짧을수록 좋으니까요.
예시:
list → lst.
userAgent → ua.
browser → brsr.
등등…
모든 걸 줄여서 당신의 코드를 읽을 가치가 있는 직감이 뛰어난 개발자만 유지보수를 담당 할 수 있게 해 놓읍시다.
위 문서는 "이렇게 해라 !"가 아니라, "이를 지양하자 !"라는 것으로 작성된 문서 내용입니다. 😊
물론
oAuth(Open Authorization),sms(Short Message Service) 와 같이 내용이 길어서 통상적으로 줄임말을 사용하는 경우도 있기는 하기에 무조건 풀 텍스트를 사용하자 라는 차원은 아님을 전달드립니다. 😊