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/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/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..4c38b36 100644 --- a/VVSU/index.html +++ b/VVSU/index.html @@ -1,62 +1,70 @@ - + - Навигатор ВВГУ + ВВГУ.Ориентир - + -
- -

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

-
-

Откуда:

-

Куда:

-

-
+
+
+
+ +
Ориентир
+
Упрощенный навигатор по университету.
+
+
+
+ + + +
+ + + +
+
+ -

 

-

Справка:

-

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

-

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

+ + + + + + -

 

-

+ + + + -
+ + - + diff --git a/VVSU/nullstyle.css b/VVSU/nullstyle.css new file mode 100644 index 0000000..ad6c1f6 --- /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{ + 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..56c103b --- /dev/null +++ b/VVSU/show_route.js @@ -0,0 +1,80 @@ + + +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 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() +{ + if (!state) { + let from_point = fromField.value; + let to_point = toField.value; + + let route = ''; + try { + route = findRoute(from_point, to_point); + } catch (e) { + errorText.innerHTML = e.message; + errorText.hidden = false; + return; + } + + //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; + + errorText.hidden = true; + + button.innerHTML = "Проложить новый маршрут"; + + outputBlock.hidden = false; + + // 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 = "Проложить маршрут"; + + outputBlock.hidden = true; + + 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..80b7d22 --- /dev/null +++ b/VVSU/styles.css @@ -0,0 +1,196 @@ + + +html { + background-color: transparent; +} + +body { + /*background-color: #435757; */ + background-color: transparent; +} + +.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; +} + +.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 { + max-width: 315px; + margin: 0 auto; + padding: 0 0 5px 0; +} + +.header { + margin: 0 auto; + padding: 0 5px 5px; +} + +.header__logo {/*383x815*/ + margin: 0 auto; + padding: 30px 0; + width: 70%; +} + +.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; + user-select: none; + -webkit-user-select: none; +} + +.header__subtitle { + margin: 10px 0 0 0; + font-size: 15px; + text-align: left; + color: white; + user-select: none; + -webkit-user-select: none; +} + +#route-text { + color: white; + font-size: 20px; +} + +#error-text { + color: #ce0000; + font-size: 20px; + text-align: center; +} + +.form { + margin: 0 auto 0px auto; + padding: 0 5px 15px 5px; + width: 100%; +} + +.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 5px auto; + padding: 2px 10px; + + background: #002962; + border: 3px solid rgba(97, 189, 241, 0.77); + border-radius: 25px; + color: rgba(255, 255, 255, 0.93); + cursor: pointer; + display: inline-block; + font-family: "Amazon Ember",sans-serif; + font-size: 18px; + line-height: 1; + position: relative; + text-align: center; + text-decoration: none; + user-select: none; + -webkit-user-select: none; + touch-action: manipulation; + vertical-align: middle; + width: 100%; + min-height: 50px; +} + +.form__button:hover { + border: 2px solid rgba(255, 116, 51, 0.87); + color: rgba(255, 116, 51, 0.87); +} diff --git a/find_route.js b/find_route.js index 198a340..370c730 100644 --- a/find_route.js +++ b/find_route.js @@ -135,24 +135,28 @@ function get_route_text (route) 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 route_strs = [`Маршрут от ${point_from} до ${point_to}`]; + //let route_strs = [`Маршрут от ${point_from} до ${point_to}`]; + + if (point_from === point_to) { + throw new Error('Пункты отправления и назначения совпадают'); + } if (!plan.point_by_id.has(point_from)) { - route_strs.push(`Пункт ${point_from} отсутствует`); - return route_strs; + //route_strs.push(`Пункт ${point_from} отсутствует`); + throw new Error(`Пункт ${point_from} отсутствует`); } if (!plan.point_by_id.has(point_to)) { - route_strs.push(`Пункт ${point_to} отсутствует`); - return route_strs; + //route_strs.push(`Пункт ${point_to} отсутствует`); + throw new Error(`Пункт ${point_to} отсутствует`); } - 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; + 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); }