From 1c64efd5dd00196395c1badec5e838914948338c Mon Sep 17 00:00:00 2001 From: yungo1846 Date: Sun, 13 Dec 2020 01:11:11 +0900 Subject: [PATCH 01/20] =?UTF-8?q?docs:=20=EA=B8=B0=EB=8A=A5=EC=9A=94?= =?UTF-8?q?=EA=B5=AC=EC=82=AC=ED=95=AD=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 75 ++++++++----------------------------------------------- 1 file changed, 10 insertions(+), 65 deletions(-) diff --git a/README.md b/README.md index e97a1d649..4808037fa 100644 --- a/README.md +++ b/README.md @@ -3,20 +3,23 @@ ## ๐Ÿš€ ๊ธฐ๋Šฅ ์š”๊ตฌ์‚ฌํ•ญ ### ์ง€ํ•˜์ฒ  ์—ญ ๊ด€๋ จ ๊ธฐ๋Šฅ + - ์ง€ํ•˜์ฒ  ์—ญ์„ ๋“ฑ๋กํ•˜๊ณ  ์‚ญ์ œํ•  ์ˆ˜ ์žˆ๋‹ค. (๋‹จ, ๋…ธ์„ ์— ๋“ฑ๋ก๋œ ์—ญ์€ ์‚ญ์ œํ•  ์ˆ˜ ์—†๋‹ค) - ์ค‘๋ณต๋œ ์ง€ํ•˜์ฒ  ์—ญ ์ด๋ฆ„์ด ๋“ฑ๋ก๋  ์ˆ˜ ์—†๋‹ค. - ์ง€ํ•˜์ฒ  ์—ญ์€ 2๊ธ€์ž ์ด์ƒ์ด์–ด์•ผ ํ•œ๋‹ค. - ์ง€ํ•˜์ฒ  ์—ญ์˜ ๋ชฉ๋ก์„ ์กฐํšŒํ•  ์ˆ˜ ์žˆ๋‹ค. ### ์ง€ํ•˜์ฒ  ๋…ธ์„  ๊ด€๋ จ ๊ธฐ๋Šฅ + - ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ๋“ฑ๋กํ•˜๊ณ  ์‚ญ์ œํ•  ์ˆ˜ ์žˆ๋‹ค. - ์ค‘๋ณต๋œ ์ง€ํ•˜์ฒ  ๋…ธ์„  ์ด๋ฆ„์ด ๋“ฑ๋ก๋  ์ˆ˜ ์—†๋‹ค. - ๋…ธ์„  ๋“ฑ๋ก ์‹œ ์ƒํ–‰ ์ข…์ ์—ญ๊ณผ ํ•˜ํ–‰ ์ข…์ ์—ญ์„ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค. - ์ง€ํ•˜์ฒ  ๋…ธ์„ ์˜ ๋ชฉ๋ก์„ ์กฐํšŒํ•  ์ˆ˜ ์žˆ๋‹ค. ### ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„ ์ถ”๊ฐ€ ๊ธฐ๋Šฅ + - ์ง€ํ•˜์ฒ  ๋…ธ์„ ์— ๊ตฌ๊ฐ„์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ธฐ๋Šฅ์€ ๋…ธ์„ ์— ์—ญ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ธฐ๋Šฅ์ด๋ผ๊ณ ๋„ ํ•  ์ˆ˜ ์žˆ๋‹ค. - - ์—ญ๊ณผ ์—ญ์‚ฌ์ด๋ฅผ ๊ตฌ๊ฐ„์ด๋ผ ํ•˜๊ณ  ์ด ๊ตฌ๊ฐ„๋“ค์˜ ๋ชจ์Œ์ด ๋…ธ์„ ์ด๋‹ค. + - ์—ญ๊ณผ ์—ญ์‚ฌ์ด๋ฅผ ๊ตฌ๊ฐ„์ด๋ผ ํ•˜๊ณ  ์ด ๊ตฌ๊ฐ„๋“ค์˜ ๋ชจ์Œ์ด ๋…ธ์„ ์ด๋‹ค. - ํ•˜๋‚˜์˜ ์—ญ์€ ์—ฌ๋Ÿฌ๊ฐœ์˜ ๋…ธ์„ ์— ์ถ”๊ฐ€๋  ์ˆ˜ ์žˆ๋‹ค. - ์—ญ๊ณผ ์—ญ ์‚ฌ์ด์— ์ƒˆ๋กœ์šด ์—ญ์ด ์ถ”๊ฐ€ ๋  ์ˆ˜ ์žˆ๋‹ค. - ๋…ธ์„ ์—์„œ ๊ฐˆ๋ž˜๊ธธ์€ ์ƒ๊ธธ ์ˆ˜ ์—†๋‹ค. @@ -24,6 +27,7 @@ ### ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„ ์‚ญ์ œ ๊ธฐ๋Šฅ + - ๋…ธ์„ ์— ๋“ฑ๋ก๋œ ์—ญ์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ๋‹ค. - ์ข…์ ์„ ์ œ๊ฑฐํ•  ๊ฒฝ์šฐ ๋‹ค์Œ ์—ญ์ด ์ข…์ ์ด ๋œ๋‹ค. - ๋…ธ์„ ์— ํฌํ•จ๋œ ์—ญ์ด ๋‘๊ฐœ ์ดํ•˜์ผ ๋•Œ๋Š” ์—ญ์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์—†๋‹ค. @@ -31,6 +35,7 @@ ### ์ง€ํ•˜์ฒ  ๋…ธ์„ ์— ๋“ฑ๋ก๋œ ์—ญ ์กฐํšŒ ๊ธฐ๋Šฅ + - ๋…ธ์„ ์˜ ์ƒํ–‰ ์ข…์ ๋ถ€ํ„ฐ ํ•˜ํ–‰ ์ข…์ ๊นŒ์ง€ ์—ฐ๊ฒฐ๋œ ์ˆœ์„œ๋Œ€๋กœ ์—ญ ๋ชฉ๋ก์„ ์กฐํšŒํ•  ์ˆ˜ ์žˆ๋‹ค.
@@ -38,77 +43,17 @@ ## ๐Ÿ’ป ํ”„๋กœ๊ทธ๋žจ ์‹คํ–‰ ๊ฒฐ๊ณผ ### ์—ญ๊ด€๋ฆฌ + ### ๋…ธ์„ ๊ด€๋ฆฌ + ### ๊ตฌ๊ฐ„๊ด€๋ฆฌ + ### ๋…ธ์„ ๋„ ์ถœ๋ ฅ - - - -## โœ… ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์š”๊ตฌ์‚ฌํ•ญ -### ๋ฉ”๋‰ด ๋ฒ„ํŠผ -- ์—ญ ๊ด€๋ฆฌ button ํƒœ๊ทธ๋Š” `#station-manager-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ๋…ธ์„  ๊ด€๋ฆฌ button ํƒœ๊ทธ๋Š” `#line-manager-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ button ํƒœ๊ทธ๋Š” `#section-manager-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ์ถœ๋ ฅ ๊ด€๋ฆฌ button ํƒœ๊ทธ๋Š” `#map-print-manager-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. - -### ์ง€ํ•˜์ฒ  ์—ญ ๊ด€๋ จ ๊ธฐ๋Šฅ -- ์ง€ํ•˜์ฒ  ์—ญ์„ ์ž…๋ ฅํ•˜๋Š” input ํƒœ๊ทธ๋Š” `#station-name-input` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ์ง€ํ•˜์ฒ  ์—ญ์„ ์ถ”๊ฐ€ํ•˜๋Š” button ํƒœ๊ทธ๋Š” `#station-add-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ์ง€ํ•˜์ฒ  ์—ญ์„ ์‚ญ์ œํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.station-delete-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. - -### ์ง€ํ•˜์ฒ  ๋…ธ์„  ๊ด€๋ จ ๊ธฐ๋Šฅ -- ์ง€ํ•˜์ฒ  ๋…ธ์„ ์˜ ์ด๋ฆ„์„ ์ž…๋ ฅํ•˜๋Š” input ํƒœ๊ทธ๋Š” `#line-name-input` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ์ง€ํ•˜์ฒ  ๋…ธ์„ ์˜ ์ƒํ–‰ ์ข…์ ์„ ์„ ํƒํ•˜๋Š” select ํƒœ๊ทธ๋Š” `#line-start-station-selector` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ์ง€ํ•˜์ฒ  ๋…ธ์„ ์˜ ํ•˜ํ–‰ ์ข…์ ์„ ์„ ํƒํ•˜๋Š” select ํƒœ๊ทธ๋Š” `#line-end-station-selector` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ์ถ”๊ฐ€ํ•˜๋Š” button ํƒœ๊ทธ๋Š” `#line-add-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ์‚ญ์ œํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.line-delete-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. - -### ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„ ์ถ”๊ฐ€ ๊ธฐ๋Šฅ -- ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ์„ ํƒํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.section-line-menu-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์„ ์„ค์ •ํ•  ์—ญ select ํƒœ๊ทธ๋Š” `#section-station-selector` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์˜ ์ˆœ์„œ๋ฅผ ์ž…๋ ฅํ•˜๋Š” input ํƒœ๊ทธ๋Š” `#section-order-input` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์„ ๋“ฑ๋กํ•˜๋Š” button ํƒœ๊ทธ๋Š” `#section-add-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์„ ์ œ๊ฑฐํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.section-delete-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. - -### ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ์ถœ๋ ฅ ๊ธฐ๋Šฅ -- ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ์ถœ๋ ฅ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด `
` ํƒœ๊ทธ๋ฅผ ๋งŒ๋“ค๊ณ  ํ•ด๋‹น ํƒœ๊ทธ ๋‚ด๋ถ€์— ๋…ธ์„ ๋„๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. - -### ๊ธฐ์กด ์š”๊ตฌ์‚ฌํ•ญ - -- ์‚ฌ์šฉ์ž๊ฐ€ ์ž˜๋ชป๋œ ์ž…๋ ฅ ๊ฐ’์„ ์ž‘์„ฑํ•œ ๊ฒฝ์šฐ `alert`์„ ์ด์šฉํ•ด ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด์—ฌ์ฃผ๊ณ , ์žฌ์ž…๋ ฅํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•œ๋‹ค. -- ์™ธ๋ถ€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ(jQuery, Lodash ๋“ฑ)๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ , ์ˆœ์ˆ˜ Vanilla JS๋กœ๋งŒ ๊ตฌํ˜„ํ•œ๋‹ค. -- **์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ ์ปจ๋ฒค์…˜์„ ์ง€ํ‚ค๋ฉด์„œ ํ”„๋กœ๊ทธ๋ž˜๋ฐ** ํ•œ๋‹ค - - [https://google.github.io/styleguide/jsguide.html](https://google.github.io/styleguide/jsguide.html) - - [https://ui.toast.com/fe-guide/ko_CODING-CONVENSION/](https://ui.toast.com/fe-guide/ko_CODING-CONVENTION) -- **indent(์ธ๋ดํŠธ, ๋“ค์—ฌ์“ฐ๊ธฐ) depth๋ฅผ 3์ด ๋„˜์ง€ ์•Š๋„๋ก ๊ตฌํ˜„ํ•œ๋‹ค. 2๊นŒ์ง€๋งŒ ํ—ˆ์šฉ**ํ•œ๋‹ค. - - ์˜ˆ๋ฅผ ๋“ค์–ด while๋ฌธ ์•ˆ์— if๋ฌธ์ด ์žˆ์œผ๋ฉด ๋“ค์—ฌ์“ฐ๊ธฐ๋Š” 2์ด๋‹ค. - - ํžŒํŠธ: indent(์ธ๋ดํŠธ, ๋“ค์—ฌ์“ฐ๊ธฐ) depth๋ฅผ ์ค„์ด๋Š” ์ข‹์€ ๋ฐฉ๋ฒ•์€ ํ•จ์ˆ˜(๋˜๋Š” ๋ฉ”์†Œ๋“œ)๋ฅผ ๋ถ„๋ฆฌํ•˜๋ฉด ๋œ๋‹ค. -- **ํ•จ์ˆ˜(๋˜๋Š” ๋ฉ”์†Œ๋“œ)์˜ ๊ธธ์ด๊ฐ€ 15๋ผ์ธ์„ ๋„˜์–ด๊ฐ€์ง€ ์•Š๋„๋ก ๊ตฌํ˜„ํ•œ๋‹ค.** - - ํ•จ์ˆ˜(๋˜๋Š” ๋ฉ”์†Œ๋“œ)๊ฐ€ ํ•œ ๊ฐ€์ง€ ์ผ๋งŒ ์ž˜ ํ•˜๋„๋ก ๊ตฌํ˜„ํ•œ๋‹ค. -- ๋ณ€์ˆ˜ ์„ ์–ธ์‹œ `var` ๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š”๋‹ค. `const` ์™€ `let` ์„ ์‚ฌ์šฉํ•œ๋‹ค. - - [const](https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Statements/const) - - [let](https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Statements/let) -- `import` ๋ฌธ์„ ์ด์šฉํ•ด ์Šคํฌ๋ฆฝํŠธ๋ฅผ ๋ชจ๋“ˆํ™”ํ•˜๊ณ  ๋ถˆ๋Ÿฌ์˜ฌ ์ˆ˜ ์žˆ๊ฒŒ ๋งŒ๋“ ๋‹ค. - - [https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Statements/import](https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Statements/import) -- `template literal`์„ ์ด์šฉํ•ด ๋ฐ์ดํ„ฐ์™€ html string์„ ๊ฐ€๋…์„ฑ ์ข‹๊ฒŒ ํ‘œํ˜„ํ•œ๋‹ค. - - [https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Template_literals](https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Template_literals) - -### ์ถ”๊ฐ€๋œ ์š”๊ตฌ์‚ฌํ•ญ -- [data](https://developer.mozilla.org/ko/docs/Learn/HTML/Howto/%EB%8D%B0%EC%9D%B4%ED%84%B0_%EC%86%8D%EC%84%B1_%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0)์†์„ฑ์„ ํ™œ์šฉํ•˜์—ฌ html ํƒœ๊ทธ์— ์—ญ, ๋…ธ์„ , ๊ตฌ๊ฐ„์˜ ์œ ์ผํ•œ ๋ฐ์ดํ„ฐ ๊ฐ’๋“ค์„ ๊ด€๋ฆฌํ•œ๋‹ค. -- [localStorage](https://developer.mozilla.org/ko/docs/Web/API/Window/localStorage)๋ฅผ ์ด์šฉํ•˜์—ฌ, ์ƒˆ๋กœ๊ณ ์นจํ•˜๋”๋ผ๋„ ๊ฐ€์žฅ ์ตœ๊ทผ์— ์ž‘์—…ํ•œ ์ •๋ณด๋“ค์„ ๋ถˆ๋Ÿฌ์˜ฌ ์ˆ˜ ์žˆ๋„๋ก ํ•œ๋‹ค. - -
- -## ๐Ÿ“ ๋ฏธ์…˜ ์ €์žฅ์†Œ ๋ฐ ์ง„ํ–‰ ์š”๊ตฌ์‚ฌํ•ญ - -- ๋ฏธ์…˜์€ [https://github.com/woowacourse/javascript-subway-map-precours](https://github.com/woowacourse/javascript-subway-map-precourse) ์ €์žฅ์†Œ๋ฅผ fork/cloneํ•ด ์‹œ์ž‘ํ•œ๋‹ค. -- **๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•˜๊ธฐ ์ „์— javascript-subway-precourse/docs/README.md ํŒŒ์ผ์— ๊ตฌํ˜„ํ•  ๊ธฐ๋Šฅ ๋ชฉ๋ก**์„ ์ •๋ฆฌํ•ด ์ถ”๊ฐ€ํ•œ๋‹ค. -- **git์˜ commit ๋‹จ์œ„๋Š” ์•ž ๋‹จ๊ณ„์—์„œ README.md ํŒŒ์ผ์— ์ •๋ฆฌํ•œ ๊ธฐ๋Šฅ ๋ชฉ๋ก ๋‹จ์œ„๋กœ ์ถ”๊ฐ€**ํ•œ๋‹ค. -- [ํ”„๋ฆฌ์ฝ”์Šค ๊ณผ์ œ ์ œ์ถœ](https://github.com/woowacourse/woowacourse-docs/tree/master/precourse) ๋ฌธ์„œ ์ ˆ์ฐจ๋ฅผ ๋”ฐ๋ผ ๋ฏธ์…˜์„ ์ œ์ถœํ•œ๋‹ค. + From e65b2ab2e03d469f4b3062bdbbd1daa653ff5552 Mon Sep 17 00:00:00 2001 From: yungo1846 Date: Sun, 13 Dec 2020 01:50:56 +0900 Subject: [PATCH 02/20] =?UTF-8?q?feat:=20station=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=20=EC=A0=9C=EA=B1=B0=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 38 +++++++++++++++++- src/alertMessage.js | 13 ++++++ src/constant.js | 4 ++ src/index.js | 34 ++++++++++++++++ src/inputCheck.js | 88 +++++++++++++++++++++++++++++++++++++++++ src/manager/line.js | 1 + src/manager/mapPrint.js | 1 + src/manager/section.js | 1 + src/manager/station.js | 78 ++++++++++++++++++++++++++++++++++++ 9 files changed, 257 insertions(+), 1 deletion(-) create mode 100644 src/alertMessage.js create mode 100644 src/constant.js create mode 100644 src/inputCheck.js create mode 100644 src/manager/line.js create mode 100644 src/manager/mapPrint.js create mode 100644 src/manager/section.js create mode 100644 src/manager/station.js diff --git a/index.html b/index.html index fc99deac2..c3d7cdc6d 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,43 @@
-

๐Ÿš‡ ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ๊ด€๋ฆฌ

+

๐Ÿš‡ ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ๊ด€๋ฆฌ

+ + + + +
+
+ + + +
diff --git a/src/alertMessage.js b/src/alertMessage.js new file mode 100644 index 000000000..f0e954841 --- /dev/null +++ b/src/alertMessage.js @@ -0,0 +1,13 @@ +import { constant } from "./constant.js"; + +export const alertMessage = { + SHORT_LENGTH_ERROR: `์ตœ์†Œ ${constant.minLength} ๊ธ€์ž ์ด์ƒ ์ž…๋ ฅํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.`, + ORDERING_INPUT_NOTHING_ERROR: `์ˆœ์„œ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”`, + DELETE_CHECK_MESSAGE: "์ •๋ง๋กœ ์‚ญ์ œํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?", + DELETE_STATION_ON_LINE_MESSAGE: "์ด ์—ญ์€ ํ˜„์žฌ ๋…ธ์„ ์— ๋“ฑ๋ก๋˜์–ด ์žˆ์–ด ์‚ญ์ œ๊ฐ€ ๋ถˆ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.", + DELETE_STATIONS_ON_LINE_SHORTAGE_MESSAGE: `์„ ํƒํ•œ ๋…ธ์„ ์˜ ์—ญ์ด ${constant.minStations}๊ฐœ ์ดํ•˜์ธ ๊ฒฝ์šฐ์—๋Š” ์‚ญ์ œํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.`, + SAME_DESTINATION_ERROR: `์ƒํ–‰๊ณผ ํ•˜ํ–‰์ด ๊ฐ™์Šต๋‹ˆ๋‹ค. ๋‹ค์‹œ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.`, + SAME_LINE_EXIST_ERROR: "์ด๋ฏธ ๊ฐ™์€ ์ด๋ฆ„์„ ๊ฐ€์ง„ ๋…ธ์„ ์ด ์žˆ์Šต๋‹ˆ๋‹ค.", + SAME_STATION_EXIST_ERROR: "์ด๋ฏธ ๊ฐ™์€ ์ด๋ฆ„์„ ๊ฐ€์ง„ ์—ญ์ด ์žˆ์Šต๋‹ˆ๋‹ค.", + SAME_SECTION_EXIST_ERROR: "์ด๋ฏธ ๊ฐ™์€ ๊ตฌ๊ฐ„์ด ๋“ฑ๋ก๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.", +}; diff --git a/src/constant.js b/src/constant.js new file mode 100644 index 000000000..3b75617b1 --- /dev/null +++ b/src/constant.js @@ -0,0 +1,4 @@ +export const constant = { + minLength: 2, + minStations: 2, +}; diff --git a/src/index.js b/src/index.js index e69de29bb..028a2b904 100644 --- a/src/index.js +++ b/src/index.js @@ -0,0 +1,34 @@ +import Station from "./manager/station.js"; +import Line from "./manager/line.js"; +import Section from "./manager/section.js"; +import MapPrint from "./manager/mapPrint.js"; + +export default function SubwayMap() { + const station = new Station(); + const line = new Line(); + const section = new Section(); + const mapPrint = new MapPrint(); + const stationBtn = document.getElementById("station-manager-button"); + const lineBtn = document.getElementById("line-manager-button"); + const sectionBtn = document.getElementById("section-manager-button"); + const mapPrintBtn = document.getElementById("map-print-manager-button"); + + this.onClickStation = () => { + station.init(line.lines); + }; + + this.onClickLine = () => { + line.init(); + }; + + this.onClickSection = () => {}; + + this.onClickMapPrint = () => {}; + + stationBtn.addEventListener("click", this.onClickStation); + lineBtn.addEventListener("click", this.onClickLine); + sectionBtn.addEventListener("click", this.onClickSection); + mapPrintBtn.addEventListener("click", this.onClickMapPrint); +} + +new SubwayMap(); diff --git a/src/inputCheck.js b/src/inputCheck.js new file mode 100644 index 000000000..5a135c1b5 --- /dev/null +++ b/src/inputCheck.js @@ -0,0 +1,88 @@ +import { constant } from "./constant.js"; + +export function isSatisfyLength(len) { + let result = true; + if (String(len).length < constant.minLength) { + result = false; + } + + return result; +} + +export function isSameDestination(start, end) { + let result = true; + if (start !== end) { + result = false; + } + + return result; +} + +export function isStationAlreadyExist(stations, name) { + let result = false; + for (let i = 0; i < stations.length; i++) { + if (name === stations[i]) { + result = true; + break; + } + } + + return result; +} + +export function isLineAlreadyExist(lines, name) { + let result = false; + for (let i = 0; i < lines.length; i++) { + if (name === lines[i].name) { + result = true; + break; + } + } + + return result; +} + +export function isSectionAlreadyExist(sections, name) { + let result = false; + for (let i = 0; i < sections.length; i++) { + if (name === sections[i]) { + result = true; + break; + } + } + + return result; +} + +function _isStationOnLine(sections, name) { + let result = false; + for (let i = 0; i < sections.length; i++) { + if (name === sections[i]) { + result = true; + break; + } + } + + return result; +} + +export function isStationOnLine(lines, name) { + let result = false; + for (let i = 0; i < lines.length; i++) { + if (_isStationOnLine(lines[i].sections, name)) { + result = true; + break; + } + } + + return result; +} + +export function isSatisfyMinNumOfStations(line) { + let result = false; + if (line.sections.length > constant.minStations) { + result = true; + } + + return result; +} diff --git a/src/manager/line.js b/src/manager/line.js new file mode 100644 index 000000000..0f0f329ff --- /dev/null +++ b/src/manager/line.js @@ -0,0 +1 @@ +export default function Line() {} diff --git a/src/manager/mapPrint.js b/src/manager/mapPrint.js new file mode 100644 index 000000000..e70441540 --- /dev/null +++ b/src/manager/mapPrint.js @@ -0,0 +1 @@ +export default function MapPrint() {} diff --git a/src/manager/section.js b/src/manager/section.js new file mode 100644 index 000000000..138ffff5c --- /dev/null +++ b/src/manager/section.js @@ -0,0 +1 @@ +export default function Section() {} diff --git a/src/manager/station.js b/src/manager/station.js new file mode 100644 index 000000000..1ae8c17dd --- /dev/null +++ b/src/manager/station.js @@ -0,0 +1,78 @@ +import { isSatisfyLength, isStationAlreadyExist, isStationOnLine } from "../inputCheck.js"; +import { alertMessage } from "../alertMessage.js"; + +export default function Station() { + const stationPage = document.getElementById("station-page"); + const stationTable = document.getElementById("station-table"); + let lines; + this.stations = [ + "์ธ์ฒœ", + "๋™์ธ์ฒœ", + "๋„์›", + "์†Œ์š”์‚ฐ", + "์‚ฌ๋‹น", + "์‹œ์ฒญ", + "์‹ ๋„๋ฆผ", + "๋Œ€ํ™”", + "์˜ค๊ธˆ", + "์˜ค์ด๋„", + "๋‹น๊ณ ๊ฐœ", + ]; + this.count = this.stations.length; + + this.init = (lineList) => { + lines = lineList; // Line ํด๋ž˜์Šค ์ธ์Šคํ„ด์Šค๋ฅผ ๋ฐ›์•„์˜ด + stationPage.style.display = "block"; + this.showStations(); + const stationDelBtns = document.getElementsByClassName("station-delete-button"); + for (let i = 0; i < stationDelBtns.length; i++) { + stationDelBtns[i].addEventListener("click", (event) => this.deleteStation(event)); + } + const stationInputBtn = document.getElementById("station-add-button"); + stationInputBtn.addEventListener("click", this.addStation); + }; + + this.showStations = () => { + let newHTML = ""; + for (let i = 0; i < this.stations.length; i++) { + newHTML += ` + + ${this.stations[i]} + + `; + } + stationTable.insertAdjacentHTML("beforeend", newHTML); + }; + + this.addStation = () => { + const stationInput = document.getElementById("station-name-input").value; + if (!isSatisfyLength(stationInput)) { + return alert(alertMessage.SHORT_LENGTH_ERROR); + } else if (isStationAlreadyExist(this.stations, stationInput)) { + return alert(alertMessage.SAME_STATION_EXIST_ERROR); + } + this.stations.push(stationInput); + const newHTML = ` + + ${stationInput} + `; + stationTable.insertAdjacentHTML("beforeend", newHTML); + const newStation = document.getElementById(`${this.count}`); + newStation.addEventListener("click", (event) => this.deleteStation(event)); + this.count++; + }; + + this.deleteStation = (event) => { + const targetId = event.target.id; + const targetValue = event.target.value; + const delStation = document.getElementById(`station${targetId}`); + if (!confirm(alertMessage.DELETE_CHECK_MESSAGE)) { + return; + } + if (isStationOnLine(lines, targetValue)) { + return alert(alertMessage.DELETE_STATION_ON_LINE_MESSAGE); + } + delStation.remove(); + this.stations.splice(this.stations.indexOf(targetValue), 1); + }; +} From 7a0c62f03f1f4b30b32cb5348fbe3ae410f7b125 Mon Sep 17 00:00:00 2001 From: yungo1846 Date: Sun, 13 Dec 2020 13:39:06 +0900 Subject: [PATCH 03/20] =?UTF-8?q?feat:=20station=20=EC=B6=94=EA=B0=80,=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 25 +++++---- src/event/line/addLine.js | 0 src/event/line/delLine.js | 0 src/event/menuEvent.js | 28 ++++++++++ src/event/station/addStationEvent.js | 29 ++++++++++ src/event/station/delStationEvent.js | 31 ++++++++++ src/index.js | 27 +-------- src/inputCheck.js | 2 +- src/manager/line.js | 84 +++++++++++++++++++++++++++- src/manager/station.js | 80 +++----------------------- src/render/render.js | 11 ++++ src/render/renderLine.js | 40 +++++++++++++ src/render/renderStation.js | 45 +++++++++++++++ 13 files changed, 291 insertions(+), 111 deletions(-) create mode 100644 src/event/line/addLine.js create mode 100644 src/event/line/delLine.js create mode 100644 src/event/menuEvent.js create mode 100644 src/event/station/addStationEvent.js create mode 100644 src/event/station/delStationEvent.js create mode 100644 src/render/render.js create mode 100644 src/render/renderLine.js create mode 100644 src/render/renderStation.js diff --git a/index.html b/index.html index c3d7cdc6d..bb0ee944c 100644 --- a/index.html +++ b/index.html @@ -7,24 +7,24 @@

๐Ÿš‡ ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ๊ด€๋ฆฌ

- - - - +
-