From 8f47cea0732c8ab2886a3155860f507f057cb689 Mon Sep 17 00:00:00 2001 From: dev-karpov0 Date: Wed, 27 Sep 2023 21:48:50 +1000 Subject: [PATCH 1/6] Improve frontend --- .gitignore | 1 + VVSU/images/logo.svg | 30 +++++++++ VVSU/index.html | 97 ++++++++++++++------------- VVSU/nullstyle.css | 38 +++++++++++ VVSU/show_route.js | 70 ++++++++++++++++++++ VVSU/styles.css | 151 +++++++++++++++++++++++++++++++++++++++++++ find_route.js | 22 ++++--- 7 files changed, 351 insertions(+), 58 deletions(-) create mode 100644 .gitignore create mode 100644 VVSU/images/logo.svg create mode 100644 VVSU/nullstyle.css create mode 100644 VVSU/show_route.js create mode 100644 VVSU/styles.css diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..62c8935 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ \ No newline at end of file diff --git a/VVSU/images/logo.svg b/VVSU/images/logo.svg new file mode 100644 index 0000000..cfa9ccb --- /dev/null +++ b/VVSU/images/logo.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/VVSU/index.html b/VVSU/index.html index 841eded..90263e5 100644 --- a/VVSU/index.html +++ b/VVSU/index.html @@ -1,62 +1,61 @@ - + - Навигатор ВВГУ + ВВГУ.Ориентир - + + + + + + -
- -

Навигатор ВВГУ

-
-

Откуда:

-

Куда:

-

-
- -

 

-

Справка:

-

Введите номера аудиторий

-

1 - главный вход, 2 - зимний сад

- -

 

-

- -
- - +
+ +
+
+
+ +
Ориентир
+
Упрощенный навигатор по университету.
+
+
+
+ + + +
+ + +
+
+ + + + + + + + + + + + + + + + + + + diff --git a/VVSU/nullstyle.css b/VVSU/nullstyle.css new file mode 100644 index 0000000..948c9d6 --- /dev/null +++ b/VVSU/nullstyle.css @@ -0,0 +1,38 @@ +/*Обнуление*/ +*{ + padding: 0; + margin: 0; + border: 0; +} +*,*:before,*:after{ + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; +} +:focus,:active{outline: none;} +a:focus,a:active{outline: none;} + +nav,footer,header,aside{display: block;} + +html,body{ + min-height: 100%; + width: 100%; + font-size: 100%; + line-height: 1; + font-size: 14px; + -ms-text-size-adjust: 100%; + -moz-text-size-adjust: 100%; + -webkit-text-size-adjust: 100%; +} +input,button,textarea{font-family:inherit;} + +input::-ms-clear{display: none;} +button{cursor: pointer;} +button::-moz-focus-inner {padding:0;border:0;} +a, a:visited{text-decoration: none;} +a:hover{text-decoration: none;} +ul li{list-style: none;} +img{vertical-align: top;} + +h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight: 400;} +/*--------------------*/ \ No newline at end of file diff --git a/VVSU/show_route.js b/VVSU/show_route.js new file mode 100644 index 0000000..e1d2f20 --- /dev/null +++ b/VVSU/show_route.js @@ -0,0 +1,70 @@ + + +let toField = document.getElementById("to"); +let fromField = document.getElementById("from"); +let button = document.getElementById("button"); +let routeText = document.getElementById("route-text"); +let errorText = document.getElementById("error-text"); +let state = false; + +function showRoute() +{ + if (!state) { + let from_point = fromField.value; + let to_point = toField.value; + let route = findRoute(from_point, to_point); + if (route.status !== RouteFinderStatus.SUCCESS) + { + switch (route.status) + { + case RouteFinderStatus.INVALID_SOURCE: + errorText.innerHTML = `Пункт ${from_point} отсутствует`; + break; + + case RouteFinderStatus.INVALID_DESTINATION: + errorText.innerHTML = `Пункт ${to_point} отсутствует`; + break; + } + errorText.hidden = false; + return; + } + let route_str = route.route_str_list.join("
"); + routeText.hidden = false; + routeText.innerHTML = route_str; + + toField.hidden = true; + fromField.hidden = true; + + errorText.hidden = true; + + button.innerHTML = "Проложить новый маршрут"; + + // toField.classList.add("collapsed"); + // fromField.classList.add("collapsed"); + + state = true; + } else { + toField.hidden = false; + toField.value = ""; + + fromField.hidden = false; + fromField.value = ""; + + routeText.hidden = true; + + button.innerHTML = "Проложить маршрут"; + + state = false; + } +} + +/*При нажатии ENTER в текстовом поле*/ +const clickEvent = function(event) { + if (event.key === "Enter") { + event.preventDefault(); + showRoute(); + } +} + +toField.addEventListener("keypress", clickEvent); +fromField.addEventListener("keypress", clickEvent); \ No newline at end of file diff --git a/VVSU/styles.css b/VVSU/styles.css new file mode 100644 index 0000000..d495abd --- /dev/null +++ b/VVSU/styles.css @@ -0,0 +1,151 @@ + + +html { + background-color: black; +} + +body { + /*background-color: #435757;*/ +} + +.background { + background: rgb(35,38,103); + background: -moz-linear-gradient(137deg, rgba(35,38,103,1) 0%, rgba(20,129,215,1) 100%); + background: -webkit-linear-gradient(137deg, rgba(35,38,103,1) 0%, rgba(20,129,215,1) 100%); + background: linear-gradient(137deg, rgba(35,38,103,1) 0%, rgba(20,129,215,1) 100%); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#232667",endColorstr="#1481d7",GradientType=1); + position: fixed; + z-index: -1; + width: 100vw; + height: 100vh; +} + +.container { + width: 400px; + /*background-color: #141718;*/ + background-color: transparent; + margin: 0 auto; +} + +.header { + transition: 0.3s all; + width: 300px; + margin: 0 auto; +} + +.header__logo {/*383x815*/ + margin: 0 auto; + padding: 30px 0; + width: 200px; +} + +.header__logo img { + object-fit: contain; + width: 100%; + /*height: 100%;!*Proportional???*!*/ +} + +.header__title { + margin: 20px 0 0 0; + font-size: 30px; + text-align: left; + color: white; +} + +.header__subtitle { + margin: 10px 0 0 0; + font-size: 15px; + text-align: left; + color: white; +} + +#route-text { + color: white; + font-size: 20px; +} + +#error-text { + color: #d01313; + font-size: 20px; + text-align: center; +} + +.form { + margin: 20px auto 0px auto; + padding: 0 0 15px 0; + width: 300px; +} + +.form form { + text-align: center; +} + +/*Input*/ +.form__input { + margin: 10px 0 0 0; + width: 100%; + padding: 10px; + font-size: 18px; + outline:none; + background: #002962; + border-radius: 10px; + border: 2px solid rgba(97, 189, 241, 0.77); + color: rgb(255, 255, 255); +} + +.form__input:hover { + border: 2px solid rgba(255, 116, 51, 0.87); +} + +.form__input:focus { + border: 2px solid rgba(255, 116, 51, 0.87); +} + +.form__input::placeholder { + color: #d9d4d4; + opacity: 1; +} + +.form__input::-ms-input-placeholder { /* Edge 12 -18 */ + color: #d9d4d4; +} + +/*Button*/ +.form__button { + margin: 15px auto 15px auto; + + background: #002962; + border: 3px solid rgba(97, 189, 241, 0.77); + border-radius: 25px; + /*box-shadow: rgba(97, 189, 241, 0.77) 0 0px 10px 0;*/ + box-sizing: border-box; + color: rgba(255, 255, 255, 0.93); + cursor: pointer; + display: inline-block; + font-family: "Amazon Ember",sans-serif; + font-size: 20px; + line-height: 29px; + padding: 0 10px 0 11px; + position: relative; + text-align: center; + text-decoration: none; + user-select: none; + -webkit-user-select: none; + touch-action: manipulation; + vertical-align: middle; + width: 100%; + height: 50px; + transition: 0.5s all; +} + +.form__button:hover { + border: 2px solid rgba(255, 116, 51, 0.87); + color: rgba(255, 116, 51, 0.87); +} + +/*.form__button:focus {*/ +/* border-color: #008296;*/ +/* box-shadow: rgba(213, 217, 217, .5) 0 2px 5px 0;*/ +/* outline: 0;*/ +/*}*/ + diff --git a/find_route.js b/find_route.js index 198a340..e3aba74 100644 --- a/find_route.js +++ b/find_route.js @@ -132,6 +132,8 @@ function get_route_text (route) return route_text; } +const RouteFinderStatus = {SUCCESS:0, INVALID_SOURCE: 1, INVALID_DESTINATION: 2}; + function findRoute (point_from, point_to) { if (!point_from || !point_to) @@ -139,20 +141,22 @@ function findRoute (point_from, point_to) point_from = point_from.trim(); point_to = point_to.trim(); + let status = RouteFinderStatus.SUCCESS; let route_strs = [`Маршрут от ${point_from} до ${point_to}`]; if (!plan.point_by_id.has(point_from)) { - route_strs.push(`Пункт ${point_from} отсутствует`); - return route_strs; + //route_strs.push(`Пункт ${point_from} отсутствует`); + status = RouteFinderStatus.INVALID_SOURCE; } if (!plan.point_by_id.has(point_to)) { - route_strs.push(`Пункт ${point_to} отсутствует`); - return route_strs; + //route_strs.push(`Пункт ${point_to} отсутствует`); + status = RouteFinderStatus.INVALID_DESTINATION; } - route = get_route(plan.point_by_id.get(point_from), plan.point_by_id.get(point_to)); - route_text = get_route_text(route); - route_strs.push.apply(route_strs, route_text); // добавить route_text к route_strs - - return route_strs; + if (status === RouteFinderStatus.SUCCESS) { + route = get_route(plan.point_by_id.get(point_from), plan.point_by_id.get(point_to)); + route_text = get_route_text(route); + route_strs.push.apply(route_strs, route_text); // добавить route_text к route_strs + } + return {status: status, route_str_list: route_strs}; } \ No newline at end of file From 727092a3467d5307e4aeb85d4ec471a5c20467f5 Mon Sep 17 00:00:00 2001 From: dev-karpov0 Date: Wed, 27 Sep 2023 21:56:43 +1000 Subject: [PATCH 2/6] Fix body color --- VVSU/styles.css | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/VVSU/styles.css b/VVSU/styles.css index d495abd..11a8086 100644 --- a/VVSU/styles.css +++ b/VVSU/styles.css @@ -1,11 +1,12 @@ html { - background-color: black; + background-color: transparent; } body { - /*background-color: #435757;*/ + /*background-color: #435757; */ + background-color: transparent; } .background { From 8854c921526a4510ea4738495a8a2cc542646dbb Mon Sep 17 00:00:00 2001 From: dev-karpov0 Date: Wed, 27 Sep 2023 22:13:04 +1000 Subject: [PATCH 3/6] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BE=D1=82=D1=81=D1=83=D1=82=D1=81=D1=82=D0=B2=D1=83?= =?UTF-8?q?=D1=8E=D1=89=D0=B8=D0=B9=20=D0=B7=D0=B0=D0=BA=D1=80=D1=8B=D0=B2?= =?UTF-8?q?=D0=B0=D1=8E=D1=89=D0=B8=D0=B9=20=D1=82=D0=B5=D0=B3=20?= =?UTF-8?q?=20=D0=B2=20Plan=5FVVSU.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VVSU/Plan_VVSU.js | 51 ++++++++++++++++++++++++----------------------- VVSU/styles.css | 3 ++- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/VVSU/Plan_VVSU.js b/VVSU/Plan_VVSU.js index 4788b60..85300cd 100644 --- a/VVSU/Plan_VVSU.js +++ b/VVSU/Plan_VVSU.js @@ -544,31 +544,32 @@ let planXML = ` - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/VVSU/styles.css b/VVSU/styles.css index 11a8086..b6da54f 100644 --- a/VVSU/styles.css +++ b/VVSU/styles.css @@ -18,7 +18,7 @@ body { position: fixed; z-index: -1; width: 100vw; - height: 100vh; + height: 102vh; } .container { @@ -26,6 +26,7 @@ body { /*background-color: #141718;*/ background-color: transparent; margin: 0 auto; + padding: 0 0 5px 0; } .header { From 269f1fda65c807b8e1437f2b389f3937066f0e01 Mon Sep 17 00:00:00 2001 From: dev-karpov0 Date: Wed, 27 Sep 2023 22:31:05 +1000 Subject: [PATCH 4/6] =?UTF-8?q?=D0=A3=D0=BC=D0=B5=D0=BD=D1=8C=D1=88=D0=B5?= =?UTF-8?q?=D0=BD=20=D1=80=D0=B0=D0=B7=D0=BC=D0=B5=D1=80=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BD=D1=82=D0=B5=D0=B9=D0=BD=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VVSU/styles.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VVSU/styles.css b/VVSU/styles.css index b6da54f..deec5fd 100644 --- a/VVSU/styles.css +++ b/VVSU/styles.css @@ -22,7 +22,7 @@ body { } .container { - width: 400px; + width: 310px; /*background-color: #141718;*/ background-color: transparent; margin: 0 auto; From c91f44c2da1f7455dc3ba30767346e503cffc070 Mon Sep 17 00:00:00 2001 From: dev-karpov0 Date: Wed, 27 Sep 2023 22:36:47 +1000 Subject: [PATCH 5/6] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=BD=D0=B0=20=D1=81=D0=BE=D0=B2=D0=BF=D0=B0=D0=B4=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BF=D1=83=D0=BD=D0=BA=D1=82=D0=BE=D0=B2?= =?UTF-8?q?=20=D0=BE=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B8=20=D0=BD=D0=B0=D0=B7=D0=BD=D0=B0=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VVSU/show_route.js | 4 ++++ VVSU/styles.css | 4 ++-- find_route.js | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/VVSU/show_route.js b/VVSU/show_route.js index e1d2f20..f1268da 100644 --- a/VVSU/show_route.js +++ b/VVSU/show_route.js @@ -24,6 +24,10 @@ function showRoute() case RouteFinderStatus.INVALID_DESTINATION: errorText.innerHTML = `Пункт ${to_point} отсутствует`; break; + + case RouteFinderStatus.DEST_AND_SRC_EQUAL: + errorText.innerHTML = "Пункты отправления и назначения совпадают"; + break; } errorText.hidden = false; return; diff --git a/VVSU/styles.css b/VVSU/styles.css index deec5fd..2283854 100644 --- a/VVSU/styles.css +++ b/VVSU/styles.css @@ -22,7 +22,7 @@ body { } .container { - width: 310px; + width: 315px; /*background-color: #141718;*/ background-color: transparent; margin: 0 auto; @@ -75,7 +75,7 @@ body { .form { margin: 20px auto 0px auto; padding: 0 0 15px 0; - width: 300px; + width: 310px; } .form form { diff --git a/find_route.js b/find_route.js index e3aba74..1973edf 100644 --- a/find_route.js +++ b/find_route.js @@ -132,7 +132,7 @@ function get_route_text (route) return route_text; } -const RouteFinderStatus = {SUCCESS:0, INVALID_SOURCE: 1, INVALID_DESTINATION: 2}; +const RouteFinderStatus = {SUCCESS:0, INVALID_SOURCE: 1, INVALID_DESTINATION: 2, DEST_AND_SRC_EQUAL: 3}; function findRoute (point_from, point_to) { @@ -144,6 +144,10 @@ function findRoute (point_from, point_to) let status = RouteFinderStatus.SUCCESS; let route_strs = [`Маршрут от ${point_from} до ${point_to}`]; + if (point_from === point_to) { + status = RouteFinderStatus.DEST_AND_SRC_EQUAL + } + if (!plan.point_by_id.has(point_from)) { //route_strs.push(`Пункт ${point_from} отсутствует`); status = RouteFinderStatus.INVALID_SOURCE; From 66bee9d4f107eff80295391ab44e99258cdc5ca3 Mon Sep 17 00:00:00 2001 From: dev-karpov0 Date: Sun, 8 Oct 2023 10:47:39 +1000 Subject: [PATCH 6/6] some changes --- VVSU/index.html | 19 +++++++--- VVSU/nullstyle.css | 2 +- VVSU/show_route.js | 50 +++++++++++++----------- VVSU/styles.css | 95 +++++++++++++++++++++++++++++++++------------- find_route.js | 24 +++++------- process_plan.js | 2 + 6 files changed, 124 insertions(+), 68 deletions(-) diff --git a/VVSU/index.html b/VVSU/index.html index 90263e5..4c38b36 100644 --- a/VVSU/index.html +++ b/VVSU/index.html @@ -17,9 +17,7 @@ -
- -
+
- diff --git a/VVSU/nullstyle.css b/VVSU/nullstyle.css index 948c9d6..ad6c1f6 100644 --- a/VVSU/nullstyle.css +++ b/VVSU/nullstyle.css @@ -15,7 +15,7 @@ a:focus,a:active{outline: none;} nav,footer,header,aside{display: block;} html,body{ - min-height: 100%; + height: 100%; width: 100%; font-size: 100%; line-height: 1; diff --git a/VVSU/show_route.js b/VVSU/show_route.js index f1268da..56c103b 100644 --- a/VVSU/show_route.js +++ b/VVSU/show_route.js @@ -3,8 +3,12 @@ let toField = document.getElementById("to"); let fromField = document.getElementById("from"); let button = document.getElementById("button"); -let routeText = document.getElementById("route-text"); +//let routeText = document.getElementById("route-text"); let errorText = document.getElementById("error-text"); +let outputContainer = document.getElementById("output-container"); +let outputBlock = document.getElementById("output"); +let outFrom = document.getElementById("out-from"); +let outTo = document.getElementById("out-to"); let state = false; function showRoute() @@ -12,29 +16,27 @@ function showRoute() if (!state) { let from_point = fromField.value; let to_point = toField.value; - let route = findRoute(from_point, to_point); - if (route.status !== RouteFinderStatus.SUCCESS) - { - switch (route.status) - { - case RouteFinderStatus.INVALID_SOURCE: - errorText.innerHTML = `Пункт ${from_point} отсутствует`; - break; - - case RouteFinderStatus.INVALID_DESTINATION: - errorText.innerHTML = `Пункт ${to_point} отсутствует`; - break; - - case RouteFinderStatus.DEST_AND_SRC_EQUAL: - errorText.innerHTML = "Пункты отправления и назначения совпадают"; - break; - } + + let route = ''; + try { + route = findRoute(from_point, to_point); + } catch (e) { + errorText.innerHTML = e.message; errorText.hidden = false; return; } - let route_str = route.route_str_list.join("
"); - routeText.hidden = false; - routeText.innerHTML = route_str; + + //let route_str = route.join("
"); + let route_str = route.map((val, idx) => { + return `
${val}
`; + }).join(' '); + + outputContainer.innerHTML = route_str; + //routeText.hidden = false; + //routeText.innerHTML = route_str; + + outFrom.innerHTML = from_point; + outTo.innerHTML = to_point; toField.hidden = true; fromField.hidden = true; @@ -43,6 +45,8 @@ function showRoute() button.innerHTML = "Проложить новый маршрут"; + outputBlock.hidden = false; + // toField.classList.add("collapsed"); // fromField.classList.add("collapsed"); @@ -54,10 +58,12 @@ function showRoute() fromField.hidden = false; fromField.value = ""; - routeText.hidden = true; + //routeText.hidden = true; button.innerHTML = "Проложить маршрут"; + outputBlock.hidden = true; + state = false; } } diff --git a/VVSU/styles.css b/VVSU/styles.css index 2283854..80b7d22 100644 --- a/VVSU/styles.css +++ b/VVSU/styles.css @@ -18,27 +18,76 @@ body { position: fixed; z-index: -1; width: 100vw; - height: 102vh; + height: 100vh; +} + +.output { + margin: 5px 0 0 0; +} + +.output__header { + margin: 0 0 5px 0; +} + +.output__line { + margin: 0 25px 0 25px; + border-top: 2px rgba(97, 189, 241, 0.77) solid; + height: 0; +} + +.output__title { + margin: 12px 0 4px 0; + font-size: 20px; + text-align: center; + color: white; +} + +.output__item-container { + display: flex; + justify-content: center; + align-items: center; + color: white; +} + +.output__item { + padding: 3px 7px; + min-height: 25px; + min-width: 40px; + border-radius: 5px; + border: 2px rgba(97, 189, 241, 0.77) solid; + color: white; + text-align: center; + display: flex; + justify-content: center; + align-items: center; + line-height: 1; + background: #002962; +} + +.output__step { + padding: 5px 5px; + margin: 5px 0; + border: 2px rgba(97, 189, 241, 0.77) solid; + border-radius: 5px; + font-size: 20px; + color: white; } .container { - width: 315px; - /*background-color: #141718;*/ - background-color: transparent; + max-width: 315px; margin: 0 auto; padding: 0 0 5px 0; } .header { - transition: 0.3s all; - width: 300px; margin: 0 auto; + padding: 0 5px 5px; } .header__logo {/*383x815*/ margin: 0 auto; padding: 30px 0; - width: 200px; + width: 70%; } .header__logo img { @@ -52,6 +101,8 @@ body { font-size: 30px; text-align: left; color: white; + user-select: none; + -webkit-user-select: none; } .header__subtitle { @@ -59,6 +110,8 @@ body { font-size: 15px; text-align: left; color: white; + user-select: none; + -webkit-user-select: none; } #route-text { @@ -67,15 +120,15 @@ body { } #error-text { - color: #d01313; + color: #ce0000; font-size: 20px; text-align: center; } .form { - margin: 20px auto 0px auto; - padding: 0 0 15px 0; - width: 310px; + margin: 0 auto 0px auto; + padding: 0 5px 15px 5px; + width: 100%; } .form form { @@ -114,20 +167,18 @@ body { /*Button*/ .form__button { - margin: 15px auto 15px auto; + margin: 15px auto 5px auto; + padding: 2px 10px; background: #002962; border: 3px solid rgba(97, 189, 241, 0.77); border-radius: 25px; - /*box-shadow: rgba(97, 189, 241, 0.77) 0 0px 10px 0;*/ - box-sizing: border-box; color: rgba(255, 255, 255, 0.93); cursor: pointer; display: inline-block; font-family: "Amazon Ember",sans-serif; - font-size: 20px; - line-height: 29px; - padding: 0 10px 0 11px; + font-size: 18px; + line-height: 1; position: relative; text-align: center; text-decoration: none; @@ -136,18 +187,10 @@ body { touch-action: manipulation; vertical-align: middle; width: 100%; - height: 50px; - transition: 0.5s all; + min-height: 50px; } .form__button:hover { border: 2px solid rgba(255, 116, 51, 0.87); color: rgba(255, 116, 51, 0.87); } - -/*.form__button:focus {*/ -/* border-color: #008296;*/ -/* box-shadow: rgba(213, 217, 217, .5) 0 2px 5px 0;*/ -/* outline: 0;*/ -/*}*/ - diff --git a/find_route.js b/find_route.js index 1973edf..370c730 100644 --- a/find_route.js +++ b/find_route.js @@ -132,35 +132,31 @@ function get_route_text (route) return route_text; } -const RouteFinderStatus = {SUCCESS:0, INVALID_SOURCE: 1, INVALID_DESTINATION: 2, DEST_AND_SRC_EQUAL: 3}; - function findRoute (point_from, point_to) { if (!point_from || !point_to) - return []; + throw new Error('Пункты не могут быть пустыми'); + point_from = point_from.trim(); point_to = point_to.trim(); - let status = RouteFinderStatus.SUCCESS; - let route_strs = [`Маршрут от ${point_from} до ${point_to}`]; + //let route_strs = [`Маршрут от ${point_from} до ${point_to}`]; if (point_from === point_to) { - status = RouteFinderStatus.DEST_AND_SRC_EQUAL + throw new Error('Пункты отправления и назначения совпадают'); } if (!plan.point_by_id.has(point_from)) { //route_strs.push(`Пункт ${point_from} отсутствует`); - status = RouteFinderStatus.INVALID_SOURCE; + throw new Error(`Пункт ${point_from} отсутствует`); } if (!plan.point_by_id.has(point_to)) { //route_strs.push(`Пункт ${point_to} отсутствует`); - status = RouteFinderStatus.INVALID_DESTINATION; + throw new Error(`Пункт ${point_to} отсутствует`); } - if (status === RouteFinderStatus.SUCCESS) { - route = get_route(plan.point_by_id.get(point_from), plan.point_by_id.get(point_to)); - route_text = get_route_text(route); - route_strs.push.apply(route_strs, route_text); // добавить route_text к route_strs - } - return {status: status, route_str_list: route_strs}; + let route = get_route(plan.point_by_id.get(point_from), plan.point_by_id.get(point_to)); + let route_text = get_route_text(route); + //route_strs.push.apply(route_strs, route_text); // добавить route_text к route_strs + return route_text; } \ No newline at end of file diff --git a/process_plan.js b/process_plan.js index 8f233d8..6463f04 100644 --- a/process_plan.js +++ b/process_plan.js @@ -7,8 +7,10 @@ function process_plan () continue; let point_index = plan.paths[path_index].path_points[i]; let prev_point_index = plan.paths[path_index].path_points[i - 1]; + edge1 = { adj_point: point_index, path: path_index, reversed_path: false }; plan.points[prev_point_index].edges.push(edge1); + edge2 = { adj_point: prev_point_index, path: path_index, reversed_path: true }; plan.points[point_index].edges.push(edge2); }