-
Notifications
You must be signed in to change notification settings - Fork 0
moretall vaniljs todolist #1
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
base: moretall
Are you sure you want to change the base?
Changes from all commits
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,13 @@ | ||
| { | ||
| // See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
| // for the documentation about the tasks.json format | ||
| "version": "2.0.0", | ||
| "tasks": [ | ||
| { | ||
| "label": "openHtml", | ||
| "type": "shell", | ||
| "command": "index.html", | ||
| "problemMatcher": [] | ||
| } | ||
| ] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
|
|
||
|
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. 첫 줄을 비워두시는 이유가 있을까요?
Author
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. 아무도 보지 않은 것이라고 생각해서 엉망진창으로 코딩했네요.. |
||
| html{ | ||
| text-align: center; | ||
| font-style:italic; | ||
| } | ||
|
|
||
| input{ | ||
| width : 400px; | ||
| height : 50px; | ||
| font-size : x-large; | ||
| } | ||
|
|
||
| main{ | ||
| display:inline-block; | ||
| width : 400px; | ||
| } | ||
|
|
||
| input::placeholder{ | ||
| font-style:italic; | ||
| font-size: x-large; | ||
| font-weight : bold; | ||
| } | ||
| #createToDo{ | ||
| border: none; | ||
| margin : 0px; | ||
| box-shadow: 0 5px 10px rgba(0,0,0,0.5); | ||
| } | ||
|
|
||
| #contents{ | ||
| padding :0px; | ||
| text-align: center; | ||
| margin : 0px; | ||
| } | ||
|
|
||
| .content{ | ||
| box-shadow: 1px 1px 5px rgba(0,0,0,0.5); | ||
| text-align:left; | ||
| display: inline-block; | ||
| position: relative; | ||
| width : 400px; | ||
| height : 50px; | ||
|
|
||
| } | ||
|
|
||
| .content h1{ | ||
|
|
||
|
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. 가독성과 무관한 빈 줄은 제거해주세요. |
||
| margin : 0px | ||
| } | ||
|
|
||
| .destory{ | ||
| position : absolute; | ||
| top : 13px; | ||
| right :10px; | ||
| font-weight: inherit; | ||
| color: #cc9a9a; | ||
| } | ||
|
Comment on lines
+2
to
+56
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. ♻️ CSS property 표기의 일관성이 떨어지는 것 같습니다. property: valueproperty : valueproperty:value위 세 가지 중 하나만 사용하시는 것을 권장합니다.
Author
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. prettier 저도 알아갑니다 총총... 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. seki님 말씀 메모메모 |
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,56 @@ | ||||||
|
|
||||||
| function enterkey(){ | ||||||
| let input = document.getElementById("createToDo"); | ||||||
|
|
||||||
| if(window.event.keyCode == 13){ | ||||||
|
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. KeyboardEvent.keyCode는 deprecated된 기능입니다. |
||||||
| console.log(input.value); | ||||||
|
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. 디버깅을 위한 |
||||||
| if(localStorage.getItem(input.value) == null && input.value != "") | ||||||
| { | ||||||
| localStorage.setItem(input.value,JSON.stringify(input.value)); | ||||||
| draw(makecontent(input.value)); | ||||||
| } | ||||||
|
Comment on lines
+7
to
+11
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. 이 부분 이해가 잘 가지 않는데 설명 부탁드립니다! |
||||||
|
|
||||||
| input.value = ""; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| function makecontent(val){ | ||||||
| let content = document.createElement("div"); | ||||||
| let h = document.createElement("h1"); | ||||||
| let txtNode = document.createTextNode(val); | ||||||
| let button = document.createElement("button"); | ||||||
|
|
||||||
| button.setAttribute("class","destory"); | ||||||
| button.setAttribute("onclick", "remove(" +"\""+val+"\""+")") | ||||||
|
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. event object를 사용하는 것이 더 좋을 것 같습니다.
Suggested change
🔧할 일 이름에 쌍따옴표(")가 들어가면 동작하지 않는 문제가 있습니다. |
||||||
| content.setAttribute("class", "content"); | ||||||
| content.setAttribute("id", val); | ||||||
|
|
||||||
| h.appendChild(txtNode); | ||||||
| button.appendChild(document.createTextNode("X")); | ||||||
|
|
||||||
| content.appendChild(h); | ||||||
| content.appendChild(button); | ||||||
|
|
||||||
| return content; | ||||||
| } | ||||||
|
|
||||||
| function draw(content){ | ||||||
| let contents = document.getElementById("contents"); | ||||||
| contents.appendChild(content); | ||||||
| } | ||||||
|
|
||||||
| function remove(item_id){ | ||||||
| let content = document.getElementById(item_id); | ||||||
| let contents = document.getElementById("contents"); | ||||||
|
|
||||||
| localStorage.removeItem(item_id); | ||||||
| contents.removeChild(content); | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
| (function load(){ | ||||||
|
|
||||||
| for(var i = 0; i < localStorage.length; i++){ | ||||||
| draw(makecontent(localStorage.key(i))); | ||||||
| } | ||||||
| })() | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <!DOCTYPE html> | ||
|
|
||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <link rel = "stylesheet" href = "CSS/index.css"> | ||
| <title>vanilaToDoList</title> | ||
|
|
||
| </head> | ||
| <body> | ||
| <header> | ||
| <div> | ||
| <h1> | ||
| Seongho's vanilaToDoList | ||
| </h1> | ||
| </div> | ||
| </header> | ||
| <main> | ||
| <div> | ||
| <input onkeyup = "enterkey()" id = "createToDo" placeholder="Enter to save your task" autofocus> | ||
| </div> | ||
| <ul id = "contents"> | ||
| </ul> | ||
| </main> | ||
| <footer> | ||
| <div> | ||
|
|
||
| </div> | ||
| </footer> | ||
| <script src = "JS/index.js"></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. index.js를 html 시작 부분이 아니라 뒷 부분에 사용하신 이유가 있으신가요? |
||
| </body> | ||
| </html> | ||
|
Comment on lines
+3
to
+32
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. 원래 HTML 작성하실 때 탭을 사용하시나요? |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| <!doctype html> | ||
| <html lang="en" data-framework="javascript"> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>VanillaJS • TodoMVC</title> | ||
| <link rel="stylesheet" href="node_modules/todomvc-common/base.css"> | ||
| <link rel="stylesheet" href="node_modules/todomvc-app-css/index.css"> | ||
| </head> | ||
| <body> | ||
| <section class="todoapp"> | ||
| <header class="header"> | ||
| <h1>todos</h1> | ||
| <input class="new-todo" placeholder="What needs to be done?" autofocus> | ||
| </header> | ||
| <section class="main"> | ||
| <input id="toggle-all" class="toggle-all" type="checkbox"> | ||
| <label for="toggle-all">Mark all as complete</label> | ||
| <ul class="todo-list"></ul> | ||
| </section> | ||
| <footer class="footer"> | ||
| <span class="todo-count"></span> | ||
| <ul class="filters"> | ||
| <li> | ||
| <a href="#/" class="selected">All</a> | ||
| </li> | ||
| <li> | ||
| <a href="#/active">Active</a> | ||
| </li> | ||
| <li> | ||
| <a href="#/completed">Completed</a> | ||
| </li> | ||
| </ul> | ||
| <button class="clear-completed">Clear completed</button> | ||
| </footer> | ||
| </section> | ||
| <footer class="info"> | ||
| <p>Double-click to edit a todo</p> | ||
| <p>Created by <a href="http://twitter.com/oscargodson">Oscar Godson</a></p> | ||
| <p>Refactored by <a href="https://github.com/cburgmer">Christoph Burgmer</a></p> | ||
| <p>Part of <a href="http://todomvc.com">TodoMVC</a></p> | ||
| </footer> | ||
| <script src="node_modules/todomvc-common/base.js"></script> | ||
| <script src="js/helpers.js"></script> | ||
| <script src="js/store.js"></script> | ||
| <script src="js/model.js"></script> | ||
| <script src="js/template.js"></script> | ||
| <script src="js/view.js"></script> | ||
| <script src="js/controller.js"></script> | ||
| <script src="js/app.js"></script> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /*global app, $on */ | ||
| (function () { | ||
| 'use strict'; | ||
|
|
||
| /** | ||
| * Sets up a brand new Todo list. | ||
| * | ||
| * @param {string} name The name of your new to do list. | ||
| */ | ||
| function Todo(name) { | ||
| this.storage = new app.Store(name); | ||
| this.model = new app.Model(this.storage); | ||
| this.template = new app.Template(); | ||
| this.view = new app.View(this.template); | ||
| this.controller = new app.Controller(this.model, this.view); | ||
| } | ||
|
|
||
| var todo = new Todo('todos-vanillajs'); | ||
|
|
||
| function setView() { | ||
| todo.controller.setView(document.location.hash); | ||
| } | ||
| $on(window, 'load', setView); | ||
| $on(window, 'hashchange', setView); | ||
| })(); |
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.
Visual Studio Code 기능 중 하나인 Task에 관련된 파일입니다. 자주 사용하는 명령어를 포맷에 맞게 등록해두면 [Tasks>Task 이름]으로 바로 실행하게 해줍니다.