-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
84 lines (57 loc) · 2.79 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<html></html>
<head>
<title>external</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h2>Ссылки на маршруты:</h2>
<ul id="routesList"></ul>
<script>
const str = "Краснодар|tПрибытие|t45.039867|t38.973346|nКраснодар|tОтправление|t45.040126|t38.974565|nГеленджик|tОтправление|t44.590565|t38.048662|nГеленджик|tПрибытие|t44.592013|t38.049200|nНовороссийск|tОтправление|t44.676488|t37.783364|nНовороссийск|tПрибытие|t44.676331|t37.783724|nРостов-на-Дону|tОтправление|t47.237743|t39.595592|nРостов-на-Дону|tПрибытие|t47.237938|t39.595896|nАнапа|tОтправление|t44.881237|t37.338138|nАнапа|tПрибытие|t44.881237|t37.338138"
const rowPoints = str.split("|n");
var data = [];
rowPoints.forEach((pointStr) => {
const a = pointStr.split("|t");
data.push({ city: a[0], type: a[1], lat: a[2], lon: a[3] });
});
const dictionary = {};
data.forEach(({ city, type, lat, lon }) => {
const key = `${city} ${type}`;
dictionary[key] = { lat, lon };
});
const cities = [
['Анапа'],
['Геленджик'],
['Новороссийск'],
['Ростов-на-Дону'],
];
cities.forEach(city => {
const a1 = 'Краснодар'
const b1 = city
const coordsA1 = dictionary[`${a1} Отправление`];
const coordsB1 = dictionary[`${b1} Прибытие`];
const link1 = `yandextaxi://route?tariffClass=intercity_shuttle&start-lat=${coordsA1.lat}&start-lon=${coordsA1.lon}&end-lat=${coordsB1.lat}&end-lon=${coordsB1.lon}`;
const a2 = city
const b2 = 'Краснодар'
const coordsA2 = dictionary[`${a2} Отправление`];
const coordsB2 = dictionary[`${b2} Прибытие`];
const link2 = `yandextaxi://route?tariffClass=intercity_shuttle&start-lat=${coordsA2.lat}&start-lon=${coordsA2.lon}&end-lat=${coordsB2.lat}&end-lon=${coordsB2.lon}`;
const listItem1 = document.createElement('li');
const anchor1 = document.createElement('a');
anchor1.href = link1;
anchor1.target = '_blank';
anchor1.textContent = `${a1} — ${b1}`;
listItem1.appendChild(anchor1);
routesList.appendChild(listItem1);
const listItem2 = document.createElement('li');
const anchor2 = document.createElement('a');
anchor2.href = link2;
anchor2.target = '_blank';
anchor2.textContent = `${a2} - ${b2}`;
listItem2.appendChild(anchor2);
routesList.appendChild(listItem2);
// print(anchor.text);
});
</script>
</body>
</html>