From 7a3739335692eddcbc84685d8047ccc319ce19f0 Mon Sep 17 00:00:00 2001 From: ars Date: Tue, 6 Oct 2020 20:26:08 +0100 Subject: Various fixes, cleanup, etc. Add highlighting for routes which only run on a Friday --- index.php | 48 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) (limited to 'index.php') diff --git a/index.php b/index.php index 90a58f3..d0103da 100644 --- a/index.php +++ b/index.php @@ -9,7 +9,13 @@ table { border-collapse: collapse; } + tr:nth-child(even) {background-color: #f2f2f2;} + +.frionly { + background-color: #039DFF; +} + @@ -17,8 +23,13 @@ tr:nth-child(even) {background-color: #f2f2f2;} console.log('Debug Objects: " . $output . "' );"; +} ini_set('display_errors', 1); error_reporting(~0); @@ -49,6 +60,11 @@ function getData($type, $route, $direction, $day) { } } +// function to $stopList by $stopList['order'] using usort +function cmp($a, $b) { + return $a['order'] - $b['order']; +} + $servUpdates = getData('service', false, false, false); if (isset($_GET['route'])) { @@ -71,6 +87,10 @@ if (isset($_GET['route'])) { echo $update . '
'; } } + + //print friday only gmp_legend + echo '
Friday Only

'; + // print timetables foreach ($days as $day) { if ($schedule['schedule'][$day] == 'true') { @@ -88,30 +108,30 @@ if (isset($_GET['route'])) { default: break; } - // function to $stopList by $stopList['order'] using usort - function cmp($a, $b) { - return $a['order'] - $b['order']; - } + foreach ($directions as $direction) { if ($schedule['directions'][$direction] == 'true') { $stopList = getData('stoplist', $route, $direction, false); // usort to sort stoplist usort($stopList,"cmp"); + $trips = getData('trips', $route, $direction, $day); // print timetable info while setting display friendly case for directions // TODO: add linebreaks between end of table and next table title - echo '


' . ucfirst($direction) . ' | ' . $displayDay . ''; + echo '

' . ucfirst($direction) . ' | ' . $displayDay . '

'; echo '
'; - $trips = getData('trips', $route, $direction, $day); - // TODO: must be a more efficient way to search for $rowStop['stop_name'] in $trip? // search for $stopList['stop_name'] in each trip and print time in row on table foreach ($stopList as $rowStop) { - // TODO: don't use $rowStop if it doesn't appear in $trip echo ''; foreach ($trips as $trip) { $found=False; foreach ($trip['stops'] as $stop) { if ($stop['stop_name'] == $rowStop['stop_name']) { - echo ''; + // check if bus runs on friday only by checking another day (in this case thursday) and apply custom color to cells + if (($day == 'mon_fri') && ($trip['days_of_operation']['mon'] == False)) { + echo ''; + } else { + echo ''; + } $found=True; } } @@ -122,7 +142,7 @@ if (isset($_GET['route'])) { } echo ''; } - echo '
' . $rowStop['stop_name'] . '' . $stop['departure_time'] . '' . $stop['departure_time'] . '' . $stop['departure_time'] . '


'; + echo ''; } } } @@ -132,7 +152,7 @@ if (isset($_GET['route'])) { else { $routes = getData('routes', false, false, false); $meta = getData('meta', false, false, false); - if ($meta['from'] = "-- --- ----") { + if ($meta['from'] == '-- --- ----') { echo '

' . $meta['name']. '

'; } else { echo '

' . $meta['name']. ' | ' . $meta['from'] . ' - ' . $meta['to'] . '

'; @@ -141,7 +161,7 @@ else { foreach ($servUpdates as $update) { echo $update['content'] . '- Affected Routes: ' . implode(", ",$update['services']) . '

'; } - // TODO: sort routes to print in (alpha)numerical order + // TODO: sort routes to print in alphanumerical order foreach ($routes as $route) { echo '

' . $route['service_number'] . ' - ' . $route['service_name'] . '

'; } -- cgit v1.2.3