Last active
May 6, 2016 08:07
-
-
Save siren/459db18bf4b128df0555 to your computer and use it in GitHub Desktop.
Locate gtfsId for vehicles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html ng-app="locator"> | |
<head> | |
<title>Vehicle locator</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script> | |
<script> | |
angular.module('locator',[]).controller('Ctrl', | |
function ($scope, $http) { | |
var q = {"query":"query routes{agency (id:\"HSL\") {routes {gtfsId, type, longName,shortName}}}","variables":null} | |
$http.post('http://api.digitransit.fi/routing/v1/routers/finland/index/graphql', q).then(function(data){ | |
$scope.routes = data.data.data.agency.routes; | |
}, console.err); | |
$scope.order = function(predicate) { | |
$scope.reverse = ($scope.predicate === predicate) ? !$scope.reverse : false; | |
$scope.predicate = predicate; | |
} | |
}); | |
</script> | |
</head> | |
<body ng-controller="Ctrl"> | |
<div class="container"> | |
<div class="jumbotron"> | |
<h1>Locate My Vehicle Identifier</h1> | |
<p>Locate gtfsId-identifier for HSL vehicles</p> | |
</div> | |
<div class="panel input-group"> | |
<span class="input-group-addon"><span class="glyphicon glyphicon-search"></span></span> | |
<input type="text" class="form-control" ng-model="search.$"> | |
</div> | |
<table class="table"> | |
<tr> | |
<th ng-click="order('gtfsId')">gtfsId</th> | |
<th ng-click="order('type')">type</td> | |
<th ng-click="order('shortName')">shortName</th> | |
<th ng-click="order('longName')">longName</th> | |
</tr> | |
<tr ng-repeat="route in routes | filter:search:strict | orderBy:predicate:reverse"> | |
<td>{{route.gtfsId}}</td> | |
<td>{{route.type}}</td> | |
<td>{{route.shortName}}</td> | |
<td>{{route.longName}}</td> | |
</tr> | |
</table> | |
<a href="https://gist.github.com/siren/459db18bf4b128df0555">View Source</a> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment