Thu, 06 Dec 2018 19:36:27 +0200
branch merge
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> |
39 | var getJSON = function(url, callback) { | |
40 | var xhr = new XMLHttpRequest(); | |
41 | xhr.open('GET', url, true); | |
42 | xhr.responseType = 'json'; | |
43 | xhr.onload = function() { | |
44 | var status = xhr.status; | |
45 | if (status === 200) { | |
46 | callback(xhr.response); | |
47 | } | |
48 | }; | |
49 | xhr.send(); | |
50 | }; | |
51 | ||
52 | var getUuid = function(blockref, originaimeddeparturetime, data, callback) { | |
53 | var xhr = new XMLHttpRequest(); | |
54 | var url = "../find_halt/{{ref}}/" + blockref + "/" + originaimeddeparturetime.toString(); | |
55 | xhr.open('GET', url, true); | |
56 | xhr.responseType = 'json'; | |
57 | xhr.onload = function() { | |
58 | var status = xhr.status; | |
59 | if (status === 200) { | |
60 | callback(xhr.response['id'], data); | |
61 | } | |
62 | }; | |
63 | xhr.send(); | |
64 | }; | |
65 | ||
66 | function timeConverter(UNIX_timestamp){ | |
67 | var a = new Date(UNIX_timestamp * 1000); | |
68 | var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; | |
69 | var year = a.getFullYear(); | |
70 | var month = months[a.getMonth()]; | |
71 | var date = a.getDate(); | |
72 | var hour = a.getHours(); | |
73 | var min = a.getMinutes(); | |
74 | var sec = a.getSeconds(); | |
75 | var time = hour + ':' + (min < 10 ? '0' : '') + min; | |
76 | return time; | |
77 | } | |
78 | ||
79 | function updateTime(uuid, time) { | |
80 | const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; | |
81 | const d = new Date(); | |
82 | const now = (d.getTime() + d.getTimezoneOffset()) / 1000; | |
83 | row = document.getElementById(uuid); | |
84 | timeCell = document.getElementById(uuid + '-time'); | |
85 | t0 = parseInt(document.getElementById(uuid + '-stamp').innerHTML); | |
86 | if (Math.abs(time - t0) > 90) { | |
87 | oldTime = timeConverter(t0); | |
88 | newTime = timeConverter(time); | |
89 | timeCell.innerHTML = '<s style="color:gray">' + oldTime + '</s> ⟶ <b>' + newTime + '</b>'; | |
90 | } | |
91 | if (time + 15 > now) | |
92 | row.classList.remove('gone'); | |
93 | else | |
94 | row.classList.add('gone'); | |
95 | } | |
96 | </script> | |
0 | 97 | </head> |
98 | <body> | |
93 | 99 | <table class='aikataulu service-{{service}}' cellspacing="0"> |
55
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
100 | <thead> |
0 | 101 | <tr> |
55
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
102 | <th colspan='4' class='primary-heading'> |
90 | 103 | <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
|
104 | </th> |
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
105 | </tr> |
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
106 | <tr class='headings'> |
20
3199e289ae62
- Sivusto hieman edustuksellisempi
Teemu Piippo <teemu@hecknology.net>
parents:
19
diff
changeset
|
107 | <th class='sarake-aika'>{{tr('time', 'headings')}}</th> |
3199e289ae62
- Sivusto hieman edustuksellisempi
Teemu Piippo <teemu@hecknology.net>
parents:
19
diff
changeset
|
108 | <th class='sarake-linja'>{{tr('route', 'headings')}}</th> |
3199e289ae62
- Sivusto hieman edustuksellisempi
Teemu Piippo <teemu@hecknology.net>
parents:
19
diff
changeset
|
109 | <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
|
110 | <th> |
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
111 | <span class='actions'> |
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
112 | <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
|
113 | {% if cluster %} |
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
114 | <a href="../stop_cluster/{{cluster}}">🞊</a> |
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
115 | {% endif %} |
109 | 116 | <a href='../stop_week/{{ref}}'>▤</a> |
55
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
117 | </th> |
0 | 118 | </tr> |
55
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
119 | </thead> |
127 | 120 | <tbody id='departures-table'> |
24
e6bdb9c54096
Yhtenäistetty ohjelmakoodin kieli englanniksi
Teemu Piippo <teemu@hecknology.net>
parents:
22
diff
changeset
|
121 | {% for halt in schedule %} |
127 | 122 | <tr class="{% if halt['night'] %} yö {% endif %}{% if halt['gone'] %}gone{% endif %}" id="{{halt['id']}}"> |
41 | 123 | <td class='sarake-aika'> |
127 | 124 | <!-- |
41 | 125 | {% if halt['imminent'] %} |
126 | <span class='imminent-leave'>●</span> | |
127 | {% endif %} | |
127 | 128 | --> |
129 | <span id="{{halt['id']}}-time"></span> | |
130 | <span class='dataentry' id="{{halt['id']}}-stamp">{{halt['timestamp']}}</span> | |
131 | <!--{{halt['time']}}--></td> | |
0 | 132 | <td class='sarake-linja linja'> |
77 | 133 | <a href="../trip/{{halt['trip']}}">{{route_rep(halt['route-splice'])}}</a> |
0 | 134 | </td> |
55
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
135 | <td class='sarake-määränpää' colspan='2'> |
48
428cfdf64ccc
Lisätty uudelleenohjauksia
Teemu Piippo <teemu@hecknology.net>
parents:
41
diff
changeset
|
136 | <a href="../trip/{{halt['trip']}}">{{halt['sign']}}</a> |
0 | 137 | </td> |
138 | </tr> | |
139 | {% endfor %} | |
55
0f1d046b3f78
Suppeampi näkymä, pikatiet ja mootoritiet
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
140 | </tbody> |
0 | 141 | </table> |
127 | 142 | <script> |
143 | var list = document.getElementById('departures-table').children; | |
144 | for (var i = 0; i < list.length; i += 1) { | |
145 | id = list[i].id; | |
146 | timestamp = parseInt(document.getElementById(id + '-stamp').innerHTML); | |
147 | document.getElementById(id + '-time').innerHTML = timeConverter(timestamp); | |
148 | } | |
149 | //updateTime('fbf6f367-069c-4f8d-831b-bd36cd643f3b', 1544092500); | |
150 | getJSON('http://data.foli.fi/siri/sm/{{ref}}', function(data){ | |
151 | var arrayLength = data['result'].length; | |
152 | for (var i = 0; i < arrayLength; i++) { | |
153 | var blockref = data['result'][i]['blockref']; | |
154 | var originaimeddeparturetime = data['result'][i]['originaimeddeparturetime']; | |
155 | var expecteddeparturetime = data['result'][i]['expecteddeparturetime']; | |
156 | getUuid(blockref, originaimeddeparturetime, expecteddeparturetime, function(id, expecteddeparturetime) { | |
157 | updateTime(id, expecteddeparturetime); | |
158 | }); | |
159 | } | |
160 | }); | |
161 | </script> | |
0 | 162 | </body> |
4 | 163 | </html> |