var transito = angular.module('transito',[]);
var TransitoController = function($scope, $http){
	var update = function(){
	$scope.showRoutes = true;
		var p = $http.get("http://transitobh.com.br/device/getRoutes");
		p.success(function(routes ){
			routes = JSON.parse(routes.substring(0,routes.length-1))
			$scope.routes = routes;
		});
	};
	$scope.update = update;
	$scope.showTwits = function(route){
	var p = $http.get("http://transitobh.com.br/device/getRouteInfo/"+route.id);
		p.success(function(route){
			route = JSON.parse(route.substring(0,route.length-1))
			$scope.showRoutes = false;
			document.querySelector('#content_route').innerHTML = route.tws.replace(/style='width:300px;'/g,'style="width:100%;float: right;"');
		});		
	};
	update();
}