Skip to content

Commit 6aaa9f3

Browse files
Merge branch 'master' into 1313
2 parents 11ab606 + 68e1c59 commit 6aaa9f3

File tree

8 files changed

+53
-49
lines changed

8 files changed

+53
-49
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The solution has two parts.
1+
해답은 두 파트로 나뉩니다.
22

3-
1. Wrap every tree node title into `<span>`. Then we can CSS-style them on `:hover` and handle clicks exactly on text, because `<span>` width is exactly the text width (unlike without it).
4-
2. Set a handler to the `tree` root node and handle clicks on that `<span>` titles.
3+
1. 트리에 있는 모든 텍스트를 `<span>`이 감싸도록 합니다. 이렇게 하면 CSS `:hover`를 사용해 마우스 오버 시 글씨를 굴게 해주는 효과를 줄 수 있고 `<span>`이 차지하는 너비가 텍스트의 너비와 정확히 일치하기 때문에 텍스트에만 클릭 이벤트가 동작하도록 할 수 있습니다.
4+
2. 루트 노드인 `tree`에 핸들러를 추가하고 클릭 이벤트가 `<span>`으로 감싼 텍스트에만 동작하도록 합니다.

2-ui/2-events/03-event-delegation/2-sliding-tree/solution.view/index.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,22 @@
5454
</ul>
5555

5656
<script>
57-
// move all text into <span>
58-
// they occupy exactly the place necessary for the text,
57+
// 텍스트 전부를 <span>이 감싸도록 합니다.
5958
for (let li of tree.querySelectorAll('li')) {
6059
let span = document.createElement('span');
6160
li.prepend(span);
62-
span.append(span.nextSibling); // move the text node into span
61+
span.append(span.nextSibling); // 텍스트 노드를 span 안으로 옮깁니다.
6362
}
6463

65-
// catch clicks on whole tree
64+
// 트리 전체의 클릭 이벤트를 감지하는 리스너를 만듭니다.
6665
tree.onclick = function(event) {
6766

6867
if (event.target.tagName != 'SPAN') {
6968
return;
7069
}
7170

7271
let childrenContainer = event.target.parentNode.querySelector('ul');
73-
if (!childrenContainer) return; // no children
72+
if (!childrenContainer) return; // 자손 노드가 없는 경우
7473

7574
childrenContainer.hidden = !childrenContainer.hidden;
7675
}

2-ui/2-events/03-event-delegation/2-sliding-tree/source.view/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,9 @@
4242
</li>
4343
</ul>
4444

45+
<script>
46+
// ...여기에 코드를 작성하세요...
47+
</script>
48+
4549
</body>
4650
</html>

2-ui/2-events/03-event-delegation/2-sliding-tree/task.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ importance: 5
22

33
---
44

5-
# Tree menu
5+
# 트리 메뉴 구현하기
66

7-
Create a tree that shows/hides node children on click:
7+
노드를 클릭하면 자손 노드가 보이거나 숨겨지는 트리 메뉴를 구현해보세요.
88

99
[iframe border=1 src="solution"]
1010

11-
Requirements:
11+
구체적인 요구사항은 다음과 같습니다.
1212

13-
- Only one event handler (use delegation)
14-
- A click outside the node title (on an empty space) should not do anything.
13+
- 단 하나의 이벤트 핸들러(이벤트 위임 사용하기)
14+
15+
- 노드(텍스트) 바깥(빈 곳)을 클릭하면 아무 일도 일어나지 않아야 합니다.

2-ui/2-events/03-event-delegation/3-sortable-table/solution.view/index.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,30 @@
2525
<table id="grid">
2626
<thead>
2727
<tr>
28-
<th data-type="number">Age</th>
29-
<th data-type="string">Name</th>
28+
<th data-type="number">나이</th>
29+
<th data-type="string">이름</th>
3030
</tr>
3131
</thead>
3232
<tbody>
3333
<tr>
3434
<td>5</td>
35-
<td>John</td>
35+
<td>일리야</td>
3636
</tr>
3737
<tr>
3838
<td>2</td>
39-
<td>Pete</td>
39+
<td>보라</td>
4040
</tr>
4141
<tr>
4242
<td>12</td>
43-
<td>Ann</td>
43+
<td>호진</td>
4444
</tr>
4545
<tr>
4646
<td>9</td>
47-
<td>Eugene</td>
47+
<td>지민</td>
4848
</tr>
4949
<tr>
5050
<td>1</td>
51-
<td>Ilya</td>
51+
<td>재인</td>
5252
</tr>
5353
</tbody>
5454
</table>
@@ -59,10 +59,10 @@
5959
if (e.target.tagName != 'TH') return;
6060

6161
let th = e.target;
62-
// if TH, then sort
63-
// cellIndex is the number of th:
64-
// 0 for the first column
65-
// 1 for the second column, etc
62+
// 클릭한 요소가 TH라면 정렬을 진행합니다.
63+
// cellIndex는 몇 번째 열인지를 나타내는 인덱스 값입니다.
64+
// 첫 번째 열이라면 0,
65+
// 두 번째 열이라면 1이 됩니다.
6666
sortGrid(th.cellIndex, th.dataset.type);
6767
};
6868

@@ -71,7 +71,7 @@
7171

7272
let rowsArray = Array.from(tbody.rows);
7373

74-
// compare(a, b) compares two rows, need for sorting
74+
// 변수 compare에 할당할 함수 compare(a, b)는 두 행을 비교하고 필요에 따라 정렬을 진행합니다.
7575
let compare;
7676

7777
switch (type) {
@@ -87,7 +87,7 @@
8787
break;
8888
}
8989

90-
// sort
90+
// 해당 열을 정렬합니다.
9191
rowsArray.sort(compare);
9292

9393
tbody.append(...rowsArray);

2-ui/2-events/03-event-delegation/3-sortable-table/source.view/index.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,36 +25,36 @@
2525
<table id="grid">
2626
<thead>
2727
<tr>
28-
<th data-type="number">Age</th>
29-
<th data-type="string">Name</th>
28+
<th data-type="number">나이</th>
29+
<th data-type="string">이름</th>
3030
</tr>
3131
</thead>
3232
<tbody>
3333
<tr>
3434
<td>5</td>
35-
<td>John</td>
35+
<td>일리야</td>
3636
</tr>
3737
<tr>
3838
<td>2</td>
39-
<td>Pete</td>
39+
<td>보라</td>
4040
</tr>
4141
<tr>
4242
<td>12</td>
43-
<td>Ann</td>
43+
<td>호진</td>
4444
</tr>
4545
<tr>
4646
<td>9</td>
47-
<td>Eugene</td>
47+
<td>민지</td>
4848
</tr>
4949
<tr>
5050
<td>1</td>
51-
<td>Ilya</td>
51+
<td>호석</td>
5252
</tr>
5353
</tbody>
5454
</table>
5555

5656
<script>
57-
// ...your code...
57+
// ...여기에 코드를 작성하세요...
5858
</script>
5959

6060
</body>

2-ui/2-events/03-event-delegation/3-sortable-table/task.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,42 @@ importance: 4
22

33
---
44

5-
# Sortable table
5+
# 정렬 기능을 제공하는 표
66

7-
Make the table sortable: clicks on `<th>` elements should sort it by corresponding column.
7+
열 제목을 나타내는 요소인 `<th>`를 클릭하면 열 전체가 정렬되는 표를 만들어보세요.
88

9-
Each `<th>` has the type in the attribute, like this:
9+
모든 `<th>` 속성엔 다음과 같이 데이터의 타입이 정의되어 있습니다.
1010

1111
```html
1212
<table id="grid">
1313
<thead>
1414
<tr>
1515
*!*
16-
<th data-type="number">Age</th>
17-
<th data-type="string">Name</th>
16+
<th data-type="number">나이</th>
17+
<th data-type="string">이름</th>
1818
*/!*
1919
</tr>
2020
</thead>
2121
<tbody>
2222
<tr>
2323
<td>5</td>
24-
<td>John</td>
24+
<td>일리야</td>
2525
</tr>
2626
<tr>
2727
<td>10</td>
28-
<td>Ann</td>
28+
<td>보라</td>
2929
</tr>
3030
...
3131
</tbody>
3232
</table>
3333
```
3434

35-
In the example above the first column has numbers, and the second one -- strings. The sorting function should handle sort according to the type.
35+
위 예시에선 첫 번째 열엔 숫자가, 두 번째 열엔 문자열이 들어갑니다. 구현할 정렬 함수는 데이터 타입에 맞게 정렬을 해줘야 합니다.
3636

37-
Only `"string"` and `"number"` types should be supported.
37+
이 문제에선 `'숫자'``'문자열'` 타입만 다룬다고 가정하겠습니다.
3838

39-
The working example:
39+
제대로 해답을 작성했다면 다음 예시처럼 동작해야 합니다.
4040

4141
[iframe border=1 src="solution" height=190]
4242

43-
P.S. The table can be big, with any number of rows and columns.
43+
P.S. 표 크기는 예시보다 훨씬 클 수 있습니다. 열이나 행이 더 추가될 수 있다는 가정하에 답을 작성해보세요.

6-data-storage/02-localstorage/article.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,17 @@ for(let key of keys) {
127127
숫자나 객체 등 다른 자료형을 사용하게 되면 문자열로 자동 변환됩니다.
128128

129129
```js run
130-
sessionStorage.user = {name: "John"};
131-
alert(sessionStorage.user); // [object Object]
130+
localStorage.user = {name: "John"};
131+
alert(localStorage.user); // [object Object]
132132
```
133133

134134
`JSON`을 사용하면 객체를 쓸 수 있긴 합니다.
135135

136136
```js run
137-
sessionStorage.user = JSON.stringify({name: "John"});
137+
localStorage.user = JSON.stringify({name: "John"});
138138
139139
// 잠시 후
140-
let user = JSON.parse( sessionStorage.user );
140+
let user = JSON.parse( localStorage.user );
141141
alert( user.name ); // John
142142
```
143143

0 commit comments

Comments
 (0)