diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..fd5106ff2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+.DS_STORE
diff --git a/README.md b/README.md
index e97a1d649..0cbdb1158 100644
--- a/README.md
+++ b/README.md
@@ -1,114 +1,94 @@
-# ๐ ์งํ์ฒ ๋
ธ์ ๋ ๋ฏธ์
-
-## ๐ ๊ธฐ๋ฅ ์๊ตฌ์ฌํญ
-
-### ์งํ์ฒ ์ญ ๊ด๋ จ ๊ธฐ๋ฅ
-- ์งํ์ฒ ์ญ์ ๋ฑ๋กํ๊ณ ์ญ์ ํ ์ ์๋ค. (๋จ, ๋
ธ์ ์ ๋ฑ๋ก๋ ์ญ์ ์ญ์ ํ ์ ์๋ค)
-- ์ค๋ณต๋ ์งํ์ฒ ์ญ ์ด๋ฆ์ด ๋ฑ๋ก๋ ์ ์๋ค.
-- ์งํ์ฒ ์ญ์ 2๊ธ์ ์ด์์ด์ด์ผ ํ๋ค.
-- ์งํ์ฒ ์ญ์ ๋ชฉ๋ก์ ์กฐํํ ์ ์๋ค.
-
-### ์งํ์ฒ ๋
ธ์ ๊ด๋ จ ๊ธฐ๋ฅ
-- ์งํ์ฒ ๋
ธ์ ์ ๋ฑ๋กํ๊ณ ์ญ์ ํ ์ ์๋ค.
-- ์ค๋ณต๋ ์งํ์ฒ ๋
ธ์ ์ด๋ฆ์ด ๋ฑ๋ก๋ ์ ์๋ค.
-- ๋
ธ์ ๋ฑ๋ก ์ ์ํ ์ข
์ ์ญ๊ณผ ํํ ์ข
์ ์ญ์ ์
๋ ฅ๋ฐ๋๋ค.
-- ์งํ์ฒ ๋
ธ์ ์ ๋ชฉ๋ก์ ์กฐํํ ์ ์๋ค.
-
-### ์งํ์ฒ ๊ตฌ๊ฐ ์ถ๊ฐ ๊ธฐ๋ฅ
-- ์งํ์ฒ ๋
ธ์ ์ ๊ตฌ๊ฐ์ ์ถ๊ฐํ๋ ๊ธฐ๋ฅ์ ๋
ธ์ ์ ์ญ์ ์ถ๊ฐํ๋ ๊ธฐ๋ฅ์ด๋ผ๊ณ ๋ ํ ์ ์๋ค.
- - ์ญ๊ณผ ์ญ์ฌ์ด๋ฅผ ๊ตฌ๊ฐ์ด๋ผ ํ๊ณ ์ด ๊ตฌ๊ฐ๋ค์ ๋ชจ์์ด ๋
ธ์ ์ด๋ค.
-- ํ๋์ ์ญ์ ์ฌ๋ฌ๊ฐ์ ๋
ธ์ ์ ์ถ๊ฐ๋ ์ ์๋ค.
-- ์ญ๊ณผ ์ญ ์ฌ์ด์ ์๋ก์ด ์ญ์ด ์ถ๊ฐ ๋ ์ ์๋ค.
-- ๋
ธ์ ์์ ๊ฐ๋๊ธธ์ ์๊ธธ ์ ์๋ค.
-
-
-
-### ์งํ์ฒ ๊ตฌ๊ฐ ์ญ์ ๊ธฐ๋ฅ
-- ๋
ธ์ ์ ๋ฑ๋ก๋ ์ญ์ ์ ๊ฑฐํ ์ ์๋ค.
-- ์ข
์ ์ ์ ๊ฑฐํ ๊ฒฝ์ฐ ๋ค์ ์ญ์ด ์ข
์ ์ด ๋๋ค.
-- ๋
ธ์ ์ ํฌํจ๋ ์ญ์ด ๋๊ฐ ์ดํ์ผ ๋๋ ์ญ์ ์ ๊ฑฐํ ์ ์๋ค.
-
-
-
-### ์งํ์ฒ ๋
ธ์ ์ ๋ฑ๋ก๋ ์ญ ์กฐํ ๊ธฐ๋ฅ
-- ๋
ธ์ ์ ์ํ ์ข
์ ๋ถํฐ ํํ ์ข
์ ๊น์ง ์ฐ๊ฒฐ๋ ์์๋๋ก ์ญ ๋ชฉ๋ก์ ์กฐํํ ์ ์๋ค.
-
-
-
-## ๐ป ํ๋ก๊ทธ๋จ ์คํ ๊ฒฐ๊ณผ
-
-### ์ญ๊ด๋ฆฌ
-
-
-### ๋
ธ์ ๊ด๋ฆฌ
-
-
-### ๊ตฌ๊ฐ๊ด๋ฆฌ
-
-
-### ๋
ธ์ ๋ ์ถ๋ ฅ
-
-
-
-## โ
ํ๋ก๊ทธ๋๋ฐ ์๊ตฌ์ฌํญ
-
-### ๋ฉ๋ด ๋ฒํผ
-- ์ญ ๊ด๋ฆฌ 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) ๋ฌธ์ ์ ์ฐจ๋ฅผ ๋ฐ๋ผ ๋ฏธ์
์ ์ ์ถํ๋ค.
+### 0. ๋ฉ๋ด
+- ์ญ ๊ด๋ฆฌ, ๋
ธ์ ๊ด๋ฆฌ, ๊ตฌ๊ฐ ๊ด๋ฆฌ, ์งํ์ฒ ๋
ธ์ ๋ ์ถ๋ ฅ ๋ฒํผ ์์ฑ
+- ๊ฐ ๋ฒํผ์ ํด๋น๋๋ ํ์ด์ง ์์ฑํด์ ์จ๊ธฐ๊ธฐ (์ฒ์ ๋ก๋ ์ ํ์ด์ง๋ ๋ณด์ด๋ฉด ์๋จ)
+- ๊ฐ ๋ฒํผ์ ๊ด๋ จ ํ์ด์ง๋ง ๋ณด์ด๊ณ ๋ค๋ฅธ ํ์ด์ง๋ ์จ๊ธฐ๊ธฐ
+
+### 1. ์ญ ๊ด๋ฆฌ
+- ์ฒ์ ์์์ localStorage๋ฅผ ๋ฐํ์ผ๋ก ํ์ด์ง ๊ตฌ์ฑ ์์ ์์ฑ
+- ์ญ ๊ด๋ฆฌ ๋ฒํผ ๋๋ฅผ ๋๋ง๋ค ์ญ ๋ชฉ๋ก ํ
์ด๋ธ ์๋ก๊ณ ์นจ
+
+- ์ญ ๋ฑ๋ก ์์ธ์ฌํญ
+ - ์ญ ์ด๋ฆ์ด ํ๊ธ์ ์ดํ์ธ ๊ฒฝ์ฐ
+ - ์ญ ์ด๋ฆ์ด ์ค๋ณต๋๋ ๊ฒฝ์ฐ
+- ์ญ ์ด๋ฆ์ ๊ณต๋ฐฑ ๋ชจ๋ ์ ๊ฑฐ
+- ์งํ์ฒ ์ญ ๋ชฉ๋ก ๋์ ์ถ๊ฐ
+- localStorage์ ์ญ ๋ชฉ๋ก ์๋ก ์ ์ฅ
+- ์ญ ๋ชฉ๋ก ํ
์ด๋ธ ํ๋จ์ row ์ถ๊ฐ
+
+- ์ญ ์ญ์ ์์ธ์ฌํญ
+ - ๋
ธ์ ์ ๋ฑ๋ก๋์ด์๋ ๊ฒฝ์ฐ
+- ์ญ์ ๋ฒํผ ๋๋ฅด๋ฉด ํ์ธ์ฐฝ ๋์ฐ๊ธฐ
+- localStorage์ ์ญ ๋ชฉ๋ก ์๋ก ์ ์ฅ
+- ์ญ์ ๋ ์ญ row๋ฅผ ํ
์ด๋ธ์์ ์ ๊ฑฐ
+ - ์ญ์ ๋ฒํผ์ dataset์ผ๋ก row ์ฐพ๊ธฐ
+
+
+
+### 2. ๋
ธ์ ๊ด๋ฆฌ
+- ์ฒ์ ์์์ localStorage๋ฅผ ๋ฐํ์ผ๋ก ํ์ด์ง ๊ตฌ์ฑ ์์ ์์ฑ
+
+- ๋
ธ์ ๊ด๋ฆฌ ๋ฒํผ ๋๋ฅผ ๋๋ง๋ค
+ - ์ํ ํํ selector ๋ชฉ๋ก ์๋ก๊ณ ์นจ
+ - ๋
ธ์ ๋ชฉ๋ก ํ
์ด๋ธ ์๋ก๊ณ ์นจ
+
+- ๋
ธ์ ๋ฑ๋ก ์์ธ์ฌํญ
+ - ๋
ธ์ ์ด๋ฆ์ด ๋น์ด์๋ ๊ฒฝ์ฐ
+ - ๋
ธ์ ์ด๋ฆ์ด ์ค๋ณต๋๋ ๊ฒฝ์ฐ
+ - ์ํ ์ข
์ ๊ณผ ํํ ์ข
์ ์ด ๊ฐ์ ๊ฒฝ์ฐ
+- ์ํ ์ข
์ ์ญ๊ณผ ํํ ์ข
์ ์ญ ์ ํ
+ - ์ํ๊ณผ ํํ ์ข
์ ์ญ selector์ ๊ธฐ๋ณธ์ ์ฒซ ์ญ์ผ๋ก ๋ณด์ฌ์ฃผ๊ธฐ
+ - ์ํ ์ข
์ ์ญ๊ณผ ํํ ์ข
์ ์ญ์ ์ญ ๋ชฉ๋ก ์์๋๋ก ๋ณด์ฌ์ฃผ๊ธฐ
+- ๋
ธ์ ์ด๋ฆ์ ๊ณต๋ฐฑ ๋ชจ๋ ์ ๊ฑฐ
+- ๋
ธ์ ๋ชฉ๋ก ๋์ ์ถ๊ฐ
+- ์ญ ๋ชฉ๋ก์ ํด๋น ์ญ์ ๋
ธ์ ์ ๋ณด ์ถ๊ฐ
+- ๋
ธ์ ๋ชฉ๋ก๊ณผ ์ญ ๋ชฉ๋ก localStorage์ ์๋ก ์ ์ฅ
+- ๋
ธ์ ๋ชฉ๋ก ํ
์ด๋ธ ํ๋จ์ row ์ถ๊ฐ
+
+- ์งํ์ฒ ๋
ธ์ ์ญ์
+- ์ญ์ ๋ฒํผ ๋๋ฅด๋ฉด ํ์ธ์ฐฝ ๋์ฐ๊ธฐ
+- ์ญ ๋ชฉ๋ก์์ ํด๋น ์ญ์ ๋
ธ์ ์ ๋ณด ์ ๊ฑฐ
+- ๋
ธ์ ๋ชฉ๋ก๊ณผ ์ญ ๋ชฉ๋ก localStorage์ ์๋ก ์ ์ฅ
+- ๋
ธ์ ๋ชฉ๋ก ํ
์ด๋ธ์์ ํด๋น row๋ฅผ ์ ๊ฑฐ
+ - ์ญ์ ๋ฒํผ์ dataset์ผ๋ก row ์ฐพ๊ธฐ
+
+
+
+### 3. ๊ตฌ๊ฐ ๊ด๋ฆฌ
+- ์ฒ์ ์์์ localStorage๋ฅผ ๋ฐํ์ผ๋ก ํ์ด์ง ๊ตฌ์ฑ ์์ ์์ฑ
+
+- ๊ตฌ๊ฐ ๊ด๋ฆฌ ๋ฒํผ ๋๋ฅผ ๋๋ง๋ค
+ - ๊ฐ ๋
ธ์ ๋ณ๋ก ๋ฒํผ ์๋ก ์์ฑ
+ - selector ๋ชฉ๋ก ์๋ก๊ณ ์นจ
+
+- ๋
ธ์ ๋ฒํผ ๋๋ฅผ ๋๋ง๋ค
+ - ๋
ธ์ ๊ตฌ๊ฐ ํ
์ด๋ธ ์๋ก๊ณ ์นจ
+
+- ๊ตฌ๊ฐ ์ถ๊ฐ ์์ธ์ฌํญ
+ - ์์๊ฐ ๋น์ด์๋ ๊ฒฝ์ฐ
+ - ์์๊ฐ ์์์ธ ๊ฒฝ์ฐ
+ - ์์๊ฐ ์ข
์ ์ญ ์์๋ณด๋ค 1๋๊ฒ ํฐ ๊ฒฝ์ฐ (์ฐ์์ ์ด์ง ์์ ์์ ๋ฐ์์ํค๋ ๊ฒฝ์ฐ)
+ - ์ด๋ฏธ ๋ฑ๋ก๋ ์ญ์ธ ๊ฒฝ์ฐ
+- ์
๋ ฅํ ์์ ์ดํ์ ์์๋ ๋ฐ๋ฆผ (์์๋ ์ค๋ณต๋์ง ์์)
+- ๋
ธ์ ๋ชฉ๋ก์์, ํด๋น๋๋ ๋
ธ์ ์ ์ญ ๋ฆฌ์คํธ์, ํด๋น๋๋ ์์๋ก ์ญ ๋ฑ๋ก
+- ์ญ ๋ชฉ๋ก์ ํด๋น ์ญ์ ๋
ธ์ ์ ๋ณด ์ถ๊ฐ
+- ๋
ธ์ ๋ชฉ๋ก๊ณผ ์ญ ๋ชฉ๋ก localStorage์ ์๋ก ์ ์ฅ
+- ํธ์ ๋ณ ์ญ ๋ชฉ๋ก ํ
์ด๋ธ์ ํด๋น๋๋ ์์ row ์ถ๊ฐ
+
+- ๊ตฌ๊ฐ ์ ๊ฑฐ ์์ธ์ฌํญ
+ - ํด๋น ํธ์ ์ ์ญ์ด ๋๊ฐ ์ดํ์ธ ๊ฒฝ์ฐ๋ ๋
ธ์ ์์ ์ญ ์ ๊ฑฐ ๋ถ๊ฐ
+- ๋
ธ์ ๋ชฉ๋ก์์ ํด๋น ํธ์ ์ ํด๋น ์ญ ์ ๊ฑฐ
+- ์ญ ๋ชฉ๋ก์์ ํด๋น ์ญ์ ๋
ธ์ ์ ๋ณด ์ ๊ฑฐ
+- ๋
ธ์ ๋ชฉ๋ก๊ณผ ์ญ ๋ชฉ๋ก localStorage์ ์๋ก ์ ์ฅ
+- ํธ์ ๋ณ ์ญ ๋ชฉ๋ก ํ
์ด๋ธ์์ ํด๋น๋๋ ์์ row ์ ๊ฑฐ
+
+### 4. ์งํ์ฒ ๋
ธ์ ๋ ์ถ๋ ฅ
+- ์งํ์ฒ ๋
ธ์ ๋ ์ถ๋ ฅ ๋ฒํผ ํด๋ฆญํ ๋๋ง๋ค
+ - ํธ์ ๊ณผ ํด๋น๋๋ ์ญ์ ์์๋๋ก ํ๋ฉด์ ์๋ก ์ถ๋ ฅํ๊ธฐ
+
+### 5. LocalStorage
+- stationList ๊ฐ์ฒด
+ - key: ์ญ์ด๋ฆ
+ - value: ์ญ์ด ๋ฑ๋ก๋ ๋
ธ์ ๋ฐฐ์ด
+- lineList ๊ฐ์ฒด
+ - key: ๋
ธ์ ์ด๋ฆ
+ - value: ๋
ธ์ ์ ๋ฑ๋ก๋ ์ญ ๋ฐฐ์ด
\ No newline at end of file
diff --git a/src/common_utils.js b/src/common_utils.js
new file mode 100644
index 000000000..7742c14ed
--- /dev/null
+++ b/src/common_utils.js
@@ -0,0 +1,82 @@
+import DomUtils from './dom_utils.js';
+
+export default class CommonUtils {
+ constructor() {
+ this._privateDomUtils = new DomUtils();
+ }
+
+ alertError(errorMessage) {
+ alert(errorMessage);
+ }
+
+ createDiv(toIdName, idName) {
+ const div = document.createElement('div');
+
+ this._privateDomUtils.setAttribute('id', div, idName);
+ this._privateDomUtils.appendToIdName(toIdName, div);
+ }
+
+ createTitle(titleTag, titleContent, toIdName) {
+ const title = document.createElement(titleTag);
+
+ title.innerHTML = titleContent;
+ this._privateDomUtils.appendToIdName(toIdName, title);
+ }
+
+ createUnorderedList(stationList, toIdName) {
+ const list = document.createElement('ul');
+
+ this._privateDomUtils.appendToIdName(toIdName, list);
+
+ for (const station of stationList) {
+ this.createListElement(list, station);
+ }
+ }
+
+ createListElement(list, station) {
+ const element = document.createElement('li')
+
+ element.innerHTML = station;
+ this._privateDomUtils.appendToVarName(list, element);
+ }
+
+ insertEmptyline(toIdName) {
+ const newline = document.createElement('br');
+
+ this._privateDomUtils.appendToIdName(toIdName, newline);
+ }
+
+ getLocalStorageStation() {
+ const stationList = JSON.parse(localStorage.getItem('stationList'));
+
+ if (!stationList) {
+ return {};
+ }
+
+ return stationList;
+ }
+
+ getLocalStorageLine() {
+ const lineList = JSON.parse(localStorage.getItem('lineList'));
+
+ if (!lineList) {
+ return {};
+ }
+
+ return lineList;
+ }
+
+ saveToLocalStorage(datasetName, data) {
+ localStorage.setItem(datasetName, JSON.stringify(data));
+ }
+
+ renewSelect(idName) {
+ const select = document.getElementById(idName);
+
+ select.value = select.firstChild.value;
+ }
+
+ emptyInput(input) {
+ input.value = '';
+ }
+}
\ No newline at end of file
diff --git a/src/dom_utils.js b/src/dom_utils.js
new file mode 100644
index 000000000..075c2332d
--- /dev/null
+++ b/src/dom_utils.js
@@ -0,0 +1,74 @@
+export default class DomUtils {
+ constructor() {
+ this.DO_NOT_APPEND = false;
+ this.ID_ATTRIBUTE = 'id';
+ }
+
+ createButton(idName, buttonText) {
+ const button = document.createElement('button');
+
+ this.setAttribute(this.ID_ATTRIBUTE, button, idName);
+ this.setInnerHtml(button, buttonText);
+
+ return button;
+ }
+
+ createArticle(toIdName, idName) {
+ const article = document.createElement('ARTICLE');
+
+ this.setAttribute(this.ID_ATTRIBUTE, article, idName);
+ this.appendToIdName(toIdName, article);
+
+ return article
+ }
+
+ setAttribute(attribute, varName, attributeName) {
+ varName.setAttribute(attribute, attributeName);
+ }
+
+ setInnerHtml(varName, buttonText) {
+ varName.innerHTML = buttonText;
+ }
+
+ appendToIdName(toIdName, varName) {
+ document.getElementById(toIdName).appendChild(varName);
+ }
+
+ appendToVarName(toVarName, varName) {
+ toVarName.appendChild(varName);
+ }
+
+ appendBefore(toIdName, varName, before) {
+ const toVarName = document.getElementById(toIdName);
+
+ toVarName.insertBefore(varName, before);
+ }
+
+ displayNone(varName) {
+ varName.style.display = "none";
+ }
+
+ createInput(inputObject) {
+ const input = document.createElement('input');
+
+ this.setAttribute(inputObject['attribute'], input, inputObject['idName']);
+ this.setInputType(input, inputObject['type']);
+ this.setPlaceholder(input, inputObject['placeholder']);
+ this.appendToIdName(inputObject['toIdName'], input)
+ input.style.margin = '0 2px 0 2px';
+
+ return input;
+ }
+
+ setInputType(input, type) {
+ input.setAttribute('type', type);
+ }
+
+ setPlaceholder(input, placeholder) {
+ input.placeholder = placeholder;
+ }
+
+ addDataAttribute(tag, trackingData) {
+ tag.setAttribute('data-tracking', trackingData);
+ }
+}
\ No newline at end of file
diff --git a/src/index.js b/src/index.js
index e69de29bb..43a7bc448 100644
--- a/src/index.js
+++ b/src/index.js
@@ -0,0 +1,22 @@
+import ManageStation from './manage_station.js';
+import Menu from './menu.js';
+import ManageLine from './manage_line.js';
+import ManageSection from './manage_section.js';
+
+export default class SubwayMap {
+ constructor() {
+ document.body.style.fontFamily = 'Arial';
+
+ const menu = new Menu();
+ const manageStation = new ManageStation();
+ const manageLine = new ManageLine();
+ const manageSection = new ManageSection();
+
+ menu.createMenu();
+ manageLine.initPage();
+ manageStation.initPage();
+ manageSection.initPage();
+ }
+}
+
+new SubwayMap();
\ No newline at end of file
diff --git a/src/manage_line.js b/src/manage_line.js
new file mode 100644
index 000000000..2b69f4f14
--- /dev/null
+++ b/src/manage_line.js
@@ -0,0 +1,219 @@
+import CommonUtils from "./common_utils.js";
+import DomUtils from "./dom_utils.js";
+import TableUtils from "./table_utils.js";
+import SelectUtils from "./select_utils.js";
+import StringUtils from "./string_utils.js";
+
+export default class ManageLine {
+ setPrivateVariables() {
+ this._privateCommonUtils = new CommonUtils();
+ this._privateDomUtils = new DomUtils();
+ this._privateTableUtils = new TableUtils();
+ this._privateSelectUtils = new SelectUtils();
+ this._privateStringUtils = new StringUtils();
+ }
+
+ setConst() {
+ this.ARTICLE_NAME = 'lineArticle';
+
+ this.LINE_INPUT_ID = 'line-name-input';
+ this.LINE_INPUT_TITLE_TAG = 'div';
+ this.LINE_INPUT_TITLE_TEXT = '๋
ธ์ ์ด๋ฆ';
+ this.LINE_INPUT_PLACEHOLDER = '๋
ธ์ ์ด๋ฆ์ ์
๋ ฅํด์ฃผ์ธ์';
+ this.LINE_INPUT_TYPE = 'String';
+
+ this.ADD_BUTTON_ID = 'line-add-button';
+ this.ADD_BUTTON_TEXT = '๋
ธ์ ์ถ๊ฐ';
+
+ this.LINE_LIST_TITLE_TAG = 'h2';
+ this.LINE_LIST_TITLE_TEXT = '๐ ์งํ์ฒ ์ญ ๋ชฉ๋ก';
+
+ this.IS_VALID = 1;
+ this.IS_NOT_VALID = 0;
+
+ this.DELETE_BUTTON_TEXT = '์ญ์ ';
+ this.IS_NOT_VALID = false;
+ this.IS_VALID = true;
+
+ this.EMPTY_ERROR_MESSAGE = '๋
ธ์ ์ด๋ฆ์ ํ ๊ธ์ ์ด์ ์
๋ ฅํด์ฃผ์ธ์';
+ this.OVERLAP_ERROR_MESSAGE = '์ด๋ฏธ ์กด์ฌํ๋ ๋
ธ์ ์ด๋ฆ์
๋๋ค.'
+ this.SAME_START_END_ERROR_MESSAGE = '์ํ ์ข
์ ์ญ๊ณผ ํํ ์ข
์ ์ญ์ด ๊ฐ์ต๋๋ค.'
+ }
+
+ initPage() {
+ this.setConst();
+ this.setPrivateVariables();
+ this.initLists();
+
+ this.createLineAddSection();
+ this.createTableSection();
+ }
+
+ initLists() {
+ this._lineList = this._privateCommonUtils.getLocalStorageLine();
+ this._stationList = this._privateCommonUtils.getLocalStorageStation();
+ this._privateCommonUtils.insertEmptyline(this.ARTICLE_NAME);
+ }
+
+ /*
+ * this.createLineAddSection()
+ */
+
+ createLineAddSection() {
+ this.createInputSection();
+ this._privateSelectUtils.createSelectSection(this.ARTICLE_NAME);
+ this._privateCommonUtils.insertEmptyline(this.ARTICLE_NAME);
+ this.createLineAddButton();
+ }
+
+ createInputSection() {
+ this._privateCommonUtils.createTitle('div', this.LINE_INPUT_TITLE_TEXT, this.ARTICLE_NAME);
+ this.createLineInput();
+ this._privateCommonUtils.insertEmptyline(this.ARTICLE_NAME);
+ }
+
+ createLineInput() {
+ const inputObject = this.lineInputObject();
+
+ this._lineInput = this._privateDomUtils.createInput(inputObject);
+ }
+
+ lineInputObject() {
+ const inputObject = {
+ 'attribute': 'id',
+ 'toIdName': this.ARTICLE_NAME,
+ 'idName': this.LINE_INPUT_ID,
+ 'placeholder': this.LINE_INPUT_PLACEHOLDER,
+ 'type': this.LINE_INPUT_TYPE,
+ }
+
+ return inputObject;
+ }
+
+ /*
+ * this.createLineAddButton()
+ */
+
+ createLineAddButton() {
+ this._lineAddButton = this._privateDomUtils.createButton(this.ADD_BUTTON_ID, this.ADD_BUTTON_TEXT);
+ this._privateDomUtils.appendToIdName(this.ARTICLE_NAME, this._lineAddButton);
+ this.addEventToButton();
+ }
+
+ addEventToButton() {
+ this._lineAddButton.addEventListener('click', () => {
+ this.createNewLine();
+ })
+ this._lineInput.addEventListener('keypress', e => {
+ if (e.keyCode === 13) {
+ this.createNewLine();
+ }
+ })
+ }
+
+ createNewLine() {
+ this._lineInputValue = this._privateStringUtils.removeSpace(this._lineInput.value);
+
+ if (this.checkLineValidity() === this.IS_VALID) {
+ this.updateAddToLocalStorage();
+ this.addLine();
+ this.renewLineUserInteractions();
+ }
+ else {
+ this.alertCorrespondingError();
+ }
+ }
+
+ checkLineValidity() {
+ if (this.isEmpty() === this.IS_NOT_VALID) {
+ return this.IS_NOT_VALID;
+ }
+
+ if (this.overlap() === this.IS_NOT_VALID) {
+ return this.IS_NOT_VALID;
+ }
+
+ if (this.sameStartEnd() === this.IS_NOT_VALID) {
+ return this.IS_NOT_VALID;
+ }
+
+ return this.IS_VALID;
+ }
+
+ isEmpty() {
+ if (this._lineInputValue.length === 0) {
+ return this.IS_NOT_VALID;
+ }
+
+ return this.IS_VALID;
+ }
+
+ overlap() {
+ const lineList = this._privateCommonUtils.getLocalStorageLine();
+ if (this._lineInputValue in lineList) {
+ return this.IS_NOT_VALID;
+ }
+
+ return this.IS_VALID;
+ }
+
+ sameStartEnd() {
+ this.getSelect();
+ if (this._startSelect.value === this._endSelect.value) {
+ return this.IS_NOT_VALID;
+ }
+
+ return this.IS_VALID;
+ }
+
+ alertCorrespondingError() {
+ if (this.isEmpty() === this.IS_NOT_VALID) {
+ this._privateCommonUtils.alertError(this.EMPTY_ERROR_MESSAGE);
+ }
+ else if (this.overlap() === this.IS_NOT_VALID) {
+ this._privateCommonUtils.alertError(this.OVERLAP_ERROR_MESSAGE);
+ }
+ else if (this.sameStartEnd() === this.IS_NOT_VALID) {
+ this._privateCommonUtils.alertError(this.SAME_START_END_ERROR_MESSAGE);
+ }
+
+ return this.IS_VALID;
+ }
+
+ getSelect() {
+ this._startSelect = document.getElementById('line-start-station-selector');
+ this._endSelect = document.getElementById('line-end-station-selector');
+ }
+
+ updateAddToLocalStorage() {
+ const lineList = this._privateCommonUtils.getLocalStorageLine();
+ const stationList = this._privateCommonUtils.getLocalStorageStation();
+ lineList[this._lineInputValue] = [this._startSelect.value, this._endSelect.value];
+ stationList[this._startSelect.value].push(this._lineInputValue);
+ stationList[this._endSelect.value].push(this._lineInputValue);
+
+ this._privateCommonUtils.saveToLocalStorage('lineList', lineList);
+ this._privateCommonUtils.saveToLocalStorage('stationList', stationList);
+ }
+
+ addLine() {
+ const rowArray = [this._lineInputValue, this._startSelect.value, this._endSelect.value, this.DELETE_BUTTON_TEXT];
+
+ this._privateTableUtils.addRow(rowArray, this.ARTICLE_NAME);
+ }
+
+ renewLineUserInteractions() {
+ this._privateCommonUtils.emptyInput(this._lineInput);
+ this._privateCommonUtils.renewSelect('line-start-station-selector');
+ this._privateCommonUtils.renewSelect('line-end-station-selector');
+ }
+
+ /*
+ * this.createTableSection()
+ */
+
+ createTableSection() {
+ this._privateCommonUtils.createTitle(this.LINE_LIST_TITLE_TAG, this.LINE_LIST_TITLE_TEXT, this.ARTICLE_NAME);
+ this._privateTableUtils.initTable(this.ARTICLE_NAME);
+ }
+}
\ No newline at end of file
diff --git a/src/manage_map_print.js b/src/manage_map_print.js
new file mode 100644
index 000000000..d69d53b90
--- /dev/null
+++ b/src/manage_map_print.js
@@ -0,0 +1,30 @@
+import DomUtils from './dom_utils.js';
+
+export default class ManageMapPrint {
+ emptyArticle(articleName) {
+ const mapArticle = document.getElementById(articleName);
+
+ mapArticle.innerHTML = '';
+ }
+
+ displayMapPrint(articleName, commonUtils) {
+ const mapClass = this.createMapDiv(articleName);
+ const lineList = commonUtils.getLocalStorageLine();
+
+ for (const line in lineList) {
+ commonUtils.createTitle('h3', line, mapClass);
+ commonUtils.createUnorderedList(lineList[line], mapClass);
+ }
+ }
+
+ createMapDiv(articleName) {
+ const domUtils = new DomUtils();
+ const mapDiv = document.createElement('div');
+
+ domUtils.setAttribute('class', mapDiv, 'map');
+ domUtils.setAttribute('id', mapDiv, 'map');
+ domUtils.appendToIdName(articleName, mapDiv);
+
+ return 'map';
+ }
+}
\ No newline at end of file
diff --git a/src/manage_section.js b/src/manage_section.js
new file mode 100644
index 000000000..cfc22c4d1
--- /dev/null
+++ b/src/manage_section.js
@@ -0,0 +1,301 @@
+import TableUtils from './table_utils.js';
+import DomUtils from './dom_utils.js';
+import CommonUtils from './common_utils.js';
+import SelectUtils from './select_utils.js';
+import StringUtils from './string_utils.js';
+
+export default class ManageSection {
+ setPrivateVariables() {
+ this._privateTableUtils = new TableUtils();
+ this._privateDomUtils = new DomUtils();
+ this._privateCommonUtils = new CommonUtils();
+ this._privateSelectUtils = new SelectUtils();
+ this._privateStringUtils = new StringUtils();
+ }
+
+ setConst() {
+ this.IS_VALID = 1;
+ this.IS_NOT_VALID = 0;
+
+ this.ARTICLE_NAME = 'sectionArticle';
+ this.SELECT_LINE_SECTION = 'selectLineSection';
+ this.MANAGE_LINE_SECTION = 'manageLineSection';
+ this.LINE_TABLE_SECTION = 'sectionManageArea';
+
+ this.SELECT_LINE_TITLE_TAG = 'h3';
+ this.SELECT_LINE_TITLE = '๊ตฌ๊ฐ์ ์์ ํ ๋
ธ์ ์ ์ ํํด์ฃผ์ธ์';
+
+ this.MANAGE_LINE_TITLE_TAG = 'h3';
+ this.MANAGE_LINE_TITLE = ' ๊ด๋ฆฌ';
+
+ this.ADD_SECTION_TITLE_TAG = 'h4';
+ this.ADD_SECTION_TITLE = '๊ตฌ๊ฐ ๋ฑ๋ก';
+
+ this.SECTION_ORDER_INPUT_PLACEHOLDER = '์์';
+ this.SECTION_DELETE_TEXT = '๋
ธ์ ์์ ์ ๊ฑฐ';
+
+ this.LINE_BUTTONS_CLASS = 'line-button';
+ this.SELECT_LINE_BUTTON_CLASS = 'section-line-menu-button';
+ this.DELETE_BUTTON_CLASS = 'section-delete-button';
+
+ this.SECTION_STATION_SELECTOR = 'section-station-selector';
+ this.SECTION_ORDER_INPUT = 'section-order-input';
+ this.ADD_BUTTON = 'section-add-button';
+ this.ADD_BUTTON_TEXT = '๋ฑ๋ก';
+
+ this.IS_EMPTY_ERROR_MESSAGE = '์์๋ฅผ ์
๋ ฅํด์ฃผ์ธ์.';
+ this.IS_NEGATIVE_ERROR_MESSAGE = '์์๊ฐ ์๋ ์ ์ ์์๋ฅผ ์
๋ ฅํด์ฃผ์ธ์.';
+ this.IS_NOT_CONSECUTIVE_ERROR_MESSAGE = '๊ธฐ์กด ์์๋ค๊ณผ ์ฐ์๋๋ ์์๋ฅผ ์
๋ ฅํด์ฃผ์ธ์.';
+ this.IS_ALREADY_REGISTERED_ERROR_MESSAGE = '์ด๋ฏธ ๋ฑ๋ก๋์ด์๋ ์ญ์
๋๋ค.';
+ }
+
+ getLocalStorage() {
+ this._lineList = this._privateCommonUtils.getLocalStorageLine();
+ this._stationList = this._privateCommonUtils.getLocalStorageStation();
+ }
+
+ initPage() {
+ this.setPrivateVariables();
+ this.setConst();
+ this.getLocalStorage();
+
+ this.createSelectLineSection();
+ this.createManageLineSection();
+ this.createManageLineSectionTable();
+ }
+
+ /*
+ * createSelectLineSection()
+ */
+
+ createSelectLineSection() {
+ this._privateCommonUtils.createDiv(this.ARTICLE_NAME, this.SELECT_LINE_SECTION);
+ this._privateCommonUtils.createTitle(this.SELECT_LINE_TITLE_TAG, this.SELECT_LINE_TITLE, this.SELECT_LINE_SECTION);
+ this.createLineButtons();
+ }
+
+ createLineButtons() {
+ this.setPrivateVariables();
+ this.setConst();
+ const lineList = this._privateCommonUtils.getLocalStorageLine();
+
+ for (const line in lineList) {
+ const button = this._privateDomUtils.createButton(`${line}Button`, line);
+
+ this._privateDomUtils.appendToIdName(this.SELECT_LINE_SECTION, button);
+ button.style.margin = "2px";
+ this._privateDomUtils.setAttribute('class', button, this.LINE_BUTTONS_CLASS);
+ this.addEventToLineSelectButton(button, line);
+ }
+ }
+
+ addEventToLineSelectButton(button, line) {
+ button.addEventListener('click', () => {
+ this.showManageLineSection();
+ this.changeManageLineSection(line);
+ })
+ }
+
+ showManageLineSection() {
+ const manageLineSection = document.getElementById(this.MANAGE_LINE_SECTION);
+
+ manageLineSection.style.display = 'block';
+ }
+
+ changeManageLineSection(line) {
+ this.changeManageLineSectionTitle(line);
+ this.changeManageLineSectionTable(line);
+ }
+
+ changeManageLineSectionTitle(line) {
+ const manageLineTitle = document.querySelector("#manageLineSection h3");
+
+ manageLineTitle.innerHTML = line + this.MANAGE_LINE_TITLE;
+ }
+
+ changeManageLineSectionTable(line) {
+ this._privateTableUtils.refreshTableData(this.LINE_TABLE_SECTION, line);
+ }
+
+ /*
+ * createManageLineSection()
+ */
+
+ createManageLineSection() {
+ this._privateCommonUtils.createDiv(this.ARTICLE_NAME, this.MANAGE_LINE_SECTION);
+ this._privateCommonUtils.createTitle(this.MANAGE_LINE_TITLE_TAG, this.MANAGE_LINE_TITLE, this.MANAGE_LINE_SECTION);
+ this.createSectionAddArea();
+ this.hideManageLineSection();
+ }
+
+ hideManageLineSection() {
+ const manageLineSection = document.getElementById(this.MANAGE_LINE_SECTION);
+
+ manageLineSection.style.display = 'none';
+ }
+
+ createSectionAddArea() {
+ this._privateCommonUtils.createTitle(this.ADD_SECTION_TITLE_TAG, this.ADD_SECTION_TITLE, this.MANAGE_LINE_SECTION);
+ this._privateSelectUtils.createSelect(this.MANAGE_LINE_SECTION, this.SECTION_STATION_SELECTOR, this._privateCommonUtils, this._privateDomUtils);
+ this.createSectionOrderInput();
+ this.createSectionAddButton();
+ }
+
+ createSectionOrderInput() {
+ const inputObject = this.createInputObject();
+ this._orderInput = this._privateDomUtils.createInput(inputObject);
+ }
+
+ createInputObject() {
+ const inputObject = {
+ 'attribute': 'id',
+ 'toIdName': this.MANAGE_LINE_SECTION,
+ 'idName': this.SECTION_ORDER_INPUT,
+ 'placeholder': this.SECTION_ORDER_INPUT_PLACEHOLDER,
+ 'type': 'number',
+ }
+
+ return inputObject;
+ }
+
+ createSectionAddButton() {
+ const button = this._privateDomUtils.createButton(this.ADD_BUTTON, this.ADD_BUTTON_TEXT);
+
+ this._privateDomUtils.appendToIdName(this.MANAGE_LINE_SECTION, button);
+ this.addEventToAddButton(button);
+ }
+
+ addEventToAddButton(button) {
+ button.addEventListener('click', () => {
+ this.createNewSection();
+ })
+ this._orderInput.addEventListener('keypress', (e) => {
+ if (e.keyCode === 13) {
+ this.createNewSection();
+ }
+ })
+ }
+
+ createNewSection() {
+ if (this.checkSectionValidity() === this.IS_VALID) {
+ const line = this.getCurrentLineFromTitle();
+
+ this.updateAddToLocalStorage();
+ this._privateTableUtils.refreshTableData(this.LINE_TABLE_SECTION, line);
+ this.renewSectionUserInteractions();
+ }
+ else {
+ this.alertCorrespondingError();
+ }
+ }
+
+ renewSectionUserInteractions() {
+ this._privateCommonUtils.renewSelect('section-station-selector');
+ this._privateCommonUtils.emptyInput(this._orderInput);
+ }
+
+ checkSectionValidity() {
+ if (this.isAlreadyRegistered() === this.IS_NOT_VALID) {
+ return this.IS_NOT_VALID
+ }
+ if (this.isEmpty() === this.IS_NOT_VALID) {
+ return this.IS_NOT_VALID;
+ }
+ if (this.isNegative() === this.IS_NOT_VALID) {
+ return this.IS_NOT_VALID;
+ }
+ if (this.isNotConsecutive() === this.IS_NOT_VALID) {
+ return this.IS_NOT_VALID;
+ }
+
+ return this.IS_VALID;
+ }
+
+ isAlreadyRegistered() {
+ const lineList = this._privateCommonUtils.getLocalStorageLine();
+ const line = this.getCurrentLineFromTitle();
+ const station = this.getSelectedStation();
+
+ if (lineList[line].includes(station)) {
+ return this.IS_NOT_VALID;
+ }
+
+ return this.IS_VALID;
+ }
+
+ isEmpty() {
+ if (!this._orderInput.value) {
+ return this.IS_NOT_VALID;
+ }
+
+ return this.IS_VALID;
+ }
+
+ isNegative() {
+ if (this._orderInput.value < 0) {
+ return this.IS_NOT_VALID;
+ }
+
+ return this.IS_VALID;
+ }
+
+ isNotConsecutive() {
+ const tbody = document.querySelector(`#${this.LINE_TABLE_SECTION}Table tbody`);
+ const rowCount = tbody.childElementCount;
+
+ if (this._orderInput.value >= rowCount) {
+ return this.IS_NOT_VALID;
+ }
+
+ return this.IS_VALID;
+ }
+
+ alertCorrespondingError() {
+ if (this.isEmpty() === this.IS_NOT_VALID) {
+ this._privateCommonUtils.alertError(this.IS_EMPTY_ERROR_MESSAGE);
+ }
+ else if (this.isNegative() === this.IS_NOT_VALID) {
+ this._privateCommonUtils.alertError(this.IS_NEGATIVE_ERROR_MESSAGE);
+ }
+ else if (this.isNotConsecutive() === this.IS_NOT_VALID) {
+ this._privateCommonUtils.alertError(this.IS_NOT_CONSECUTIVE_ERROR_MESSAGE);
+ }
+ else if (this.isAlreadyRegistered() === this.IS_NOT_VALID) {
+ this._privateCommonUtils.alertError(this.IS_ALREADY_REGISTERED_ERROR_MESSAGE);
+ }
+ }
+
+ updateAddToLocalStorage() {
+ const lineList = this._privateCommonUtils.getLocalStorageLine();
+ const stationList = this._privateCommonUtils.getLocalStorageStation();
+ const line = this.getCurrentLineFromTitle();
+ const station = this.getSelectedStation();
+
+ lineList[line].splice(this._orderInput.value, 0, station);
+ stationList[station].push(line);
+
+ this._privateCommonUtils.saveToLocalStorage('lineList', lineList);
+ this._privateCommonUtils.saveToLocalStorage('stationList', stationList);
+ }
+
+ getCurrentLineFromTitle() {
+ const title = document.querySelector("#manageLineSection h3");
+
+ return title.innerHTML.split(' ')[0];
+ }
+
+ getSelectedStation() {
+ return document.getElementById('section-station-selector').value;
+ }
+
+ /*
+ * createManageLineSectionTable
+ */
+
+ createManageLineSectionTable() {
+ this._privateCommonUtils.createDiv(this.MANAGE_LINE_SECTION, this.LINE_TABLE_SECTION);
+ this._privateCommonUtils.insertEmptyline(this.LINE_TABLE_SECTION);
+ this._privateCommonUtils.insertEmptyline(this.LINE_TABLE_SECTION);
+ this._privateTableUtils.initTable(this.LINE_TABLE_SECTION);
+ }
+}
\ No newline at end of file
diff --git a/src/manage_station.js b/src/manage_station.js
new file mode 100644
index 000000000..fb6e152b7
--- /dev/null
+++ b/src/manage_station.js
@@ -0,0 +1,150 @@
+import DomUtils from './dom_utils.js';
+import TableUtils from './table_utils.js';
+import CommonUtils from './common_utils.js';
+import StringUtils from './string_utils.js';
+
+export default class ManageStation {
+ setPrivateVariable() {
+ this._privateStringUtils = new StringUtils();
+ this._privateDomUtils = new DomUtils();
+ this._privateCommonUtils = new CommonUtils();
+ this._privateTableUtils = new TableUtils();
+ }
+
+ setConst() {
+ this.ARTICLE_NAME = 'stationArticle';
+
+ this.MENU_TYPE = 'station',
+ this.ADD_TYPE = 'Add',
+ this.DELETE_TYPE = 'Delete',
+
+ this.STATION_INPUT_TITLE_TAG = 'div';
+ this.STATION_INPUT_TITLE_TEXT = '์ญ ์ด๋ฆ';
+ this.STATION_LIST_TITLE_TAG = 'h2';
+ this.STATION_LIST_TITLE_TEXT = '๐ ์งํ์ฒ ์ญ ๋ชฉ๋ก';
+
+ this.STATION_INPUT_ID = 'station-name-input';
+ this.ADD_BUTTON_ID = 'station-add-button';
+
+ this.STATION_INPUT_PLACEHOLDER = '์ญ ์ด๋ฆ์ ์
๋ ฅํด์ฃผ์ธ์';
+ this.STATION_INPUT_TYPE = 'String';
+ this.MINLENGTH_ERROR_MESSAGE = '์ญ ์ด๋ฆ์ ๋ ๊ธ์ ์ด์ ์
๋ ฅํด์ฃผ์ธ์';
+ this.OVERLAP_ERROR_MESSAGE = '์ด๋ฏธ ์กด์ฌํ๋ ์ญ์
๋๋ค.'
+
+ this.ADD_BUTTON_TEXT = '์ญ ์ถ๊ฐ';
+ this.DELETE_BUTTON_TEXT = '์ญ์ ';
+
+ this.IS_VALID = true;
+ this.IS_NOT_VALID = false;
+ }
+
+ initPage() {
+ this.setPrivateVariable();
+ this._stationList = {};
+ this.setConst();
+
+ this.createInputSection();
+ this.createTableSection();
+ }
+
+ createInputSection() {
+ this._privateCommonUtils.insertEmptyline(this.ARTICLE_NAME);
+ this._privateCommonUtils.createTitle(this.STATION_INPUT_TITLE_TAG, this.STATION_INPUT_TITLE_TEXT, this.ARTICLE_NAME);
+ this.createStationInput();
+ this._stationAddButton = this._privateDomUtils.createButton(this.ADD_BUTTON_ID, this.ADD_BUTTON_TEXT);
+ this._privateDomUtils.appendToIdName(this.ARTICLE_NAME, this._stationAddButton);
+ this.addEventToButton(this.ADD_TYPE, this.MENU_TYPE);
+ }
+
+ createTableSection() {
+ this._privateCommonUtils.createTitle(this.STATION_LIST_TITLE_TAG, this.STATION_LIST_TITLE_TEXT, this.ARTICLE_NAME);
+ this._privateTableUtils.initTable(this.ARTICLE_NAME);
+ }
+
+ createStationInput() {
+ const inputObject = this.stationInputObject();
+
+ this._stationInput = this._privateDomUtils.createInput(inputObject);
+ }
+
+ stationInputObject() {
+ const inputObject = {
+ 'attribute': 'id',
+ 'toIdName': this.ARTICLE_NAME,
+ 'idName': this.STATION_INPUT_ID,
+ 'placeholder': this.STATION_INPUT_PLACEHOLDER,
+ 'type': this.STATION_INPUT_TYPE,
+ }
+
+ return inputObject;
+ }
+
+ addEventToButton(buttonType, menuType) {
+ this[`_station${buttonType}Button`].addEventListener('click', () => {
+ this.addStation();
+ })
+ this[`_${menuType}Input`].addEventListener('keypress', e => {
+ if (e.keyCode === 13) {
+ this.addStation();
+ }
+ })
+ }
+
+ addStation() {
+ this._inputValue = this._privateStringUtils.removeSpace(this._stationInput.value);
+ console.log(this._inputValue);
+
+ if (this.checkStationValidity() === this.IS_VALID) {
+ const rowArray = [this._inputValue, this.DELETE_BUTTON_TEXT];
+
+ this.addToStationList(this._inputValue);
+ this._privateCommonUtils.saveToLocalStorage('stationList', this._stationList);
+ this._privateTableUtils.addRow(rowArray, this.ARTICLE_NAME);
+ this._stationInput.value = '';
+ }
+ }
+
+ checkStationValidity() {
+ if (this.minLength() === this.IS_NOT_VALID) {
+ this._privateCommonUtils.alertError(this.MINLENGTH_ERROR_MESSAGE);
+
+ return this.IS_NOT_VALID;
+ }
+
+ if (this.overlap() === this.IS_NOT_VALID) {
+ this._privateCommonUtils.alertError(`"${this._inputValue}"์/๋ ` + this.OVERLAP_ERROR_MESSAGE)
+
+ return this.IS_NOT_VALID;
+ }
+
+ return this.IS_VALID;
+ }
+
+ minLength() {
+ if (this._inputValue.length <= 1) {
+ return this.IS_NOT_VALID;
+ }
+
+ return this.IS_VALID;
+ }
+
+ overlap() {
+ const stationList = this._privateCommonUtils.getLocalStorageStation();
+
+ if (this._inputValue in stationList) {
+ return this.IS_NOT_VALID;
+ }
+
+ return this.IS_VALID;
+ }
+
+ addToStationList(stationName) {
+ this._stationList = this._privateCommonUtils.getLocalStorageStation();
+
+ if (!this._stationList) {
+ this._stationList = {};
+ }
+
+ this._stationList[stationName] = [];
+ }
+}
\ No newline at end of file
diff --git a/src/menu.js b/src/menu.js
new file mode 100644
index 000000000..f3cf8366e
--- /dev/null
+++ b/src/menu.js
@@ -0,0 +1,182 @@
+import DomUtils from './dom_utils.js';
+import StringUtils from './string_utils.js';
+import TableUtils from './table_utils.js';
+import CommonUtils from './common_utils.js';
+import ManageLine from './manage_line.js';
+import SelectUtils from './select_utils.js';
+import ManageMapPrint from './manage_map_print.js';
+import ManageSection from './manage_section.js';
+
+export default class Menu {
+ setPrivateVariables() {
+ this._privateDomUtils = new DomUtils();
+ this._privateStringUtils = new StringUtils();
+ this._privateTableUtils = new TableUtils();
+ this._privateCommonUtils = new CommonUtils();
+ this._privateSelectUtils = new SelectUtils();
+ }
+
+ setIdName() {
+ this.APP = 'app';
+ this.ARTICLE_AREA = 'articleArea';
+ this.DO_NOT_APPEND = false;
+
+ this.STATION_ARTICLE = 'stationArticle';
+ this.LINE_ARTICLE = 'lineArticle';
+ this.SECTION_ARTICLE = 'sectionArticle';
+ this.MAP_PRINT_ARTICLE = 'mapArticle';
+
+ this.LINE_BUTTON_CLASS = 'line-button'
+ }
+
+ managerButton() {
+ this._managerButton = {
+ 'station-manager-button': '1. ์ญ ๊ด๋ฆฌ',
+ 'line-manager-button': '2. ๋
ธ์ ๊ด๋ฆฌ',
+ 'section-manager-button': '3. ๊ตฌ๊ฐ ๊ด๋ฆฌ',
+ 'map-print-manager-button': '4. ์งํ์ฒ ๋
ธ์ ๋ ์ถ๋ ฅ',
+ }
+ }
+
+ createMenu() {
+ this.setIdName();
+ this.managerButton();
+ this.setPrivateVariables();
+
+ this.createArticleArea();
+ for (const idName in this._managerButton) {
+ const varName = this.createMenuButton(idName);
+ const articleName = this.createMenuArticle(idName);
+ this.addEventToButton(varName, articleName);
+ }
+ }
+
+ createArticleArea() {
+ this._articleArea = this._privateDomUtils.createArticle(this.APP, this.ARTICLE_AREA);
+ }
+
+ createMenuButton(idName) {
+ const varName = this._privateStringUtils.getVarName(idName);
+
+ this[`_${varName}`] = this._privateDomUtils.createButton(idName, this._managerButton[idName]);
+ this._privateDomUtils.appendBefore(this.APP, this[`_${varName}`], this._articleArea);
+
+ return varName;
+ }
+
+ createMenuArticle(idName) {
+ const articleName = this._privateStringUtils.getArticleName(idName);
+
+ this[`_${articleName}`] = this._privateDomUtils.createArticle(this.ARTICLE_AREA, articleName);
+ this._privateDomUtils.displayNone(this[`_${articleName}`]);
+
+ return articleName;
+ }
+
+ addEventToButton(varName, articleName) {
+ this[`_${varName}`].addEventListener('click', () => {
+ this.showArticle(articleName);
+ this.refreshArticle(articleName);
+ });
+ }
+
+ showArticle(articleName) {
+ this.hideAllArticle();
+ this.showCorrespondingArticle(articleName);
+ }
+
+ hideAllArticle() {
+ for (let i = 0; i < 4; i++) {
+ this._articleArea.children[i].style.display = 'none'
+ }
+ }
+
+ showCorrespondingArticle(articleName) {
+ this[`_${articleName}`].style.display = 'block';
+ }
+
+ refreshArticle(articleName) {
+ if (articleName === this.STATION_ARTICLE) {
+ this.refreshStationArticle(articleName);
+ }
+ else if (articleName === this.LINE_ARTICLE) {
+ this.refreshLineArticle(articleName);
+ }
+ else if (articleName === this.SECTION_ARTICLE) {
+ this.refreshSectionArticle();
+ }
+ else if (articleName === this.MAP_PRINT_ARTICLE) {
+ this.refreshMapPrint(articleName);
+ }
+ }
+
+ refreshStationArticle(articleName) {
+ this.findInputAndEmpty('station-name-input');
+ this._privateTableUtils.emptyTableData(articleName);
+ this._privateTableUtils.initStationTableData(articleName);
+ }
+
+ refreshLineArticle(articleName) {
+ this.findInputAndEmpty('line-name-input')
+ this.refreshLineSelect();
+ this._privateTableUtils.refreshTableData(articleName);
+ }
+
+ refreshLineSelect() {
+ const startSelect = document.getElementById('line-start-station-selector');
+ const endSelect = document.getElementById('line-end-station-selector');
+
+ startSelect.innerHTML = '';
+ endSelect.innerHTML = '';
+
+ this._privateSelectUtils.addStationsToSelect(startSelect, this._privateCommonUtils, this._privateDomUtils);
+ this._privateSelectUtils.addStationsToSelect(endSelect, this._privateCommonUtils, this._privateDomUtils);
+ }
+
+ refreshSectionArticle() {
+ this.findInputAndEmpty('section-order-input');
+ this.refreshSectionLineButtons();
+ this.refreshStationsSelector();
+ }
+
+ findInputAndEmpty(idName) {
+ const input = document.getElementById(idName)
+ this._privateCommonUtils.emptyInput(input);
+ }
+
+ refreshSectionLineButtons() {
+ this.removeButtons();
+
+ const manageSection = new ManageSection();
+
+ manageSection.createLineButtons();
+ manageSection.hideManageLineSection();
+ }
+
+ refreshStationsSelector() {
+ const select = document.getElementById('section-station-selector');
+
+ select.innerHTML = '';
+
+ this._privateSelectUtils.addStationsToSelect(select, this._privateCommonUtils, this._privateDomUtils);
+ }
+
+ removeButtons() {
+ const buttonArray = document.querySelectorAll(`.${this.LINE_BUTTON_CLASS}`);
+ const len = buttonArray.length
+
+ for (let i = 0; i < len; i++) {
+ document.querySelector(`.${this.LINE_BUTTON_CLASS}`).remove();
+ }
+ }
+
+ refreshMapPrint(articleName) {
+ const manageMapPrint = new ManageMapPrint();
+
+ manageMapPrint.emptyArticle(articleName);
+ manageMapPrint.displayMapPrint(articleName, this._privateCommonUtils);
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/src/select_utils.js b/src/select_utils.js
new file mode 100644
index 000000000..7b5b0c89a
--- /dev/null
+++ b/src/select_utils.js
@@ -0,0 +1,65 @@
+import CommonUtils from './common_utils.js';
+import DomUtils from './dom_utils.js';
+
+export default class SelectUtils {
+ setPrivateVariables() {
+ this._privateCommonUtils = new CommonUtils();
+ this._privateDomUtils = new DomUtils();
+ }
+
+ initLists() {
+ this._lineList = this._privateCommonUtils.getLocalStorageLine();
+ this._stationList = this._privateCommonUtils.getLocalStorageStation();
+ }
+
+ setConst() {
+ this.LINE_START_SELECT_ID = 'line-start-station-selector';
+ this.LINE_END_SELECT_ID = 'line-end-station-selector';
+ this.LINE_START_SELECT_TEXT = '์ํ ์ข
์ ';
+ this.LINE_END_SELECT_TEXT = 'ํํ ์ข
์ '
+ }
+
+ createSelectSection(articleName) {
+ this.setPrivateVariables();
+ this.setConst();
+
+ this._privateCommonUtils.insertEmptyline(articleName);
+ this.createSelectStation('start', articleName);
+ this._privateCommonUtils.insertEmptyline(articleName);
+ this.createSelectStation('end', articleName);
+ this._privateCommonUtils.insertEmptyline(articleName);
+ }
+
+ createSelectStation(position, articleName) {
+ const positionUpper = position.toUpperCase();
+
+ this._privateCommonUtils.createTitle('span', this[`LINE_${positionUpper}_SELECT_TEXT`], articleName);
+ this[`_${position}Select`] = this.createSelect(articleName, this[`LINE_${positionUpper}_SELECT_ID`], this._privateCommonUtils, this._privateDomUtils);
+ }
+
+ createSelect(toIdName, idName, commonUtils, domUtils) {
+ const select = document.createElement('SELECT');
+
+ domUtils.setAttribute('id', select, idName);
+ domUtils.appendToIdName(toIdName, select);
+ this.addStationsToSelect(select, commonUtils, domUtils);
+
+ return select;
+ }
+
+ addStationsToSelect(select, commonUtils, domUtils) {
+ const stationList = commonUtils.getLocalStorageStation();
+
+ for (const station in stationList) {
+ this.createSelectOption(select, station, domUtils);
+ }
+ }
+
+ createSelectOption(select, station, domUtils) {
+ const option = document.createElement('option');
+
+ domUtils.addDataAttribute(option, station)
+ option.innerHTML = station;
+ select.add(option);
+ }
+}
\ No newline at end of file
diff --git a/src/string_utils.js b/src/string_utils.js
new file mode 100644
index 000000000..b1365ec67
--- /dev/null
+++ b/src/string_utils.js
@@ -0,0 +1,40 @@
+export default class StringUtils {
+ removeSpace(inputValue) {
+ return inputValue.split(' ').join('');
+ }
+
+ getVarName(tagName) {
+ let tagParts = this.splitTagName(tagName);
+ let varNameParts = this.intoCamelCase(tagParts);
+
+ return varNameParts.join('');
+ }
+
+ splitTagName(tagName) {
+ return tagName.split('-');
+ }
+
+ intoCamelCase(tagParts) {
+ let varNameParts = [];
+
+ tagParts.forEach((part) => {
+ varNameParts.push(this.capitalizeFirstChar(part, tagParts));
+ })
+
+ return varNameParts;
+ }
+
+ capitalizeFirstChar(string, tagParts) {
+ if (tagParts.indexOf(string) >= 1) {
+ return string.charAt(0).toUpperCase() + string.slice(1);
+ }
+
+ return string
+ }
+
+ getArticleName(tagName) {
+ const tagParts = this.splitTagName(tagName);
+
+ return `${tagParts[0]}Article`;
+ }
+}
\ No newline at end of file
diff --git a/src/table_utils.js b/src/table_utils.js
new file mode 100644
index 000000000..4d082da69
--- /dev/null
+++ b/src/table_utils.js
@@ -0,0 +1,397 @@
+import DomUtils from './dom_utils.js';
+import CommonUtils from './common_utils.js';
+import ManageSection from './manage_section.js';
+
+export default class TableUtils {
+ constructor() {
+ this.setPrivateVariable();
+ this.setTableType();
+ this.setConst();
+ }
+
+ setPrivateVariable() {
+ this._privateDomUtils = new DomUtils();
+ this._privateCommonUtils = new CommonUtils();
+ }
+
+ setTableType() {
+ this._tableType = {
+ stationArticle: ['์ญ ์ด๋ฆ', '์ค์ '],
+ lineArticle: ['๋
ธ์ ์ด๋ฆ', '์ํ ์ข
์ ์ญ', 'ํํ ์ข
์ ์ญ', '์ค์ '],
+ sectionManageArea: ['์์', '์ด๋ฆ', '์ค์ '],
+ }
+ }
+
+ setConst() {
+ this.STATION_DELETE_BUTTON_TEXT = '์ญ์ ';
+ this.LINE_DELETE_BUTTON_TEXT = '์ญ์ ';
+ this.SECTION_DELETE_BUTTON_TEXT = '๋
ธ์ ์์ ์ ๊ฑฐ';
+
+ this.ID_ATTRIBUTE = 'id';
+ this.IS_VALID = 1;
+ this.IS_NOT_VALID = 0;
+
+ this.STATION_DELETE_ERROR_MESSAGE = '๋
ธ์ ์ ๋ฑ๋ก๋์ด ์๋ ์ญ์ ์ญ์ ํ ์ ์์ต๋๋ค.';
+ this.SECTION_DELETE_ERROR_MESSAGE = '๋ ์ด์ ์ด ๋
ธ์ ์์ ์ญ์ ์ ๊ฑฐํ ์ ์์ต๋๋ค. ๋
ธ์ ์ ๋ฑ๋ก๋ ์ญ์ด ๋๊ฐ ์ดํ์ผ ๋๋ ์ญ์ ์ ๊ฑฐํ ์ ์์ต๋๋ค.'
+
+ this.STATION_TABLE_NAME = 'stationArticleTable';
+ this.LINE_TABLE_NAME = 'lineArticleTable';
+ this.SECTION_TABLE_NAME = 'sectionManageAreaTable';
+ }
+
+ initTable(toIdName) {
+ const table = document.createElement('table');
+
+ this._privateDomUtils.setAttribute(this.ID_ATTRIBUTE, table, `${toIdName}Table`);
+ this.addTableStyle(table);
+ this.createTitleRow(table, toIdName);
+ this._privateDomUtils.appendToIdName(toIdName, table);
+ this.initTableData(toIdName);
+ }
+
+ initTableData(toIdName) {
+ if (toIdName === 'stationArticle') {
+ this.initStationTableData(toIdName);
+ }
+ else if (toIdName === 'lineArticle') {
+ this.initLineTableData(toIdName);
+ }
+ }
+
+ initStationTableData(articleName) {
+ const stationList = this._privateCommonUtils.getLocalStorageStation();
+
+ for (const station in stationList) {
+ const rowArray = [station, this.STATION_DELETE_BUTTON_TEXT];
+ this.addRow(rowArray, articleName);
+ }
+ }
+
+ initLineTableData(articleName) {
+ const lineList = this._privateCommonUtils.getLocalStorageLine();
+
+ for (const line in lineList) {
+ const lineLen = lineList[line].length;
+ const rowArray = [line, lineList[line][0], lineList[line][lineLen - 1], this.LINE_DELETE_BUTTON_TEXT];
+ this.addRow(rowArray, articleName);
+ }
+ }
+
+ refreshTableData(toIdName, line) {
+ this.emptyTableData(toIdName);
+ if (toIdName === 'lineArticle') {
+ this.initLineTableData(toIdName);
+ }
+ else if (toIdName === 'sectionManageArea') {
+ this.initSectionTable(toIdName, line);
+ }
+ }
+
+ emptyTableData(toIdName) {
+ const tbody = document.querySelector(`#${toIdName}Table tbody`);
+ const rowCount = tbody.childElementCount;
+
+ if (rowCount > 1) {
+ this.deleteRows(tbody.parentNode, rowCount);
+ }
+ }
+
+ deleteRows(table, rowCount) {
+ for (let i = rowCount - 1; i > 0; i--) {
+ table.deleteRow(i);
+ }
+ }
+
+ initSectionTable(toIdName, line) {
+ const lineList = this._privateCommonUtils.getLocalStorageLine();
+ const stationList = this._privateCommonUtils.getLocalStorageStation();
+
+ for (const index in lineList[line]) {
+ const rowArray = [index, lineList[line][index], this.SECTION_DELETE_BUTTON_TEXT, line];
+ this.addRow(rowArray, toIdName);
+ }
+ }
+
+ addTableStyle(table) {
+ table.style.border = '1px solid black';
+ }
+
+ createTitleRow(table, tableType) {
+ const titleRow = table.insertRow(0);
+
+ this._tableType[tableType].forEach((text, i) => {
+ const cell = this.addCell(titleRow, i);
+ this.addTitleCellStyle(cell, text);
+ })
+ }
+
+ addCell(titleRow, i) {
+ return titleRow.insertCell(i);
+ }
+
+ addTitleCellStyle(cell, text) {
+ cell.innerHTML = text;
+ cell.style.border = '1px solid black';
+ cell.style.fontWeight = 'bold';
+ cell.style.textAlign = 'center';
+ }
+
+ addRow(rowArray, tableType) {
+ const table = document.getElementById(`${tableType}Table`);
+ const row = table.insertRow();
+
+ this._privateDomUtils.addDataAttribute(row, rowArray);
+ this.addCellsAndButton(tableType, row, rowArray);
+ }
+
+ addRowAtIndex(rowArray, line, tableType) {
+ const table = document.getElementById('sectionManageAreaTable');
+ const index = rowArray[0];
+ const row = table.insertRow(index);
+
+ this._privateDomUtils.addDataAttribute(row, rowArray);
+ this.addCellsAndButton(tableType, row, rowArray);
+ }
+
+ addCellText(cell, text) {
+ cell.innerHTML = text;
+ }
+
+ addCellBorder(cell) {
+ cell.style.border = '1px solid black';
+ }
+
+ addCellsAndButton(tableType, row, rowArray) {
+ this._tableType[tableType].forEach((v, i) => {
+ const typeUpper = this.getType(tableType).toUpperCase();
+
+ if (i !== 3 || rowArray[i] === this.LINE_DELETE_BUTTON_TEXT) {
+ const cell = row.insertCell(i);
+
+ this.addCellBorder(cell);
+ this.checkButtonOrText(rowArray, i, typeUpper, cell);
+ }
+ })
+ }
+
+ checkButtonOrText(rowArray, i, typeUpper, cell) {
+ if (rowArray[i] === this[`${typeUpper}_DELETE_BUTTON_TEXT`]) {
+ this.addDeleteButton(cell, rowArray, typeUpper);
+ }
+ else {
+ this.addCellText(cell, rowArray[i]);
+ }
+ }
+
+ addDeleteButton(cell, rowArray, typeUpper) {
+ const deleteButton = document.createElement('button');
+ const type = typeUpper.toLowerCase();
+
+ this._privateDomUtils.addDataAttribute(deleteButton, rowArray);
+ this._privateDomUtils.setAttribute('class', deleteButton, `${type}-delete-button`)
+ this._privateDomUtils.setInnerHtml(deleteButton, this[`${typeUpper}_DELETE_BUTTON_TEXT`]);
+ this._privateDomUtils.appendToVarName(cell, deleteButton);
+ this.addEventToDeleteButton(deleteButton, type);
+ }
+
+ getType(tableType) {
+ let type = '';
+
+ for (let i = 0; i < tableType.length; i++) {
+ if (tableType[i] >= 'A' && tableType[i] <= 'Z') {
+ return type
+ }
+ type += tableType[i];
+ }
+
+ return type;
+ }
+
+ addEventToDeleteButton(deleteButton, type) {
+ if (type === 'station') {
+ this.addEventToStationDeleteButton(deleteButton);
+ }
+ else if (type === 'line') {
+ this.addEventToLineDeleteButton(deleteButton);
+ }
+ else if (type === 'section') {
+ this.addEventToSectionDeleteButton(deleteButton);
+ }
+ }
+
+ addEventToStationDeleteButton(button) {
+ button.addEventListener('click', () => {
+ if (this.ifOkay() === this.IS_VALID) {
+ this.checkStationDeleteValidity(button);
+ }
+ });
+ }
+
+ addEventToLineDeleteButton(button) {
+ button.addEventListener('click', () => {
+ if (this.ifOkay() === this.IS_VALID) {
+ this.deleteRowAndData(button);
+ }
+ })
+ }
+
+ addEventToSectionDeleteButton(button) {
+ button.addEventListener('click', () => {
+ if (this.ifOkay() === this.IS_VALID) {
+ this.checkSectionDeleteValidity(button);
+ }
+ })
+ }
+
+ ifOkay() {
+ if (confirm('์ ๋ง๋ก ์ญ์ ํ์๊ฒ ์ต๋๊น?')) {
+ return this.IS_VALID;
+ }
+ else {
+ return this.IS_NOT_VALID;
+ }
+ }
+
+ checkStationDeleteValidity(button) {
+ if (this.checkIfRegisteredToLine(button) === this.IS_VALID) {
+ this.deleteRowAndData(button);
+ }
+ else {
+ this._privateCommonUtils.alertError(this.STATION_DELETE_ERROR_MESSAGE);
+ }
+ }
+
+ checkSectionDeleteValidity(button) {
+ if (this.checkIfContainsOverTwoStations(button) === this.IS_VALID) {
+ this.deleteRowAndData(button);
+ this.refreshSectionTable(button);
+ }
+ else {
+ this._privateCommonUtils.alertError(this.SECTION_DELETE_ERROR_MESSAGE);
+ }
+ }
+
+ checkIfRegisteredToLine(button) {
+ const stationList = this._privateCommonUtils.getLocalStorageStation();
+ const dataset = this.getDataAttribute(button);
+ const station = dataset.split(',')[0];
+
+ if (stationList[station][0]) {
+ return this.IS_NOT_VALID;
+ }
+
+ return this.IS_VALID;
+ }
+
+ checkIfContainsOverTwoStations(button) {
+ const lineList = this._privateCommonUtils.getLocalStorageLine();
+ const dataset = this.getDataAttribute(button);
+ const line = dataset.split(',')[3];
+
+ if (lineList[line].length <= 2) {
+ return this.IS_NOT_VALID;
+ }
+
+ return this.IS_VALID;
+ }
+
+ deleteRowAndData(button) {
+ const dataset = this.getDataAttribute(button);
+ const datasetArray = this.getDataSetArray(button);
+ const row = document.querySelector(`[data-tracking="${dataset}"]`);
+
+ this.updateDeleteToLocalStorage(button, datasetArray);
+ this.deleteTableRow(row);
+ }
+
+ getDataSetArray(button) {
+ const dataset = this.getDataAttribute(button);
+ const datasetArray = dataset.split(',');
+
+ return datasetArray;
+ }
+
+ getDataAttribute(button) {
+ return button.dataset.tracking;
+ }
+
+ refreshSectionTable(button) {
+ const datasetArray = this.getDataSetArray(button);
+ const line = datasetArray[3];
+
+ this.refreshTableData('sectionManageArea', line);
+ }
+
+ updateDeleteToLocalStorage(button, datasetArray) {
+ const stationList = this._privateCommonUtils.getLocalStorageStation();
+ const lineList = this._privateCommonUtils.getLocalStorageLine();
+
+ if (this.checkTableId(button) === this.STATION_TABLE_NAME) {
+ this.updateStationDelete(stationList, datasetArray);
+ }
+ else if (this.checkTableId(button) === this.LINE_TABLE_NAME) {
+ this.updateLineDelete(stationList, lineList, datasetArray);
+ }
+ else if (this.checkTableId(button) === this.SECTION_TABLE_NAME) {
+ this.updateSectionDelete(stationList, lineList, datasetArray);
+ }
+ }
+
+ updateStationDelete(stationList, datasetArray) {
+ const station = datasetArray[0];
+
+ this.removeFromObject(stationList, station);
+ this._privateCommonUtils.saveToLocalStorage('stationList', stationList);
+ }
+
+ updateLineDelete(stationList, lineList, datasetArray) {
+ const line = datasetArray[0];
+
+ this.removeStationFromLine(line, lineList, stationList);
+ this.removeFromObject(lineList, line);
+ this._privateCommonUtils.saveToLocalStorage('stationList', stationList);
+ this._privateCommonUtils.saveToLocalStorage('lineList', lineList);
+ }
+
+ updateSectionDelete(stationList, lineList, datasetArray) {
+ const index = datasetArray[0];
+ const line = datasetArray[3];
+ const station = lineList[line][index];
+ const lineIndex = stationList[station].indexOf(line);
+ const stationIndex = lineList[line].indexOf(station);
+
+ stationList[station].splice(lineIndex, 1);
+ lineList[line].splice(stationIndex, 1);
+
+ this._privateCommonUtils.saveToLocalStorage('lineList', lineList);
+ this._privateCommonUtils.saveToLocalStorage('stationList', stationList);
+ }
+
+ checkTableId(button) {
+ return button.parentNode.parentNode.parentNode.parentNode.id;
+ }
+
+ removeStationFromLine(line, lineList, stationList) {
+ for (const station of lineList[line]) {
+ this.removeFromArray(stationList[station], line);
+ }
+ }
+
+ removeFromObject(object, name) {
+ delete object[name];
+
+ return object;
+ }
+
+ removeFromArray(array, name) {
+ const index = array.indexOf(name);
+
+ array.splice(index, 1);
+
+ return array;
+ }
+
+ deleteTableRow(row) {
+ row.remove();
+ }
+}
\ No newline at end of file