Thu, 20 Dec 2018 23:11:07 +0200
added Yli-maarian koulu
77 | 1 | {% from "macros.html" import route_rep %} |
0 | 2 | <html> |
3 | <head> | |
35 | 4 | <link rel="icon" type="image/png" href="../static/favicon.png" /> |
5 | <link rel="stylesheet" type="text/css" href="../static/style.css" /> | |
0 | 6 | <meta charset='UTF-8' /> |
33
f448f291c1dd
Korjattu pysäkkisivun otsikko
Teemu Piippo <teemu@hecknology.net>
parents:
32
diff
changeset
|
7 | <title>{{name}}</title> |
32
ca1a0ea81cf6
Yhdistetty pysäkki.png ja iso-pysäkki.png
Teemu Piippo <teemu@hecknology.net>
parents:
27
diff
changeset
|
8 | <meta http-equiv='refresh' content='60'> |
0 | 9 | <style> |
21 | 10 | .sarake-määränpää |
11 | { | |
12 | text-align: left; | |
13 | } | |
127 | 14 | |
15 | .dataentry | |
16 | { | |
17 | display: none; | |
18 | } | |
19 | ||
20 | .sarake-aika | |
21 | { | |
22 | width: 150pt; | |
23 | } | |
24 | ||
25 | .gone | |
26 | { | |
27 | background-color: #666; | |
28 | color: silver; | |
29 | font-style: italic; | |
30 | display: none; | |
31 | } | |
32 | ||
33 | tbody tr:nth-child(even).gone | |
34 | { | |
35 | background-color: #585858; | |
36 | } | |
0 | 37 | </style> |
127 | 38 | <script> |
134 | 39 | var getJSON = function(url, callback) |
40 | { | |
127 | 41 | var xhr = new XMLHttpRequest(); |
42 | xhr.open('GET', url, true); | |
43 | xhr.responseType = 'json'; | |
44 | xhr.onload = function() { | |
45 | var status = xhr.status; | |
46 | if (status === 200) { | |
47 | callback(xhr.response); | |
48 | } | |
49 | }; | |
50 | xhr.send(); | |
51 | }; | |
52 | ||
134 | 53 | function timeConverter(UNIX_timestamp) |
54 | { | |
127 | 55 | var a = new Date(UNIX_timestamp * 1000); |
56 | var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; | |
57 | var year = a.getFullYear(); | |
58 | var month = months[a.getMonth()]; | |
59 | var date = a.getDate(); | |
60 | var hour = a.getHours(); | |
61 | var min = a.getMinutes(); | |
62 | var sec = a.getSeconds(); | |
63 | var time = hour + ':' + (min < 10 ? '0' : '') + min; | |
64 | return time; | |
65 | } | |
66 | ||
134 | 67 | function epoch() |
68 | { | |
69 | var d = new Date(); | |
70 | if (d.getHours() < 4) | |
71 | d.setDate(d.getDate() - 1); | |
72 | d.setHours(0); | |
73 | d.setMinutes(0); | |
74 | d.setSeconds(0); | |
75 | return Math.floor(d.getTime() / 1000); | |
76 | } | |
77 | ||
78 | function primarykey(data) | |
79 | { | |
80 | var key = data['blockref'] + '-'; | |
81 | key += (data['originaimeddeparturetime'] - epoch()).toString() + '-'; | |
82 | key += data['visitnumber']; | |
83 | return key; | |
84 | } | |
85 | ||
86 | function updateTime(key, time) | |
87 | { | |
127 | 88 | const d = new Date(); |
89 | const now = (d.getTime() + d.getTimezoneOffset()) / 1000; | |
134 | 90 | row = document.getElementById(key); |
91 | timeCell = document.getElementById(key + '-time'); | |
92 | t0 = parseInt(document.getElementById(key + '-stamp').innerHTML); | |
93 | if (Math.abs(time - t0) > 90) | |
94 | { | |
127 | 95 | oldTime = timeConverter(t0); |
96 | newTime = timeConverter(time); | |
97 | timeCell.innerHTML = '<s style="color:gray">' + oldTime + '</s> ⟶ <b>' + newTime + '</b>'; | |
98 | } | |
134 | 99 | |
127 | 100 | if (time + 15 > now) |
101 | row.classList.remove('gone'); | |
102 | else | |
103 | row.classList.add('gone'); | |
104 | } | |
105 | </script> | |
0 | 106 | </head> |
107 | <body> | |
93 | 108 | <table class='aikataulu service-{{service}}' cellspacing="0"> |
55
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
109 | <thead> |
0 | 110 | <tr> |
55
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
111 | <th colspan='4' class='primary-heading'> |
90 | 112 | <span><img src="../static/{{typename}}.png" height="96" /> {{name}}</span> |
55
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
113 | </th> |
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
114 | </tr> |
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
115 | <tr class='headings'> |
20
3199e289ae62
- Sivusto hieman edustuksellisempi
Teemu Piippo <teemu@hecknology.net>
parents:
19
diff
changeset
|
116 | <th class='sarake-aika'>{{tr('time', 'headings')}}</th> |
3199e289ae62
- Sivusto hieman edustuksellisempi
Teemu Piippo <teemu@hecknology.net>
parents:
19
diff
changeset
|
117 | <th class='sarake-linja'>{{tr('route', 'headings')}}</th> |
3199e289ae62
- Sivusto hieman edustuksellisempi
Teemu Piippo <teemu@hecknology.net>
parents:
19
diff
changeset
|
118 | <th class='sarake-määränpää'>{{tr('destination', 'headings')}}</th> |
55
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
119 | <th> |
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
120 | <span class='actions'> |
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
121 | <a class="pysäkki-sijainti" href="{{link_to_map}}" target="_blank">📌</a> |
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
122 | {% if cluster %} |
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
123 | <a href="../stop_cluster/{{cluster}}">🞊</a> |
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
124 | {% endif %} |
109 | 125 | <a href='../stop_week/{{ref}}'>▤</a> |
55
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
126 | </th> |
0 | 127 | </tr> |
55
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
128 | </thead> |
127 | 129 | <tbody id='departures-table'> |
24
e6bdb9c54096
Yhtenäistetty ohjelmakoodin kieli englanniksi
Teemu Piippo <teemu@hecknology.net>
parents:
22
diff
changeset
|
130 | {% for halt in schedule %} |
127 | 131 | <tr class="{% if halt['night'] %} yö {% endif %}{% if halt['gone'] %}gone{% endif %}" id="{{halt['id']}}"> |
41 | 132 | <td class='sarake-aika'> |
127 | 133 | <!-- |
41 | 134 | {% if halt['imminent'] %} |
135 | <span class='imminent-leave'>●</span> | |
136 | {% endif %} | |
127 | 137 | --> |
138 | <span id="{{halt['id']}}-time"></span> | |
139 | <span class='dataentry' id="{{halt['id']}}-stamp">{{halt['timestamp']}}</span> | |
140 | <!--{{halt['time']}}--></td> | |
0 | 141 | <td class='sarake-linja linja'> |
77 | 142 | <a href="../trip/{{halt['trip']}}">{{route_rep(halt['route-splice'])}}</a> |
0 | 143 | </td> |
55
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
144 | <td class='sarake-määränpää' colspan='2'> |
48
428cfdf64ccc
Lisätty uudelleenohjauksia
Teemu Piippo <teemu@hecknology.net>
parents:
41
diff
changeset
|
145 | <a href="../trip/{{halt['trip']}}">{{halt['sign']}}</a> |
0 | 146 | </td> |
147 | </tr> | |
148 | {% endfor %} | |
55
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
149 | </tbody> |
0 | 150 | </table> |
127 | 151 | <script> |
152 | var list = document.getElementById('departures-table').children; | |
153 | for (var i = 0; i < list.length; i += 1) { | |
154 | id = list[i].id; | |
155 | timestamp = parseInt(document.getElementById(id + '-stamp').innerHTML); | |
156 | document.getElementById(id + '-time').innerHTML = timeConverter(timestamp); | |
157 | } | |
158 | //updateTime('fbf6f367-069c-4f8d-831b-bd36cd643f3b', 1544092500); | |
133 | 159 | getJSON('https://data.foli.fi/siri/sm/{{ref}}', function(data){ |
127 | 160 | var arrayLength = data['result'].length; |
161 | for (var i = 0; i < arrayLength; i++) { | |
162 | var blockref = data['result'][i]['blockref']; | |
163 | var originaimeddeparturetime = data['result'][i]['originaimeddeparturetime']; | |
164 | var expecteddeparturetime = data['result'][i]['expecteddeparturetime']; | |
134 | 165 | var key = primarykey(data['result'][i]); |
166 | updateTime(key, expecteddeparturetime); | |
127 | 167 | } |
168 | }); | |
169 | </script> | |
0 | 170 | </body> |
4 | 171 | </html> |