Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
@rposbo : UNOFFICIAL Mobile TFL Bus Countdown Board
<meta name="viewport" content="width=320" />
<title>@rposbo : UNOFFICIAL Mobile TFL Bus Countdown Board</title>
body {font-family:calibri; font-size:12px; width:auto; max-width:100%;}
#disclaimer {font-size:10px;}
#disclaimer img {float:left;}
#busListing {display:block;}
a:visited {color:blue;}
ul {list-style-type: none;padding: 0;margin: 0;cursor:auto;}
li{background-image: url(bus.jpg);background-repeat: no-repeat;background-position: 0 .4em;padding: 5px 0 5px 20px;margin: .4em 0;}
.time {margin-right:1em;}
<script language="javascript" type="text/javascript" src=""></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
// get lat long
if (navigator.geolocation){
navigator.geolocation.getCurrentPosition(function (position) {
} else {
alert('could not get your location');
function getStopListingForLocation(lat, lng){
var swLat, swLng, neLat, neLng;
swLat = lat - 0.01;
swLng = lng - 0.01;
neLat = lat + 0.01;
neLng = lng + 0.01;
var endpoint = '' + swLat + '/swLng/' + swLng + '/neLat/' + neLat + '/neLng/' + neLng + '/';
type: 'POST',
url: 'Proxy.asmx/getMeTheDataFrom',
data: "{'here':'"+endpoint+"'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) { displayStopListing(data.d); }
function displayStopListing(stopListingData){
var data = $.parseJSON(stopListingData);
$.each(data.markers, function(i,item){
.text( + ' (stop ' + item.stopIndicator + ') to ' + item.towards)
.attr("onclick", "getBusListingForStop(" + + ")")
.attr("class", "stopListing")
function getBusListingForStop(stopId){
var endpoint = '' + stopId + '/';
$("#" + stopId).attr("onclick","");
type: 'POST',
url: 'Proxy.asmx/getMeTheDataFrom',
data: "{'here':'"+endpoint+"'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) { displayBusListing(data.d, stopId); }
function displayBusListing(busListingData, stopId){
var data = $.parseJSON(busListingData);
$("<h2 />").text("Buses Due").appendTo("#" + stopId);
$.each(data.arrivals, function(i,item){
.attr("class", "busListing time")
.appendTo("#" + stopId);
.text(item.routeName + ' to ' + item.destination)
.attr("class", "busListing info")
.appendTo("#" + stopId);
.appendTo("#" + stopId);
<div id="hello">Using the extremely handy TFL bus countdown thingy, but made for mobiles by <a href="">@rposbo</a></div>
<div id="busListing"></div>
<h1>Bus Stops Near You (tap one)</h1>
<ul id="stopListing"></ul>
<div id="disclaimer"> All of the data is coming from the TFL website. I am not a TFL employee and this site is in no way endorsed by TFL. The functionality of this site is in no way guaranteed and should TFL change their site at all, this one will break! This page may or may not work on your device, and it curently relies on you device's geolocation (location sharing) functionality. I'm just making something I think might be handy for me, and you can now have a go too!</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.