Skip to content

Commit

Permalink
Добавлена проверка на совпадение пунктов отправления и назначения.
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-karpov0 committed Sep 27, 2023
1 parent 269f1fd commit c91f44c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions VVSU/show_route.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions VVSU/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ body {
}

.container {
width: 310px;
width: 315px;
/*background-color: #141718;*/
background-color: transparent;
margin: 0 auto;
Expand Down Expand Up @@ -75,7 +75,7 @@ body {
.form {
margin: 20px auto 0px auto;
padding: 0 0 15px 0;
width: 300px;
width: 310px;
}

.form form {
Expand Down
6 changes: 5 additions & 1 deletion find_route.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down

0 comments on commit c91f44c

Please sign in to comment.