templates/stop.html

Mon, 11 Feb 2019 22:39:44 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Mon, 11 Feb 2019 22:39:44 +0200
changeset 137
457200a4344b
parent 136
27324a81beca
permissions
-rw-r--r--

update

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

mercurial