Skip to content

Commit

Permalink
some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-karpov0 committed Oct 8, 2023
1 parent c91f44c commit 66bee9d
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 68 deletions.
19 changes: 14 additions & 5 deletions VVSU/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
</head>

<body>
<div class="background">

</div>
<div class="background"> </div>
<div class="container">
<div class="header">
<div class="header__logo">
Expand All @@ -34,11 +32,22 @@
<input type="text" id="to" placeholder="Куда" class="form__input"/>
<button type="button" id="button" onclick="showRoute();" class="form__button">Проложить маршрут</button>
</form>
<div id="route-text" hidden>123</div>
<div id="output" class="output" hidden>
<div class="output__header">
<div class="output__line"></div>
<div class="output__title">Маршрут</div>
<div class="output__item-container">
<div id="out-from" class="output__item">ауд. 4407</div>
->
<div id="out-to" class="output__item">ауд. 4305</div>
</div>
</div>
<div id="output-container"></div>
</div>
<!-- <div id="route-text" hidden>123</div>-->
<div id="error-text" hidden></div>
</div>
</div>

<!-- <center>-->

<!-- <h3>ВВГУ.Ориентир</h3>-->
Expand Down
2 changes: 1 addition & 1 deletion VVSU/nullstyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
50 changes: 28 additions & 22 deletions VVSU/show_route.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,40 @@
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()
{
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("<br/>");
routeText.hidden = false;
routeText.innerHTML = route_str;

//let route_str = route.join("<br/>");
let route_str = route.map((val, idx) => {
return `<div class="output__step">${val}</div>`;
}).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;
Expand All @@ -43,6 +45,8 @@ function showRoute()

button.innerHTML = "Проложить новый маршрут";

outputBlock.hidden = false;

// toField.classList.add("collapsed");
// fromField.classList.add("collapsed");

Expand All @@ -54,10 +58,12 @@ function showRoute()
fromField.hidden = false;
fromField.value = "";

routeText.hidden = true;
//routeText.hidden = true;

button.innerHTML = "Проложить маршрут";

outputBlock.hidden = true;

state = false;
}
}
Expand Down
95 changes: 69 additions & 26 deletions VVSU/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -52,13 +101,17 @@ body {
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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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;
Expand All @@ -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;*/
/*}*/

24 changes: 10 additions & 14 deletions find_route.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 2 additions & 0 deletions process_plan.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 66bee9d

Please sign in to comment.