|
|
|
@ -61,16 +61,27 @@
|
|
|
|
|
|
|
|
|
|
<title>停留所のNexTrip情報</title>
|
|
|
|
|
|
|
|
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
|
|
|
|
|
<style>
|
|
|
|
|
main {
|
|
|
|
|
max-width: 768px;
|
|
|
|
|
margin-bottom: 5rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h2 {
|
|
|
|
|
border-bottom: 1px solid lightgray;
|
|
|
|
|
* { box-sizing: border-box; }
|
|
|
|
|
@media screen and (min-width: 780px) {
|
|
|
|
|
body { max-width: 768px; margin: 0 auto; }
|
|
|
|
|
}
|
|
|
|
|
h1, h2, h3 { margin-bottom: 0.5rem; }
|
|
|
|
|
h2 { border-bottom: 1px solid gray; margin-bottom: 0.5rem; }
|
|
|
|
|
hr { border: none; border-top: 1px solid gray; }
|
|
|
|
|
.alert { margin-left: 0; padding-left: 1rem; border-left: 3px solid black; }
|
|
|
|
|
.alert.success { border-color: lime; }
|
|
|
|
|
.alert.info { border-color: blue; }
|
|
|
|
|
.alert.warning { border-color: gold; }
|
|
|
|
|
.alert.danger { border-color: red; }
|
|
|
|
|
.btn.danger, span.danger { color: red; }
|
|
|
|
|
.btn.warning, span.warning { color: gold; }
|
|
|
|
|
.unstyled-list { list-style: none; padding-left: 0; }
|
|
|
|
|
.inline-list { list-style: none; margin-top: 0; }
|
|
|
|
|
.inline-list li { display: inline-block; }
|
|
|
|
|
.grid-wrapper { display: grid; grid-template-columns: repeat(auto-fill, 100px); }
|
|
|
|
|
.d-flex { display: flex; }
|
|
|
|
|
.flex-fill { flex: 1 1 auto; }
|
|
|
|
|
</style>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
@ -105,18 +116,17 @@
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
<header>
|
|
|
|
|
<nav class="navbar navbar-expand-sm navbar-light bg-light">
|
|
|
|
|
<div class="container-fluid">
|
|
|
|
|
<a class="navbar-brand" href="<?php echo $_SERVER['PHP_SELF']; ?>">停留所のNexTrip情報</a>
|
|
|
|
|
<ul class="navbar-nav">
|
|
|
|
|
<li class="nav-item"><a class="nav-link" href="?key-menu"><?php echo empty($key) ? 'キー' : ($shortKey . 'さん'); ?></a></li>
|
|
|
|
|
<li class="nav-item"><a class="nav-link" href="?source">ソース</a></li>
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
<nav>
|
|
|
|
|
<h1>停留所のNexTrip情報</h1>
|
|
|
|
|
<ul class="inline-list">
|
|
|
|
|
<li><?php if(!isset($stop) && !$keyMenu) echo '<b>'; ?><a href="<?php echo $_SERVER['PHP_SELF']; ?>">ホーム</a><?php if(!isset($stop) && !$keyMenu) echo '</b>'; ?></li>
|
|
|
|
|
<li><?php if($keyMenu) echo '<b>'; ?><a href="?key-menu">キー設定</a><?php if($keyMenu) echo '</b>'; ?></li>
|
|
|
|
|
<li><a href="?source">ソース</a></li>
|
|
|
|
|
</ul>
|
|
|
|
|
</nav>
|
|
|
|
|
</header>
|
|
|
|
|
|
|
|
|
|
<main class="mt-3 container-fluid">
|
|
|
|
|
<main>
|
|
|
|
|
<?php
|
|
|
|
|
date_default_timezone_set('America/Chicago');
|
|
|
|
|
|
|
|
|
@ -141,7 +151,7 @@
|
|
|
|
|
$stop_name = str_replace(' & ', 'と', $json->stops[0]->description);
|
|
|
|
|
echo "<h2>停留所{$stop} – $stop_name</h2>";
|
|
|
|
|
|
|
|
|
|
echo '<div class="row row-cols-2 row-cols-sm-4 row-cols-md-6">';
|
|
|
|
|
echo '<div class="grid-wrapper">';
|
|
|
|
|
foreach($json->departures as $bus) {
|
|
|
|
|
if($bus->actual) {
|
|
|
|
|
$time = str_replace(" Min", "分", $bus->departure_text);
|
|
|
|
@ -154,30 +164,30 @@
|
|
|
|
|
$warnClass = "";
|
|
|
|
|
if($bus->schedule_relationship == "Skipped") {
|
|
|
|
|
$warn = "キャンセル";
|
|
|
|
|
$warnClass = 'text-danger';
|
|
|
|
|
$warnClass = 'danger';
|
|
|
|
|
} else if($bus->schedule_relationship == "NoData") {
|
|
|
|
|
$warn = "データなし";
|
|
|
|
|
$warnClass = 'text-warning';
|
|
|
|
|
$warnClass = 'warning';
|
|
|
|
|
} else if($bus->schedule_relationship != "Scheduled") {
|
|
|
|
|
$warn = $bus->schedule_relationship;
|
|
|
|
|
$warnClass = 'text-warning';
|
|
|
|
|
$warnClass = 'warning';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo "<div class=\"col\"><p>";
|
|
|
|
|
echo "<p>";
|
|
|
|
|
$route_name = str_replace(' Line', '線', $bus->route_short_name) . $bus->terminal;
|
|
|
|
|
echo "<strong>{$route_name}({$directions[$bus->direction_text]})</strong>";
|
|
|
|
|
echo "<br><span class=\"$warnClass\">$time";
|
|
|
|
|
if($warn)
|
|
|
|
|
echo "<br>$warn";
|
|
|
|
|
echo '</span></p></div>';
|
|
|
|
|
echo '</span></p>';
|
|
|
|
|
}
|
|
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
|
|
if($json->alerts)
|
|
|
|
|
echo '<h3>アラート</h3>';
|
|
|
|
|
foreach($json->alerts as $alert) {
|
|
|
|
|
$alertClass = $alert->stop_closed ? "alert-danger" : "alert-warning";
|
|
|
|
|
echo "<div lang=\"en\" class=\"alert $alertClass\">$alert->alert_text</div>";
|
|
|
|
|
$alertClass = $alert->stop_closed ? "danger" : "warning";
|
|
|
|
|
echo "<blockquote lang=\"en\" class=\"alert $alertClass\">$alert->alert_text</blockquote>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($key)) {
|
|
|
|
@ -188,11 +198,9 @@
|
|
|
|
|
|
|
|
|
|
echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">';
|
|
|
|
|
echo '<input type="hidden" name="fav-set" value="' . $stop . '">';
|
|
|
|
|
echo '<div class="input-group">';
|
|
|
|
|
echo '<label for="desc" class="input-group-text">お気に入り</label>';
|
|
|
|
|
echo '<input type="text" id="desc" name="desc" class="form-control" placeholder="説明" value="' . $row['description'] . '" required>';
|
|
|
|
|
echo '<input type="submit" class="btn btn-outline-secondary" value="' . ($row ? '更新' : '追加') . '">';
|
|
|
|
|
echo '</div>';
|
|
|
|
|
echo '<h3><label for="desc">お気に入り</label></h3>';
|
|
|
|
|
echo '<input type="text" id="desc" name="desc" placeholder="説明" value="' . $row['description'] . '" required>';
|
|
|
|
|
echo '<input type="submit" value="' . ($row ? '更新' : '追加') . '">';
|
|
|
|
|
echo '</form>';
|
|
|
|
|
|
|
|
|
|
// 亭の古い行を削除
|
|
|
|
@ -209,25 +217,21 @@
|
|
|
|
|
$row = pg_fetch_array($res);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
echo "<div class=\"alert alert-danger\">{$stop}は無効な停留所です。</div>";
|
|
|
|
|
echo "<blockquote class=\"alert danger\">{$stop}は無効な停留所です。</blockquote>";
|
|
|
|
|
}
|
|
|
|
|
} else if($keyMenu) { //キーを設定
|
|
|
|
|
echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">';
|
|
|
|
|
echo '<div class="input-group mb-3">';
|
|
|
|
|
echo '<label for="key-set" class="input-group-text">キー</label>';
|
|
|
|
|
echo '<input type="password" id="key-set" name="key-set" class="form-control" value="' . $_COOKIE['key'] . '">';
|
|
|
|
|
echo '<input type="submit" class="btn btn-outline-secondary" value="設定">';
|
|
|
|
|
echo '</div>';
|
|
|
|
|
echo '<h2><label for="key-set">キー設定</label></h2>';
|
|
|
|
|
echo '<input type="password" id="key-set" name="key-set" value="' . $_COOKIE['key'] . '">';
|
|
|
|
|
echo '<input type="submit" value="設定">';
|
|
|
|
|
echo '</form>';
|
|
|
|
|
echo '<p>キーを設定して、お気に入りを使用できます。キーを持つ誰でもあなたのお気に入りを見ることができますので、秘密にしておきましょう。</p>';
|
|
|
|
|
} else { // HPを表示
|
|
|
|
|
// 停留所フォームをプリント
|
|
|
|
|
echo '<form method="get" action="' . $_SERVER['PHP_SELF'] . '">';
|
|
|
|
|
echo '<div class="input-group mb-3">';
|
|
|
|
|
echo '<label for="stop" class="input-group-text">停留所</label>';
|
|
|
|
|
echo '<input type="number" min="0" id="stop" name="stop" class="form-control" placeholder="12345" required>';
|
|
|
|
|
echo '<input type="submit" class="btn btn-outline-secondary" value="検索">';
|
|
|
|
|
echo '</div>';
|
|
|
|
|
echo '<h2><label for="stop">停留所の番号</label></h2>';
|
|
|
|
|
echo '<input type="number" min="0" id="stop" name="stop" placeholder="12345" required>';
|
|
|
|
|
echo '<input type="submit" value="検索">';
|
|
|
|
|
echo '</form>';
|
|
|
|
|
|
|
|
|
|
if(!empty($key)) {
|
|
|
|
@ -240,13 +244,13 @@
|
|
|
|
|
if(!$row) {
|
|
|
|
|
$query = 'INSERT INTO favorites (stop, priority, description, key) VALUES ($1, 0, $2, $3)';
|
|
|
|
|
pg_query_params($query, [$favSet, $desc, $key]);
|
|
|
|
|
echo "<div class=\"alert alert-success\">$favSet – {$desc}は設定しました。</div>";
|
|
|
|
|
echo "<blockquote class=\"alert success\">$favSet – {$desc}は設定しました。</blockquote>";
|
|
|
|
|
} else if($desc != $row['description']) {
|
|
|
|
|
$query = 'UPDATE favorites SET description=$1 WHERE favorites.key=$2 AND favorites.fav_id=$3';
|
|
|
|
|
pg_query_params($query, [$desc, $key, $row['fav_id']]);
|
|
|
|
|
echo "<div class=\"alert alert-success\">$favSet – {$desc}は更新しました。</div>";
|
|
|
|
|
echo "<blockquote class=\"alert success\">$favSet – {$desc}は更新しました。</blockquote>";
|
|
|
|
|
} else {
|
|
|
|
|
echo "<div class=\"alert alert-info\">{$favSet}はすでに設定しました。</div>";
|
|
|
|
|
echo "<blockquote class=\"alert info\">{$favSet}はすでに設定しました。</blockquote>";
|
|
|
|
|
}
|
|
|
|
|
} else if(isset($favRemove)) { // お気に入りから削除
|
|
|
|
|
$query = 'SELECT stop, description FROM favorites WHERE favorites.key=$1 AND favorites.fav_id=$2';
|
|
|
|
@ -257,9 +261,9 @@
|
|
|
|
|
$desc = $row['description'];
|
|
|
|
|
$query = 'DELETE FROM favorites WHERE favorites.fav_id=$1';
|
|
|
|
|
pg_query_params($query, [$favRemove]);
|
|
|
|
|
echo "<div class=\"alert alert-danger\">$stop – {$desc}は削除しました。</div>";
|
|
|
|
|
echo "<blockquote class=\"alert danger\">$stop – {$desc}は削除しました。</blockquote>";
|
|
|
|
|
} else {
|
|
|
|
|
echo "<div class=\"alert alert-warning\">亭はお気に入りにありません。</div>";
|
|
|
|
|
echo "<blockquote class=\"alert warning\">亭はお気に入りにありません。</blockquote>";
|
|
|
|
|
}
|
|
|
|
|
} else if(isset($favUp)) { // お気に入りを上げる
|
|
|
|
|
$query = 'SELECT stop, description, priority FROM favorites WHERE favorites.key=$1 AND favorites.fav_id=$2';
|
|
|
|
@ -271,9 +275,9 @@
|
|
|
|
|
$priority = $row['priority'] + 1;
|
|
|
|
|
$query = 'UPDATE favorites SET priority=priority+1 WHERE favorites.fav_id=$1';
|
|
|
|
|
pg_query_params($query, [$favUp]) or die('Query failed: ' . pg_last_error());
|
|
|
|
|
echo "<div class=\"alert alert-success\">$stop – {$desc}は{$priority}に上げました。</div>";
|
|
|
|
|
echo "<blockquote class=\"alert success\">$stop – {$desc}は{$priority}に上げました。</blockquote>";
|
|
|
|
|
} else {
|
|
|
|
|
echo "<div class=\"alert alert-warning\">亭はお気に入りにありません。</div>";
|
|
|
|
|
echo "<blockquote class=\"alert warning\">亭はお気に入りにありません。</blockquote>";
|
|
|
|
|
}
|
|
|
|
|
} else if(isset($favDown)) { // お気に入りを下げる
|
|
|
|
|
$query = 'SELECT stop, description, priority FROM favorites WHERE favorites.key=$1 AND favorites.fav_id=$2';
|
|
|
|
@ -285,15 +289,15 @@
|
|
|
|
|
$priority = $row['priority'] - 1;
|
|
|
|
|
$query = 'UPDATE favorites SET priority=priority-1 WHERE favorites.fav_id=$1';
|
|
|
|
|
pg_query_params($query, [$favDown]) or die('Query failed: ' . pg_last_error());
|
|
|
|
|
echo "<div class=\"alert alert-success\">$stop – {$desc}は{$priority}に下げました。</div>";
|
|
|
|
|
echo "<blockquote class=\"alert success\">$stop – {$desc}は{$priority}に下げました。</blockquote>";
|
|
|
|
|
} else {
|
|
|
|
|
echo "<div class=\"alert alert-warning\">亭はお気に入りにありません。</div>";
|
|
|
|
|
echo "<blockquote class=\"alert warning\">亭はお気に入りにありません。</blockquote>";
|
|
|
|
|
}
|
|
|
|
|
} else if(isset($keySet)) {
|
|
|
|
|
if(!empty($keySet)) {
|
|
|
|
|
echo "<div class=\"alert alert-info\">ようこそ、{$shortKey}さん。</div>";
|
|
|
|
|
echo "<blockquote class=\"alert info\">ようこそ、{$shortKey}さん。</blockquote>";
|
|
|
|
|
} else {
|
|
|
|
|
echo "<div class=\"alert alert-info\">さようなら、{$shortKey}さん。</div>";
|
|
|
|
|
echo "<blockquote class=\"alert info\">さようなら、{$shortKey}さん。</blockquote>";
|
|
|
|
|
}
|
|
|
|
|
} else if(isset($historyRemove)) { // 履歴から削除
|
|
|
|
|
$query = 'SELECT history_id, stop FROM history WHERE history.key=$1 AND history_id=$2';
|
|
|
|
@ -303,9 +307,9 @@
|
|
|
|
|
$stop = $row['stop'];
|
|
|
|
|
$query = 'DELETE FROM history WHERE history_id=$1';
|
|
|
|
|
$res = pg_query_params($query, [$row['history_id']]) or die('Query failed: ' . pg_last_error());
|
|
|
|
|
echo "<div class=\"alert alert-danger\">{$stop}は削除しました。</div>";
|
|
|
|
|
echo "<blockquote class=\"alert danger\">{$stop}は削除しました。</blockquote>";
|
|
|
|
|
} else {
|
|
|
|
|
echo "<div class=\"alert alert-warning\">亭は履歴にありません。</div>";
|
|
|
|
|
echo "<blockquote class=\"alert warning\">亭は履歴にありません。</blockquote>";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -317,18 +321,18 @@
|
|
|
|
|
if(pg_num_rows($res) > 0) {
|
|
|
|
|
echo '<h2>お気に入り</h2>';
|
|
|
|
|
echo '<form action="' . $_SERVER['PHP_SELF'] . '">';
|
|
|
|
|
echo '<ul class="list-unstyled">';
|
|
|
|
|
echo '<ul class="unstyled-list">';
|
|
|
|
|
$priority = -1;
|
|
|
|
|
while($row = pg_fetch_array($res)) {
|
|
|
|
|
if($priority != $row['priority'] && $priority != -1)
|
|
|
|
|
echo '<hr>';
|
|
|
|
|
$priority = $row['priority'];
|
|
|
|
|
|
|
|
|
|
echo '<li class="mb-1 d-flex">';
|
|
|
|
|
echo '<button type="submit" formmethod="get" name="stop" value="' . $row['stop'] . '" class="btn btn-sm btn-secondary flex-fill me-1 text-start">' . $row['stop'] . ' – ' . $row['description'] . '</button>';
|
|
|
|
|
echo '<button type="submit" formmethod="post" name="fav-up" value="' . $row['fav_id'] . '" title="' . $row['stop'] . 'の優先を上げる" aria-label="' . $row['stop'] . 'の優先を上げる" class="btn btn-sm btn-outline-secondary me-1">↑</button>';
|
|
|
|
|
echo '<button type="submit" formmethod="post" name="fav-down" value="' . $row['fav_id'] . '" title="' . $row['stop'] . 'の優先を下げる" aria-label="' . $row['stop'] . 'の優先を下げる" class="btn btn-sm btn-outline-secondary me-1">↓</button>';
|
|
|
|
|
echo '<button type="submit" formmethod="post" name="fav-remove" value="' . $row['fav_id'] . '" title="' . $row['stop'] . 'を削除" aria-label="' . $row['stop'] . 'を削除" class="btn btn-sm btn-danger">×</button>';
|
|
|
|
|
echo '<li class="d-flex">';
|
|
|
|
|
echo '<button type="submit" formmethod="get" name="stop" value="' . $row['stop'] . '" class="flex-fill">' . $row['stop'] . ' – ' . $row['description'] . '</button>';
|
|
|
|
|
echo '<button type="submit" formmethod="post" name="fav-up" value="' . $row['fav_id'] . '" title="' . $row['stop'] . 'の優先を上げる" aria-label="' . $row['stop'] . 'の優先を上げる">↑</button>';
|
|
|
|
|
echo '<button type="submit" formmethod="post" name="fav-down" value="' . $row['fav_id'] . '" title="' . $row['stop'] . 'の優先を下げる" aria-label="' . $row['stop'] . 'の優先を下げる">↓</button>';
|
|
|
|
|
echo '<button type="submit" formmethod="post" name="fav-remove" value="' . $row['fav_id'] . '" title="' . $row['stop'] . 'を削除" aria-label="' . $row['stop'] . 'を削除"class="btn danger">×</button>';
|
|
|
|
|
echo '</li>';
|
|
|
|
|
}
|
|
|
|
|
echo '</ul>';
|
|
|
|
@ -343,18 +347,18 @@
|
|
|
|
|
if(pg_num_rows($res) > 0) {
|
|
|
|
|
echo '<h2>履歴</h2>';
|
|
|
|
|
echo '<form action="' . $_SERVER['PHP_SELF'] . '">';
|
|
|
|
|
echo '<ul class="list-unstyled">';
|
|
|
|
|
echo '<ul class="unstyled-list">';
|
|
|
|
|
while($row = pg_fetch_array($res)) {
|
|
|
|
|
echo '<li class="mb-1 d-flex">';
|
|
|
|
|
echo '<button type="submit" formmethod="get" name="stop" value="' . $row['stop'] . '" class="btn btn-sm btn-secondary flex-fill me-1 text-start">' . $row['stop'] . '</button>';
|
|
|
|
|
echo '<button type="submit" formmethod="post" name="history-remove" value="' . $row['history_id'] . '" title="' . $row['stop'] . 'を削除" aria-label="' . $row['stop'] . 'を削除" class="btn btn-sm btn-danger">×</button>';
|
|
|
|
|
echo '<button type="submit" formmethod="post" name="history-remove" value="' . $row['history_id'] . '" title="' . $row['stop'] . 'を削除" aria-label="' . $row['stop'] . 'を削除" class="btn danger">×</button>';
|
|
|
|
|
echo '</li>';
|
|
|
|
|
}
|
|
|
|
|
echo '</ul>';
|
|
|
|
|
echo '</form>';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
echo '<div class="alert alert-info"><a href="?key-menu">キーを設定する</a>と、お気に入りの停留所を保存できます。既存のお気に入りため、<a href="old.php">古い版</a>も使用可能です。</div>';
|
|
|
|
|
echo '<blockquote class="alert info"><a href="?key-menu">キーを設定する</a>と、お気に入りの停留所を保存できます。既存のお気に入りため、<a href="old.php">古い版</a>も使用可能です。</blockquote>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|