--- a/stop.php +++ b/stop.php @@ -43,16 +43,12 @@ } $stop = $stops[0]; $stopid = $stops[0]["stop_id"]; - $stopLinks.= "Individual stop pages: "; + $stopLinks.= "Individual stop pages: <br>"; foreach ($stops as $key => $sub_stop) { - // $stopNames[$key] = $sub_stop[1] . ' Stop #' . ($key + 1); - if (strpos($stop["stop_name"], "Station")) { - $stopNames[$key] = 'Platform ' . ($key + 1); - $stopLinks.= '<a href="stop.php?stopid=' . $sub_stop["stop_id"] . '&stopcode=' . $sub_stop["stop_code"] . '">' . $sub_stop["stop_name"] . '</a> '; - } else { - $stopNames[$key] = '#' . ($key + 1); - $stopLinks.= '<a href="stop.php?stopid=' . $sub_stop["stop_id"] . '&stopcode=' . $sub_stop["stop_code"] . '">' . $sub_stop["stop_name"] . ' Stop #' . ($key + 1) . '</a> '; - } + + $stopNames[$key] = $sub_stop["stop_name"]; + $stopLinks.= '<a href="stop.php?stopid=' . $sub_stop["stop_id"] . '&stopcode=' . $sub_stop["stop_code"] . '">' . $sub_stop["stop_name"] . '</a> '; + $stopPositions[$key] = Array( $sub_stop["stop_lat"], $sub_stop["stop_lon"] @@ -102,12 +98,14 @@ // time settings echo '<div id="settings" data-role="collapsible" data-collapsed="true"> -<h3>Change Time (' . (isset($_SESSION['time']) ? $_SESSION['time'] : "Current Time,") . ' ' . ucwords(service_period()) . ')...</h3> - <form action="' . basename($_SERVER['PHP_SELF']) . "?" . $_SERVER['QUERY_STRING'] . '" method="post"> +<h3>Change Time (' . (isset($_REQUEST['time']) ? $_REQUEST['time'] : "Current Time,") . ' ' . ucwords(service_period()) . ')...</h3> + <form action="' . basename($_SERVER['PHP_SELF']) . '" method="GET"> + <input type="hidden" name="stopid" id="stopid" value="' . (isset($_REQUEST['stopid']) ? $_REQUEST['stopid'] : "") . '"/> + <input type="hidden" name="stopcode" id="stopcode" value="' . (isset($_REQUEST['stopcode']) ? $_REQUEST['stopcode'] : "") . '"/> <div class="ui-body"> <div data-role="fieldcontain"> <label for="time"> Time: </label> - <input type="time" name="time" id="time" value="' . (isset($_SESSION['time']) ? $_SESSION['time'] : date("H:i")) . '"/> + <input type="time" name="time" id="time" value="' . (isset($_REQUEST['time']) ? $_REQUEST['time'] : date("H:i")) . '"/> <a href="#" name="currentTime" id="currentTime" onClick="var d = new Date();' . "$('#time').val(d.getHours() +':'+ (d.getMinutes().toString().length == 1 ? '0'+ d.getMinutes(): d.getMinutes()));" . '">Current Time?</a> </div> <div data-role="fieldcontain"> @@ -132,19 +130,45 @@ } else { $trips = getStopTripsWithTimes($stopid); } +echo "<div class='ui-header' style='overflow: visible; height: 2.5em'>"; +// later/earlier button setup +if (sizeof($trips) == 0) { + $time = isset($_REQUEST['time']) ? strtotime($_REQUEST['time']) : time(); + $earlierTime = $time - (90 * 60); + $laterTime = $time + (90 * 60); +} else { + $earlierTime = strtotime($trips[0]['arrival_time']) - (90 * 60); + $laterTime = strtotime($trips[sizeof($trips) - 1]['arrival_time']) - 60; +} +if (sizeof($stopids) > 0) { + $stopidurl = "stopids=" . implode(",", $stopids); +} else { + $stopidurl = "stopid=$stopid"; +} +if (sizeof($trips) > 10) { + echo '<a href="stop.php?' . $stopidurl . '&service_period=' . service_period() . '&time=' . date("H:i", $laterTime) . '" data-icon="arrow-r" class="ui-btn-right">Later Trips</a>'; +} +echo '<a href="stop.php?' . $stopidurl . '&service_period=' . service_period() . '&time=' . date("H:i", $earlierTime) . '" data-icon="arrow-l" class="ui-btn-left">Earlier Trips</a>'; +echo "</div>"; if (sizeof($trips) == 0) { echo "<li style='text-align: center;'>No trips in the near future.</li>"; } else { foreach ($trips as $trip) { echo '<li>'; - echo '<a href="trip.php?stopid=' . $stopid . '&tripid=' . $trip['trip_id'] . '"><h3>' . $trip['route_short_name'] . " " . $trip['route_long_name'] . "</h3><p>"; + + $destination = getTripDestination($trip['trip_id']); + echo '<a href="trip.php?stopid=' . $stopid . '&tripid=' . $trip['trip_id'] . '"><h3>' . $trip['route_short_name'] . " towards " . $destination['stop_name'] . "</h3><p>"; $viaPoints = viaPointNames($trip['trip_id'], $trip['stop_sequence']); if ($viaPoints != "") echo '<br><span class="viaPoints">Via: ' . $viaPoints . '</span>'; if (sizeof($tripStopNumbers) > 0) { echo '<br><small>Boarding At: '; - foreach ($tripStopNumbers[$trip['trip_id']] as $key) { - echo $stopNames[$key] . ' '; + if (sizeof($tripStopNumbers[$trip['trip_id']]) == sizeof($stopids)) { + echo "All Stops"; + } else { + foreach ($tripStopNumbers[$trip['trip_id']] as $key) { + echo $stopNames[$key] . ', '; + } } echo '</small>'; }