var logEvents = angular.module('logEvents', []);

function mainController($scope, $http) {
	$scope.formData = {};

	// when landing on the page, get all events and show them
	$http.get('/api/events')
		.success(function(data) {
			$scope.events = data;

			var locations = [];

			angular.forEach(data, function(value, key) {
				var location = {
					lat: value.GPSlat,
					log: value.GPSlog,
					alt: value.GPSalt
				}
				
				this.push(location);
			}, locations);

			$scope.locations = locations;
		})
		.error(function(data) {
			console.log("Error: " + data);
		});
};

function extractPosition(data, callback) {
	var locations = [];

	data.every(function(element){
		locations += extractPosition(element);
	});
}

@@ -112,67 +112,8 @@
 %7D;%0A%0A
-%09// when landing on the page, get all events and show them%0A
 %09$ht
@@ -357,21 +357,18 @@
 lt%0A%09%09%09%09%7D
+;
 %0A
-%09%09%09%09
 %0A%09%09%09%09thi
@@ -475,155 +475,44 @@
 %0A%09%09%09
-console.log(%22Error: %22 + data);%0A%09%09%7D);%0A%7D;%0A%0Afunction extractPosition(data, callback) %7B%0A%09var locations = %5B%5D;%0A%0A%09data.every(function(element)%7B
+// redirect to 500.html
 %0A%09%09
+%09$
 location
 s +=
@@ -511,42 +511,32 @@
 tion
-s += extractPosition(element
+.url('/500.html'
 );%0A
+%09
 %09%7D);%0A%7D
+;
 %0A

Handle 500 error and removed old unused code