-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
423 lines (409 loc) · 18.7 KB
/
index.php
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
<?php
define('DSN', 'mysql:host=kutnpvrhom7lki7u.cbetxkdyhwsb.us-east-1.rds.amazonaws.com:3306;dbname=lcgyul56yfcheas3;charset=utf8mb4');
define('DB_USER', 'qniv4bnn438d3vf3');
define('DB_PASS', 'tpcjvhz7crsilp40');
try {
$pdo = new PDO(
DSN,
DB_USER,
DB_PASS,
[
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ,
PDO::ATTR_EMULATE_PREPARES => false,
]
);
} catch (PDOException $e) {
echo $e->getMessage();
exit;
}
if($_SERVER['REQUEST_METHOD'] === 'POST'){
//ここに日付が変わったらときのUPDATE処理を書く
if(isset($_POST['id']) && isset($_POST['direction'])){
$user_station =$_POST['id'];
$direction = $_POST['direction'];
$sql = "SELECT id, ".$direction." FROM latetimes WHERE id = ".$user_station." AND DATE_FORMAT(updated_at, '%Y-%m-%d') = DATE_FORMAT(CURTIME(), '%Y-%m-%d')";
$stmt = $pdo->query($sql);
$result = $stmt->fetch(); //PDO::FETCH_ASSOCを指定すれば配列形式で返ってくる。ex) $result['id']のように指定。
echo($result->$direction);
exit;
}
if(isset($_POST['fetchid']) && isset($_POST['direct']) && isset($_POST['latetime'])){
$fetchid = $_POST['fetchid'];
$direct = $_POST['direct'];
$receive_time = $_POST['latetime'];
$stmt = $pdo->query("UPDATE latetimes SET $direct = $receive_time WHERE id = $fetchid");
$stmt->execute();
}
}
function getLate($pdo)
{
$stmt = $pdo->query("SELECT * FROM latetimes ");
$lates = $stmt->fetchAll();
return $lates;
}
$lates = getLate($pdo);
?>
<!DOCTYPE html>
<html>
<!-- ウェブアプリマニフェストの読み込み -->
<link rel="manifest" href="manifest.json">
<!-- ServiceWorkerの登録 -->
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('sw.js')
.then((reg) => {
console.log('Service worker registered.', reg);
});
}
</script>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>BusVis</title>
<link href="https://use.fontawesome.com/releases/v5.0.8/css/all.css" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="0">
<!-- アドレスバー等のブラウザのUIを非表示 -->
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- default(Safariと同じ) / black(黒) / black-translucent(ステータスバーをコンテンツに含める) -->
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<!-- ホーム画面に表示されるアプリ名 -->
<meta name="apple-mobile-web-app-title" content="BusVis">
<!-- ホーム画面に表示されるアプリアイコン -->
<link rel="apple-touch-icon" href="./img/192px/icon_192-back-blue.png">
</head>
<body>
<header class="page-header wrapper" id='header-id'>
<div class="inner-box">
<div class="font-biggest">
<p id="user-station">つくばセンター</p>
</div>
<div class="font-departure">
<p id="departure-time"> </p>
</div>
<div class="flex-container">
<div id="remaining-time-box">
<div class="font-smaller">
<p>次の発車まであと</p>
</div>
<div class="font-bigger">
<p id="remaining-time"> </p>
</div>
</div>
<div id="expected-time-box">
<div class="font-delay">
<p id="late-time-line"><span id="late-time"> </span><span id="late-word"></span></p>
</div>
<div class="font-smaller">
<p id="expected-time"> </p>
</div>
</div>
</div>
</div>
</header>
<div class="popup" id="js-popup">
<div class="popup-inner">
<div class="user-reaction-box" id="user-reaction">
<div id="reaction-items">
<div class="close-btn" id="js-close-btn"><i class="fas fa-times"></i></div>
<ul>
<li class="reaction-item" data-late="0">遅れなし</li>
<li class="reaction-item" data-late="2">2分遅れ</li>
<li class="reaction-item" data-late="4">4分遅れ</li>
</ul>
</div>
</div>
</div>
<div class="black-background" id="js-black-bg"></div>
</div>
<div id="canvas-wrapper">
<div id="container" class="canvas-box">
<canvas id="bus-map"></canvas>
</div>
</div>
<div class="btn-box wrapper">
<div class="btn-container">
<div class="btn btn-common switch-holiday-weekday weekday"></div>
<div class="btn btn-common switch-left-right on"></div>
<!-- <div class="btn btn2 change-bus-stop"></div> バス停を変更するボタン -->
<div class="btn btn2 change-bus"></div> <!--バスを変更するボタン-->
<div class="btn btn2 reaction"></div> <!--バスを変更するボタン-->
</div>
</div>
<div class="explanation-wrapp" id="explanation">
<div class="explanation">
<div class="box7">
<div class="logo-pos">
<img src="img/logo--.png" class="logo-size">
</div>
<p>BusVisは、筑波大学循環バスの遅延情報を確認できるアプリです。</br>
現在地から最寄りのバス停が自動で選択されていますが、乗りたいバス停を選択してみてください。</br>
右回り・左回りを変更したり、平日・休日を変更できます。</br>
現在時刻に沿ったバスが表示されていて、選択されているバス停までの到着時刻を表示しています。</br>
「バス」ボタンを押すことで、別のバスを選択できます。</br>
遅延情報を送信するボタンがユーザーから押されることで、バスの遅延状況を全ユーザーに反映します。</br></p>
</div>
</div>
</div>
<div class="time-tables">
<div>
<h2 class="time-title">つくばセンター発の時刻表</h2>
</div>
<div class="table-flex-container">
<div class="table-wrapp" id="normal-right">
<p>平日 右回り</p>
<table>
<tr>
<td class="row-head">6</td>
<td class="table-date">00 40</td>
<td class="row-head">15</td>
<td class="table-date">00 20 40</td>
</tr>
<tr>
<td class="row-head">7</td>
<td class="table-date">20 50</td>
<td class="row-head">16</td>
<td class="table-date">00 20 40</td>
</tr>
<tr>
<td class="row-head">8</td>
<td class="table-date">00 10 30 40 50</td>
<td class="row-head">17</td>
<td class="table-date">00 20 40</td>
</tr>
<tr>
<td class="row-head">9</td>
<td class="table-date">10 20 30 50</td>
<td class="row-head">18</td>
<td class="table-date">00 20 40</td>
</tr>
<tr>
<td class="row-head">10</td>
<td class="table-date">00 20 40</td>
<td class="row-head">19</td>
<td class="table-date">00 20 40</td>
</tr>
<tr>
<td class="row-head">11</td>
<td class="table-date">00 20 40</td>
<td class="row-head">20</td>
<td class="table-date">00 20 40</td>
</tr>
<tr>
<td class="row-head">12</td>
<td class="table-date">00 20 40</td>
<td class="row-head">21</td>
<td class="table-date">00 40</td>
</tr>
<tr>
<td class="row-head">13</td>
<td class="table-date">00 20 40</td>
<td class="row-head">22</td>
<td class="table-date">20</td>
</tr>
<tr>
<td class="row-head">14</td>
<td class="table-date">00 20 40</td>
<td class="table-date"> </td>
<td class="table-date"> </td>
</tr>
</table>
</div>
</br>
<div class="table-wrapp" id="normal-left">
<p>平日 左回り</p>
<table>
<tr>
<td class="row-head">6</td>
<td class="table-date">20</td>
<td class="row-head">15</td>
<td class="table-date">10 30 50</td>
</tr>
<tr>
<td class="row-head">7</td>
<td class="table-date">00 40</td>
<td class="row-head">16</td>
<td class="table-date">10 30 50</td>
</tr>
<tr>
<td class="row-head">8</td>
<td class="table-date">20</td>
<td class="row-head">17</td>
<td class="table-date">10 30 50</td>
</tr>
<tr>
<td class="row-head">9</td>
<td class="table-date">00 40</td>
<td class="row-head">18</td>
<td class="table-date">10 30 50</td>
</tr>
<tr>
<td class="row-head">10</td>
<td class="table-date">10 30 50</td>
<td class="row-head">19</td>
<td class="table-date">10 30 50</td>
</tr>
<tr>
<td class="row-head">11</td>
<td class="table-date">10 30 50</td>
<td class="row-head">20</td>
<td class="table-date">10 30 50</td>
</tr>
<tr>
<td class="row-head">12</td>
<td class="table-date">10 30 50</td>
<td class="row-head">21</td>
<td class="table-date">20</td>
</tr>
<tr>
<td class="row-head">13</td>
<td class="table-date">10 30 50</td>
<td class="row-head">22</td>
<td class="table-date">00</td>
</tr>
<tr>
<td class="row-head">14</td>
<td class="table-date">10 30 50</td>
<td class="table-date"> </td>
<td class="table-date"> </td>
</tr>
</table>
</div>
</div>
</br>
<div class="table-flex-container">
<div class="table-wrapp" id="normal-right">
<p>休日 右回り</p>
<table>
<tr>
<td class="row-head">6</td>
<td class="table-date">00 40</td>
<td class="row-head">15</td>
<td class="table-date">20</td>
</tr>
<tr>
<td class="row-head">7</td>
<td class="table-date">20</td>
<td class="row-head">16</td>
<td class="table-date">00 40</td>
</tr>
<tr>
<td class="row-head">8</td>
<td class="table-date">00 40</td>
<td class="row-head">17</td>
<td class="table-date">20</td>
</tr>
<tr>
<td class="row-head">9</td>
<td class="table-date">20</td>
<td class="row-head">18</td>
<td class="table-date">00 40</td>
</tr>
<tr>
<td class="row-head">10</td>
<td class="table-date">00 40</td>
<td class="row-head">19</td>
<td class="table-date">20</td>
</tr>
<tr>
<td class="row-head">11</td>
<td class="table-date">20</td>
<td class="row-head">20</td>
<td class="table-date">00 40</td>
</tr>
<tr>
<td class="row-head">12</td>
<td class="table-date">00 40</td>
<td class="row-head">21</td>
<td class="table-date">20</td>
</tr>
<tr>
<td class="row-head">13</td>
<td class="table-date">20</td>
<td class="row-head">22</td>
<td class="table-date">00</td>
</tr>
<tr>
<td class="row-head">14</td>
<td class="table-date">00 40</td>
<td class="table-date"> </td>
<td class="table-date"> </td>
</tr>
</table>
</div>
</br>
<div class="table-wrapp" id="normal-left">
<p>休日 左回り</p>
<table>
<tr>
<td class="row-head">6</td>
<td class="table-date">20</td>
<td class="row-head">15</td>
<td class="table-date">00 40</td>
</tr>
<tr>
<td class="row-head">7</td>
<td class="table-date">00 40</td>
<td class="row-head">16</td>
<td class="table-date">20</td>
</tr>
<tr>
<td class="row-head">8</td>
<td class="table-date">20</td>
<td class="row-head">17</td>
<td class="table-date">00 40</td>
</tr>
<tr>
<td class="row-head">9</td>
<td class="table-date">00 40</td>
<td class="row-head">18</td>
<td class="table-date">20</td>
</tr>
<tr>
<td class="row-head">10</td>
<td class="table-date">20</td>
<td class="row-head">19</td>
<td class="table-date">00 40</td>
</tr>
<tr>
<td class="row-head">11</td>
<td class="table-date">00 40</td>
<td class="row-head">20</td>
<td class="table-date">20</td>
</tr>
<tr>
<td class="row-head">12</td>
<td class="table-date">20</td>
<td class="row-head">21</td>
<td class="table-date">00 40</td>
</tr>
<tr>
<td class="row-head">13</td>
<td class="table-date">00 40</td>
<td class="row-head">22</td>
<td class="table-date">20</td>
</tr>
<tr>
<td class="row-head">14</td>
<td class="table-date">20</td>
<td class="table-date"> </td>
<td class="table-date"> </td>
</tr>
</table>
</div>
</div>
</div>
<div>
<div class="logo-wrapp">
<img src="img/big_logo.png" class="big_logo_size">
</div>
</div>
<!-- <div id="now" display="none"></div> -->
<script src="./timetable_list.js"></script>
<script src="./index.js"></script>
<!-- <script src="./cache.js?p=(new Date()).getTime()"></script> -->
</body>
</html>