-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
302 lines (258 loc) · 13.8 KB
/
index.html
File metadata and controls
302 lines (258 loc) · 13.8 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
<!DOCTYPE html>
<html>
<head>
<title>Julekartan</title>
<style type="text/css">
/* Set a size for our map container, the Google Map will take up 100% of this container */
#map {
width: 80%;
height: 500px;
margin-left: auto;
margin-right: auto;
}
body {
font-family: 'mountains_of_christmasregular', Arial, sans-serif;
background-color: #f4deaf;
}
</style>
<link rel="stylesheet" href="fonts/stylesheet.css" type="text/css" charset="utf-8" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js" ></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-dateFormat/1.0/jquery.dateFormat.min.js" ></script>
<!--
You need to include this script tag on any page that has a Google Map.
The following script tag will work when opening this example locally on your computer.
But if you use this on a localhost server or a live website you will need to include an API key.
Sign up for one here (it's free for small usage):
https://developers.google.com/maps/documentation/javascript/tutorial#api_key
After you sign up, use the following script tag with YOUR_GOOGLE_API_KEY replaced with your actual key. -->
<script type="text/javascript">
function startTimer(duration, display) {
var timer = duration, days, hours, minutes, seconds;
setInterval(function () {
days = parseInt(timer / 86400, 10);
hours = parseInt((timer - days * 86400) / 3600, 10);
minutes = parseInt((timer - days * 86400 - hours * 3600)/ 60, 10);
seconds = parseInt(timer % 60, 10);
days = days < 10 ? "0" + days : days;
hours = hours < 10 ? "0" + hours : hours;
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
var text = " kvar till nästa!";
if (days > 0) {
text = days + " dagar, " + hours + ":" + minutes + ":" + seconds + text;
}
else if (hours > 0) {
text = hours + ":" + minutes + ":" + seconds + text;
}
else {
text = minutes + ":" + seconds + text;
}
display.innerHTML = text;
if (--timer < 0) {
location.reload();
}
}, 1000);
}
var urlParams;
(window.onpopstate = function () {
var match,
pl = /\+/g, // Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g,
decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
query = window.location.search.substring(1);
urlParams = {};
while (match = search.exec(query))
urlParams[decode(match[1])] = decode(match[2]);
})();
function initMap() {
// Basic options for a simple Google Map
// For more options see: https://developers.google.com/maps/documentation/javascript/reference#MapOptions
var mapOptions = {
// How zoomed in you want the map to start at (always required)
zoom: 15,
// The latitude and longitude to center the map (always required)
center: new google.maps.LatLng(59.3346, 18.056),
// How you would like to style the map.
// This is where you would paste any style found on Snazzy Maps.
styles: [ { "featureType":"landscape", "stylers":[ { "hue":"#FFAD00" }, { "saturation":50.2 }, { "lightness":-34.8 }, { "gamma":1 } ] }, { "featureType":"road.highway", "stylers":[ { "hue":"#FFAD00" }, { "saturation":-19.8 }, { "lightness":-1.8 }, { "gamma":1 } ] }, { "featureType":"road.arterial", "stylers":[ { "hue":"#FFAD00" }, { "saturation":72.4 }, { "lightness":-32.6 }, { "gamma":1 } ] }, { "featureType":"road.local", "stylers":[ { "hue":"#FFAD00" }, { "saturation":74.4 }, { "lightness":-18 }, { "gamma":1 } ] }, { "featureType":"water", "stylers":[ { "hue":"#00FFA6" }, { "saturation":-63.2 }, { "lightness":38 }, { "gamma":1 } ] }, { "featureType":"poi", "stylers":[ { "visibility":"off" }, ] }]
};
// Get the HTML DOM element that will contain your map
// We are using a div with id="map" seen below in the <body>
var mapElement = document.getElementById('map');
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer({ suppressMarkers: true,
polylineOptions: { strokeColor: '#ff0000', strokeOpacity: 0.3, strokeWeight: 4 }
});
// Create the Google Map using our element and options defined above
var map = new google.maps.Map(mapElement, mapOptions);
directionsDisplay.setMap(map);
var centralen = new google.maps.LatLng(59.3305, 18.059);
var paus1 = new google.maps.LatLng(59.3331, 18.0573);
var pos1 = new google.maps.LatLng(59.3346, 18.0555);
var paus2 = new google.maps.LatLng(59.3342, 18.0586);
var pos2 = new google.maps.LatLng(59.3350, 18.0568);
var paus3 = new google.maps.LatLng(59.3368, 18.0582);
var pos3 = new google.maps.LatLng(59.3372, 18.0609);
var paus4 = new google.maps.LatLng(59.3388, 18.0615);
var lineSymbol = {
path: 'M 0,-1 0,1',
strokeOpacity: 1,
scale: 4
};
var all_path = [
{
start_pos: centralen,
end_pos: paus1,
starttime: Date.parse("2016-01-16T08:50:00Z"),
endtime: Date.parse("2016-01-16T09:00:00Z")
},
{
position: paus1,
starttime: Date.parse("2016-01-16T09:00:00Z"),
endtime: Date.parse("2016-01-16T09:15:00Z")
},
{
start_pos: paus1,
end_pos: pos1,
starttime: Date.parse("2016-01-16T09:15:00Z"),
endtime: Date.parse("2016-01-16T09:20:00Z")
},
{
position: pos1,
starttime: Date.parse("2016-01-16T09:20:00Z"),
endtime: Date.parse("2016-01-16T10:15:00Z")
},
{
start_pos: pos1,
end_pos: paus2,
starttime: Date.parse("2016-01-16T10:15:00Z"),
endtime: Date.parse("2016-01-16T10:40:00Z")
},
{
position: paus2,
starttime: Date.parse("2016-01-16T10:40:00Z"),
endtime: Date.parse("2016-01-16T11:40:00Z")
},
{
start_pos: paus2,
end_pos: pos2,
starttime: Date.parse("2016-01-16T11:40:00Z"),
endtime: Date.parse("2016-01-16T11:50:00Z")
},
{
position: pos2,
starttime: Date.parse("2016-01-16T11:50:00Z"),
endtime: Date.parse("2016-01-16T12:45:00Z")
},
{
start_pos: pos2,
end_pos: paus3,
starttime: Date.parse("2016-01-16T12:45:00Z"),
endtime: Date.parse("2016-01-16T13:10:00Z")
},
{
position: paus3,
starttime: Date.parse("2016-01-16T13:10:00Z"),
endtime: Date.parse("2016-01-16T14:00:00Z")
},
{
start_pos: paus3,
end_pos: pos3,
starttime: Date.parse("2016-01-16T14:00:00Z"),
endtime: Date.parse("2016-01-16T14:10:00Z")
},
{
position: pos3,
starttime: Date.parse("2016-01-16T14:10:00Z"),
endtime: Date.parse("2016-01-16T15:00:00Z")
},
{
start_pos: pos3,
end_pos: paus4,
starttime: Date.parse("2016-01-16T15:00:00Z"),
endtime: Date.parse("2016-01-16T15:30:00Z")
},
{
position: paus4,
starttime: Date.parse("2016-01-16T15:30:00Z"),
endtime: Date.parse("2016-01-16T18:00:00Z")
}
];
var dateTime;
if (urlParams["time"]) {
dateTime = Date.parse(urlParams["time"]);
console.log("time found");
console.log(dateTime);
} else {
dateTime = new Date();
console.log("now");
}
var current_path = { position: centralen, endtime: Date.parse("2016-01-16T08:50:00Z")};
for (var i = 0; i < all_path.length; i++) {
node = all_path[i];
console.log(node);
if (dateTime <= node.endtime && dateTime >= node.starttime) {
current_path = node;
console.log("Match");
break;
}
}
if (dateTime > all_path[all_path.length - 1].endtime) {
current_path = node;
}
console.log("current_path");
console.log(current_path);
var clock = document.getElementById('timeleft');
startTimer((current_path.endtime - dateTime)/1000 , clock)
if (current_path.position) {
new google.maps.Marker({
position: current_path.position,
map: map,
});
}
else
{
new google.maps.Marker({
position: current_path.start_pos,
map: map,
});
new google.maps.Marker({
position: current_path.end_pos,
map: map,
});
directionsService.route({
origin: current_path.start_pos,
destination: current_path.end_pos,
travelMode: google.maps.TravelMode.WALKING
}, function(response, status) {
if (status === google.maps.DirectionsStatus.OK) {
console.log(response);
directionsDisplay.setDirections(response);
} else {
window.alert('Directions request failed due to ' + status);
}
}
);
}
}
</script>
</head>
<body>
<div id="map"></div>
<h1 style="font-size: 500%; text-align: center; width: 100%; margin: 10px">
God Jul!
</h1>
<div style="text-align: center; width: 100%; font-size: 300%" id="timeleft"></div>
<div style="border: 1px solid black; width: 300px; margin-top: 50px;margin-left: auto; margin-right: auto;">
<ul style="display: inline-block;">
<li><strong>Klädsel:</strong> Vardags</li>
<li><strong>Barnvakt:</strong> Ordnat</li>
<li><strong>Mat:</strong> ingår</li>
<li><strong>Fika:</strong> ingår</li>
<li><strong>Instuderingslitteratur:</strong> Fem på äventyr</li>
</ul>
</div>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAqpRp_oz9Oe0yvuVfJGo5wz9RL7wJTapU&callback=&callback=initMap"></script>
</body>
</html>