-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroute.html
120 lines (72 loc) · 2.89 KB
/
route.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>route</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link href="css/ratchet.min.css" rel="stylesheet">
<link href="css/spstyles.css" rel="stylesheet">
<script src="js/ratchet.min.js"></script>
<script src="js/menu-bottom.js"></script>
</head>
<body>
<header class="bar bar-nav">
<a class="icon icon-left-nav pull-left" href="routelist.html" data-ignore="push"></a>
<a class="icon icon-edit pull-right" href="routeedit.html" data-ignore="push"></a>
<h1 class="title">Маршрут</h1>
</header>
<div class="content">
<div id="info" class="content-padded"></div>
<ul id="list" class="table-view"></ul>
</div>
<div id="menu-bottom"></div>
<script type="text/javascript">
let Routekey = "#_route" + localStorage['routeindex'];
let Route = JSON.parse(localStorage[Routekey]);
if (Route.e == true) {
document.getElementById('info').innerHTML = Route.name + '<br>' + Route.date;
document.getElementById('list').innerHTML = "";
var content = "";
for (let i=0; i < Route.list.length; i++) {
content += '<li>' + Route.list[i].name + '<br>' + Route.list[i].postal_address + '<br></li>';
document.getElementById('list').innerHTML = content;
}
}
else {
document.getElementById('info').innerHTML = Route.name + '<br>' + Route.date;
document.getElementById('list').innerHTML = "";
for (let i=0; i < Route.list.length; i++) {
let url = 'https://staging-api.naviaddress.com/api/v1.5/Addresses/' + Route.list[i].naddr;
fetch(url).then((res1)=>
res1.json().then((res2)=>{
Route.list[i].name = res2.result.name;
Route.list[i].postal_address = res2.result.postal_address;
Route.list[i].lat = res2.result.point.lat;
Route.list[i].lng = res2.result.point.lng;
document.getElementById('list').innerHTML += '<li>' +
Route.list[i].name + '<br>' + Route.list[i].postal_address + '<br></li>';
localStorage[Routekey] = JSON.stringify(Route);
})
);
}
}
//Определение индекса позиции в списке
document.getElementById("list").onclick = function(event) {
if (!event) {
event = window.event;
event.target = window.srcElement;
};
var list = this.getElementsByTagName("li");
for (let i=0; i < list.length; i++) {
if (list[i]==event.target) {
localStorage['itemindex'] = i.toString();
document.location.href = "place.html";
return;
};
}
};
</script>
</body>
</html>