Add initial between point adding prototype
[bus.git] / busui / stopList.php
blob:a/busui/stopList.php -> blob:b/busui/stopList.php
<div id="get"> <?php
<div class="toolbar"> include('common.inc.php');
<h1>GET Example</h1> include_header("Stops");
<a class="back" href="#">AJAX</a> echo'
</div> <div data-role="navbar">
<div class="info"> <ul>
This page was loaded via AJAX. <li><a href="stopList.php">Timing Points</a></li>
</div> <li><a href="stopList.php?allstops=yes">All Stops</a></li>
<ul class="rounded"> </ul>
<li><a href="#livetest">Test live events</a></li> </div>
</ul> ';
</div>  
<div id="livetest"> echo '<div class="noscriptnav"> Go to letter: ';
<div class="toolbar"> foreach(range('A','Z') as $letter)
<h1>Events test</h1> {
<a class="back" href="#">AJAX</a> echo "<a href=\"#$letter\">$letter</a>&nbsp;";
<a class="button goback" href="#home">Home</a> }
</div> echo "</div>
<div class="info"> <script>
This is a test of live events. $('.noscriptnav').hide();
</div> </script>";
</div> echo ' <ul data-role="listview" data-filter="true" data-inset="true" >';
  $url = $APIurl."/json/timingpoints";
  if ($_REQUEST['allstops']) $url = $APIurl."/json/stops";
  if ($_REQUEST['lat'] && $_REQUEST['lon']) $url = $APIurl."/json/neareststops?lat={$_REQUEST['lat']}&lon={$_REQUEST['lon']}&limit=15";
  $contents = json_decode(getPage($url));
  debug(print_r($contents,true));
  foreach ($contents as $key => $row) {
  $stopName[$key] = $row[1];
  }
   
  // Sort the stops by name
  array_multisort($stopName, SORT_ASC, $contents);
   
  $firstletter = "";
  foreach ($contents as $row)
  {
  if (substr($row[1],0,1) != $firstletter){
  echo "<a name=$firstletter></a>";
  $firstletter = substr($row[1],0,1);
  }
  echo '<li><a href="stop.php?stopid='.$row[0].'">'.bracketsMeanNewLine($row[1]).'</a></li>';
  }
  echo '</ul>';
   
  include_footer();
  ?>