--- a/busui/tripPlanner.php +++ b/busui/tripPlanner.php @@ -1,6 +1,6 @@ <?php include('common.inc.php'); - include_header("Trip Planner"); + include_header("Trip Planner", true, true); function tripPlanForm($errorMessage = "") { $from = (isset($_REQUEST['from']) ? $_REQUEST['from'] : "Brigalow"); @@ -12,20 +12,29 @@ <div data-role="fieldcontain"> <label for="from">I would like to go from</label> <input type="text" name="from" id="from" value="' . $from . '" /> + <a href="#" style="display:none" name="fromHere" id="fromHere"/>Here?</a> </div> <div data-role="fieldcontain"> <label for="to"> to </label> <input type="text" name="to" id="to" value="' . $to . '" /> + <a href="#" style="display:none" name="toHere" id="toHere"/>Here?</a> </div> <div data-role="fieldcontain"> <label for="date"> on </label> - <input type="text" name="date" id="date" value="' . $date . '" /> + <input type="date" name="date" id="date" value="' . $date . '" /> </div> <div data-role="fieldcontain"> <label for="time"> at </label> - <input type="text" name="time" id="time" value="' . $time . '" /> + <input type="time" name="time" id="time" value="' . $time . '" /> </div> <input type="submit" value="Go!"></form>'; + echo "<script> +$('#toHere').click(function(event) { $('#to').val(getCookie('geolocate')); return false;}); +$('#toHere').show(); +$('#fromHere').click(function(event) { $('#from').val(getCookie('geolocate')); return false;}); +$('#fromHere').show(); + + </script>"; } function processItinerary($itineraryNumber, $itinerary) @@ -86,14 +95,18 @@ $errorMessage .= urlencode($_REQUEST['from']) . " not found.<br>\n"; tripPlanForm($errorMessage); } else { - $url = "http://localhost:8080/opentripplanner-api-webapp/ws/plan?_dc=1290254798856&arriveBy=false&date=" . urlencode($_REQUEST['date']) . "&time=" . urlencode($_REQUEST['time']) . "&mode=TRANSIT%2CWALK&optimize=QUICK&maxWalkDistance=840&wheelchair=false&toPlace=$toPlace&fromPlace=$fromPlace&intermediatePlaces="; + $url = "http://10.1.0.243:5080/opentripplanner-api-webapp/ws/plan?_dc=1290254798856&arriveBy=false&date=" . urlencode($_REQUEST['date']) . "&time=" . urlencode($_REQUEST['time']) . "&mode=TRANSIT%2CWALK&optimize=QUICK&maxWalkDistance=840&wheelchair=false&toPlace=$toPlace&fromPlace=$fromPlace&intermediatePlaces="; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json")); + curl_setopt($ch,CURLOPT_TIMEOUT,5); $page = curl_exec($ch); - curl_close($ch); + + if(curl_errno($ch)) { tripPlanForm("Trip planner temporarily unavailable: ".curl_errno($ch)." ".curl_error($ch));} + else { $tripplan = json_decode($page); + debug(print_r($triplan,true)); echo "<h1> From: {$tripplan->plan->from->name} To: {$tripplan->plan->to->name} </h1>"; echo "<h1> At: {$tripplan->plan->date} </h1>"; @@ -106,10 +119,12 @@ } else { processItinerary(0, $tripplan->plan->itineraries->itinerary); } - + } + curl_close($ch); } } else { tripPlanForm(); } include_footer(); ?> +