-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
636 lines (577 loc) · 29 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
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
<!doctype html>
<html>
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-70819-9"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-70819-9', {
send_page_view: false,
custom_map: { dimension1: 'geoLocation' }
});
</script>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=3.0, user-scalable=yes">
<title>Wolfe Island Ferry</title>
<link rel="stylesheet" href="css/jqtouch.css" title="jQTouch">
<meta name="description" content="Live camera views and schedule of the Wolfe Island Ferry between Kingston and Wolfe Island, Ontario" />
<link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/icons/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<script src="lib/jquery-1.7.min.js" type="text/javascript" charset="utf-8"></script>
<script src="lib/jqtouch.min.js" type="text/javascript" charset="utf-8"></script>
<script src="lib/jqtouch-jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="lib/moment.min.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css" integrity="sha384-4LISF5TTJX/fLmGSxO53rV4miRxdg84mZsxmO8Rx5jGtp/LbrixFETvWa5a6sESd" crossorigin="anonymous">
<script type="text/javascript" charset="utf-8">
var jQT = new $.jQTouch({
addGlossToIcon: false,
statusBar: 'black-translucent',
preloadImages: [],
fixedViewport: false, // don't add <meta viewport>
});
var buildSchedules = function() {
// note: if the schedules change and there are non-equal number of
// crossings, there is a loop below that needs to be updated
var schedules =
{
kingston:[
{h:06,m:00}
,{h:07,m:00}
,{h:08,m:00}
,{h:09,m:00}
,{h:10,m:00}
,{h:11,m:00}
,{h:12,m:00}
,{h:13,m:00}
,{h:14,m:00}
,{h:15,m:00}
,{h:16,m:00}
,{h:17,m:00}
,{h:18,m:00}
,{h:19,m:00}
,{h:20,m:00}
,{h:21,m:00}
,{h:22,m:00}
,{h:23,m:30}
,{h:01,m:00}
,{h:02,m:00}
],
island:[
{h:05,m:30}
,{h:06,m:30}
,{h:07,m:30}
,{h:08,m:30}
,{h:09,m:30}
,{h:10,m:30}
,{h:11,m:30}
,{h:12,m:30}
,{h:13,m:30}
,{h:14,m:30}
,{h:15,m:30}
,{h:16,m:30}
,{h:17,m:30}
,{h:18,m:30}
,{h:19,m:30}
,{h:20,m:30}
,{h:21,m:30}
,{h:22,m:30}
,{h:00,m:00}
,{h:01,m:30}
]
};
// expand out the base objects
$.each(schedules.kingston, function(i) {
var tod = (this.h*60)+this.m; // time-of-day serves as our ID
schedules.kingston[i] = {
tod:tod,
h:this.h,
m:this.m,
departing:'Kingston'
};
});
$.each(schedules.island, function(i) {
var tod = (this.h*60)+this.m; // time-of-day serves as our ID
schedules.island[i] = {
tod:tod,
h:this.h,
m:this.m,
departing:'Island'
};
});
return schedules;
}
var scheduleWarning = 'Using Wolfe Islander III on 60-minute schedule (Dec 22)';
var wolfeIslandBounds = [
[44.234161,-76.398870],
[44.182973,-76.526586],
[44.149973,-76.557485],
[44.103150,-76.492253],
[44.092794,-76.442815],
[44.132727,-76.351491],
[44.183958,-76.330892],
[44.202174,-76.295186],
[44.203159,-76.235831],
[44.230225,-76.172660],
[44.242033,-76.182960]
];
/** Returns an object containing the next departure times for
* .kingston, .island, and .next.
* A .date property (moment object) is also added to the time objects,
* indicating the percise date/time of next crossing.
*/
var findNextTimes = function() {
var now = new moment();
var tod = (now.hours()*60) + now.minutes();
var nextTime = null;
var next = {
kingston: schedules.kingston[0],
island: schedules.island[0],
};
var compareTimes = function(start, compare, end) {
// if end > start, compare comes between start and end
// or, end < start (eg, from 11pm to 1am),
// compare is before start (eg, 1am)
// xor compare is after end (eg, 11pm)
//if (end < start) console.log('end<start', end, start, compare, (compare < start), (compare > end));
return ((end > start) && (compare >= start) && (compare < end))
|| ((end < start)
&& ((compare < start) || (compare > end))
&& !((compare < start) && (compare > end))); //xor
}
for (var i = 1; i<schedules.kingston.length; i++) {
if (compareTimes(schedules.kingston[i-1].tod, tod, schedules.kingston[i].tod)) {
next.kingston = schedules.kingston[i];
}
}
for (var i = 1; i<schedules.island.length; i++) {
if (compareTimes(schedules.island[i-1].tod, tod, schedules.island[i].tod)) {
next.island = schedules.island[i];
}
}
next.kingston.date = moment(
new Date(now.year(),
now.month(),
now.date() + ((next.kingston.tod < tod) ? 1 : 0),
next.kingston.h,
next.kingston.m));
next.island.date = moment(
new Date(now.year(),
now.month(),
now.date() + ((next.island.tod < tod) ? 1 : 0),
next.island.h,
next.island.m));
if (next.kingston.date.valueOf() < next.island.date.valueOf()) {
next.next = next.kingston;
next.next_location = 'kingston';
} else {
next.next = next.island;
next.next_location = 'island';
}
return next;
}
var formatTime = function(time) {
var m = ((time.m < 10) ? '0'+time.m : time.m);
if (time.h == 0) {
return '12:'+m+' AM';
} else if (time.h < 12) {
return time.h+':'+m+' AM';
} else if (time.h == 12) {
return time.h+':'+m+' PM';
} else {
return (time.h-12)+':'+m+' PM';
}
}
var populateSchedulePage = function() {
var titles = '<li class="sep"><div>From Island</div><div>From Kingston</div></li>';
var html = (scheduleWarning ? '<li class="warning">' + scheduleWarning + '</li>' : '')
+ titles;
//Note: this loop needs to be modified if the crossing times are ever not equal
if (schedules.kingston.length != schedules.island.length) {
alert('Times do not match! populateSchedulePage() has to be updated.');
return;
};
for (var i = 0; i < schedules.kingston.length; i++) {
html += '<li><div class="sched sched-'+schedules.island[i].tod+'">'+formatTime(schedules.island[i])+'</div>' +
'<div class="sched sched-'+schedules.kingston[i].tod+'">'+formatTime(schedules.kingston[i])+'</div></li>';
if (i == Math.floor(schedules.kingston.length/2)-1) {
html += titles;
}
}
html += titles;
$('#schedule ul.schedule').html(html);
};
var refreshNextTimes = function() {
nextTimes = findNextTimes();
$('.kingston.next-departure').html('<em>Ferry leaves Kingston</em> '+nextTimes.kingston.date.fromNow()+
'<small class="count">'+formatTime(nextTimes.kingston)+'</small>');
$('.island.next-departure').html('<em>Ferry leaves Island</em> '+nextTimes.island.date.fromNow()+
'<small class="count">'+formatTime(nextTimes.island)+'</small>');
// highlight schedule entry
$('.sched').removeClass('next').removeClass('next-actual');
$('.sched.sched-'+nextTimes.island.tod).addClass('next');
$('.sched.sched-'+nextTimes.kingston.tod).addClass('next');
$('.sched.sched-'+nextTimes.next.tod).addClass('next-actual');
// set body
if (nextTimes.next_location == 'kingston') {
$('body').removeClass('next-island').addClass('next-kingston');
} else {
$('body').removeClass('next-kingston').addClass('next-island');
}
};
var refreshCameras = function() {
var hash = new Date().getTime();
console.log('refreshing cams', hash);
$('.cam img').each(function() {
$(this).attr('src', $(this).data('src')+'?'+hash);
});
};
// from https://github.com/substack/point-in-polygon, MIT
var isInside = function (point, vs) {
// ray-casting algorithm based on
// http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
var x = point[0], y = point[1];
var inside = false;
for (var i = 0, j = vs.length - 1; i < vs.length; j = i++) {
var xi = vs[i][0], yi = vs[i][1];
var xj = vs[j][0], yj = vs[j][1];
var intersect = ((yi > y) != (yj > y))
&& (x < (xj - xi) * (y - yi) / (yj - yi) + xi);
if (intersect) inside = !inside;
}
return inside;
};
var refreshLocation = function() {
if ("geolocation" in navigator) {
navigator.geolocation.getCurrentPosition(
function (geo) {
var onIsland = isInside([geo.coords.latitude,geo.coords.longitude], wolfeIslandBounds);
var inKingston = Math.floor(geo.coords.latitude) == 44 && Math.ceil(geo.coords.longitude) == -76;
console.log('geo', geo, 'onIsland', onIsland, 'inKingston', inKingston);
if (onIsland) {
$('body').attr('data-geo', 'Island');
} else if (inKingston) {
$('body').attr('data-geo', 'Kingston');
} else {
$('body').attr('data-geo', 'Other');
}
},
function () {
// can't find position
console.log("geolocation failed");
$('body').attr('data-geo', 'Unknown');
},
{timeout:10000})
}
};
// find template.jit-content and replace with inner html
// returns true if any elements were replaced
var replaceJitContent = function(page) {
var templates = $('template.jit-content', page);
var changed = false;
templates.each(function(idx,e) {
console.log(e);
changed = true;
e.outerHTML = e.innerHTML; // replace <template clas=jit-content> with contents
});
return changed;
}
var ensureTwitterLoaded = function() {
if ($('script#twitter-js').length == 0) {
var script = document.createElement('script');
script.id = 'twitter-js';
script.src = 'https://platform.twitter.com/widgets.js';
script.charset = 'utf-8';
document.head.appendChild(script);
}
}
var nextTimer, cameraTimer, locationTimer;
var ensureRefreshRunning = function() {
nextTimer = setInterval(refreshNextTimes, 45000); // 45s
cameraTimer = setInterval(refreshCameras, 120000); // 2mins (MTO only updates every 2 mins)
//locationTimer = setInterval(refreshLocation, 600000); // 10mins
};
var schedules = buildSchedules();
var nextTimes = null; // periodically refreshed with the next times
// analytics callback
window.addEventListener("hashchange", function() {
gtag('event', 'page_view', {
page_path: window.location.hash,
page_title: $('div.current h1:first').text(),
geoLocation: $('body').attr('data-geo')
});
}, false);
$(function(){
// Orientation callback event
$('#jqt').bind('turn', function(e, data){
$('#orient').html('Orientation: ' + data.orientation);
});
$('#jqt > div').on('pageAnimationStart', function(e, data) {
console.log("anim start", this);
if (data.direction == "in") {
if (replaceJitContent(this)) {
refreshCameras();
}
if ($(this).hasClass('twitter')) {
ensureTwitterLoaded();
}
}
});
if (scheduleWarning) {
$("#home-warning").prepend('<li class="warning"><a href="#schedule" class="text-warning">' + scheduleWarning + '</a></li>')
}
populateSchedulePage();
refreshNextTimes();
refreshLocation();
// pass current page to replace any templated content
replaceJitContent(jQT.history[0].page[0]);
refreshCameras();
ensureRefreshRunning();
// save timing info
if (window.performance) {
gtag('event', 'timing_complete', {
name: 'load',
value: Math.round(window.performance.now()),
event_category: 'Finished',
geoLocation: $('body').attr('data-geo')
});
}
});
</script>
<style type="text/css" media="screen">
#jqt.fullscreen .add-to-home,
.add-to-home { /* disable for now */
display: none;
}
#jqt .toolbar > h1 {
width:80%;
margin:1px 0 0 0;
left:10%;
}
#jqt #home-warning {
margin-top: 0;
}
li.cam {
text-align:center;
}
li.cam img {
max-width: 100%;
}
ul.schedule li div {
width:48%;
float:left;
text-align:center;
}
ul.schedule li div.next {
color:#93B893;
}
ul.schedule li div.next-actual {
color:green;
}
.warning {
color:#6E8A8A !important;
text-align:center;
}
#jqt ul li a.inline {
display:inline;
}
#jqt ul li p {
padding-bottom:0.5em;
}
#jqt ul li p:last-child {
padding-bottom:0;
}
a.twitter-timeline {
text-decoration:none;
cursor:default;
}
/* hide/show the next-depature section */
#home li.next-departure {
display:none;
}
body.next-kingston #home li.kingston,
body[data-geo=Kingston] #home li.kingston {
display:block;
}
body.next-island #home li.island,
body[data-geo=Island] #home li.island {
display:block;
}
body[data-geo=Kingston].next-island #home li.island {
display:none;
}
body[data-geo=Island].next-kingston #home li.kingston {
display:none;
}
</style>
</head>
<body>
<div id="jqt">
<div id="home" class="current">
<div class="toolbar">
<h1>Wolfe Island Ferry</h1>
</div>
<div class="scroll">
<ul id="home-warning" class="edgetoedge scroll">
<li class="kingston next-departure gps"></li>
<li class="island next-departure gps"></li>
</ul>
<h2>Cameras</h2>
<ul class="rounded">
<li class="arrow"><a href="#kingston">Kingston Dock</a> </li>
<li class="arrow"><a href="#dawsons">Island - Dawsons Point</a> </li>
<li class="arrow"><a href="#marysville">Island - Marysville Dock</a> </li>
</ul>
<h2>Twitter</h2>
<ul class="rounded">
<li class="arrow"><a href="#twitter-WolfeIslander3">@WolfeIslander3</a> </li>
<li class="arrow"><a href="#twitter-MIHomeYGK">@MIHomeYGK</a> </li>
</ul>
<h2>Info</h2>
<ul class="rounded">
<li class="arrow"><a href="#map">Live Map</a> </li>
<li class="arrow"><a href="#schedule">Schedule</a> </li>
<li class="arrow"><a href="#about">About</a> </li>
</ul>
</div>
</div>
<div id="schedule">
<div class="toolbar">
<h1>Ferry Schedule</h1>
<a href="#" class="back">Back</a>
</div>
<ul class="edgetoedge scroll schedule"></ul>
</div>
<div id="map">
<div class="toolbar">
<h1>Live Map (AIS)</h1>
<a href="#" class="back">Back</a>
<a href="https://www.marinetraffic.com/en/ais/home/centerx:-76.453/centery:44.216/zoom:13" rel="external" target="_blank" class="button">Open <i class="bi bi-box-arrow-up-right"></i></a>
</div>
<div>
<template class="jit-content">
<iframe name="marinetraffic" id="marinetraffic"
width="100%" height="480"
scrolling="no" frameborder="1"
src="https://www.marinetraffic.com/en/ais/embed/zoom:13/centery:44.215729/centerx:-76.453/maptype:0/shownames:false/mmsi:0/shipid:0/fleet:/fleet_id:/vtypes:/showmenu:false/remember:false">
<ul>
<li>
<p>Sorry, this feature is not supported on your browser.</p>
</li>
</ul>
</iframe>
</template>
</div>
</div>
<div id="twitter-WolfeIslander3" class="twitter">
<div class="toolbar">
<h1>@WolfeIslander3</h1>
<a href="#" class="back">Back</a>
<a href="https://twitter.com/WolfeIslander3" rel="extenal" target="_blank" class="button">Open <i class="bi bi-box-arrow-up-right"></i></a>
</div>
<div>
<a class="twitter-timeline"
data-dnt="true" data-theme="dark" data-tweet-limit="24" data-chrome="noheader"
href="https://twitter.com/WolfeIslander3?ref_src=twsrc%5Etfw">
<ul>
<li>
<p>Loading...</p>
</li>
</ul>
</a>
</div>
</div>
<div id="twitter-MIHomeYGK" class="twitter">
<div class="toolbar">
<h1>@MIHomeYGK</h1>
<a href="#" class="back">Back</a>
<a href="https://twitter.com/MIHomeYGK" rel="extenal" target="_blank" class="button">Open <i class="bi bi-box-arrow-up-right"></i></a>
</div>
<div>
<a class="twitter-timeline"
data-dnt="true" data-theme="dark" data-tweet-limit="24" data-chrome="noheader"
href="https://twitter.com/MIHomeYGK?ref_src=twsrc%5Etfw">
<ul>
<li>
<p>Loading...</p>
</li>
</ul>
</a>
</div>
</div>
<div id="kingston" class="kingston jit-content">
<div class="toolbar">
<h1>Kingston Dock</h1>
<a href="#" class="back">Back</a>
</div>
<ul class="edgetoedge scroll display-on-activate">
<li class="kingston next-departure"></li>
<template class="jit-content">
<li class="cam"><img data-src="https://511on.ca/map/Cctv/1052" alt="Kingston Camera - Dock" /></li>
<li class="cam"><img data-src="https://511on.ca/map/Cctv/1423" alt="Kingston Camera - Parking" /></li>
</template>
</ul>
</div>
<div id="dawsons" class="island">
<div class="toolbar">
<h1>Dawson's Point Dock</h1>
<a href="#" class="back">Back</a>
</div>
<ul class="edgetoedge scroll display-on-activate">
<li class="island next-departure"></li>
<template class="jit-content">
<li class="cam"><img data-src="https://511on.ca/map/Cctv/1422" alt="Dawson's Point Camera - Dock" /></li>
<li class="cam"><img data-src="https://511on.ca/map/Cctv/1421" alt="Dawson's Point Camera - Road Facing Dock" /></li>
<li class="cam"><img data-src="https://511on.ca/map/Cctv/1420" alt="Dawson's Point Camera - Road Facing Highway" /></li>
</template>
</ul>
</div>
<div id="marysville" class="island">
<div class="toolbar">
<h1>Marysville Dock</h1>
<a href="#" class="back">Back</a>
</div>
<ul class="edgetoedge scroll display-on-activate">
<li class="island next-departure"></li>
<template class="jit-content">
<li class="cam"><img data-src="https://511on.ca/map/Cctv/1418" alt="Marysville Camera - Parking" /></li>
<li class="cam"><img data-src="https://511on.ca/map/Cctv/1419" alt="Marysville Camera - Main Street" /></li>
<!-- https://511on.ca/map/Cctv/loc58--4, https://511on.ca/map/Cctv/loc57--4 -->
</template>
</ul>
</div>
<div id="about">
<div class="toolbar">
<h1>About</h1>
<a href="#" class="back">Back</a>
</div>
<div>
<h2>Wolfe Island Ferry</h2>
<ul>
<li>
<p>The Wolfe Islander III can carry approximately 55 cars and 294 passengers. It takes about 20 minutes to cross, and service is free on a first-come, first-served basis.</p>
<p>The ferry operates year-round, but moves to the Dawson Point dock during the winter while there is ice on the lake, and earlier if there are low water conditions in Marysville.</p>
<p>Medical and emergency services have priority, and may cause disruptions to the schedule and wait times.</p>
</li>
<li><a href="http://www.mto.gov.on.ca/english/service-commitment/ferry-services.shtml" target="_blank">MTO Ferry Services Information</a></li>
</ul>
<h2>wiferry.ca</h2>
<ul>
<li>
This was created as a quick way to get schedules, camera feeds and other news about the ferry. I hope you find it useful.
- <a class="inline" href="https://twitter.com/groogs" target="_blank">Greg</a>
</li>
<li>AIS maps from <a class="inline" href="https://www.marinetraffic.com/en/ais/home/centerx:-76.3/centery:44.2/zoom:11" target="_blank">MarineTraffic.com</a></li>
<li>Report bugs/suggestions on <a class="inline" href="https://github.com/gregmac/WolfeFerryApp/issues" target="_blank">GitHub</a></li>
</ul>
</div>
<div class="info add-to-home">
<p>Add this page to your home screen.</p>
</div>
</div>
</div>
</body>
</html>