ChatClient.controller('RoomsController', 
function ($scope, $location, $rootScope, $routeParams, socket) {
	// TODO: Query chat server for active rooms
	$scope.currentUser = $routeParams.user;
	//ENTER has the same function as the button "Create"
	$(window).keypress(function(e){
			if(e.keyCode == 13){
				$scope.createNewRoom();
			}
		});
	
	$scope.errorMessage = '';
	$scope.rooms = ['Room 1','Room 2','Room 3','Room 4','Room 5'];
	$scope.createNewRoom = function() {
		$scope.newRoom = {
			room : undefined,
			pass : undefined
		};
		socket.emit('joinroom', $scope.newRoom, function (success, reason) {
			$scope.newRoom.room = $scope.roomName;
			if (!success) {
				$scope.errorMessage = reason;
			} else {
				$location.path('/room/' + $routeParams.user + '/' + $scope.newRoom.room);
			}

		});
	};

	// socket.on('rooms', function () {
	// 	socket.emit('roomlist', $scope.rooms, function (availableRooms) {
	// 		console.log("inni rooms socket");

	// 		$scope.$apply(function(){
	// 			if (availableRooms) {
	// 				console.log(availableRooms);
	// 				$scope.rooms = availableRooms;
	// 			} else {
	// 				console.log("no rooms");
	// 				$scope.errorMessage = "There are no available rooms";
	// 			}
	// 		});
	// 	});
	// });
	// $scope.rooms = ['Room 1','Room 2','Room 3','Room 4','Room 5'];
});
@@ -742,29 +742,30 @@
 om/' + $
-routeParams.u
+scope.currentU
 ser + '/
@@ -808,19 +808,16 @@
 ;%0A%09%7D;%0A%0A%09
-// 
 socket.o
@@ -842,19 +842,16 @@
 n () %7B%0A%09
-// 
 %09socket.
@@ -910,19 +910,16 @@
 oms) %7B%0A%09
-// 
 %09%09consol
@@ -948,19 +948,16 @@
 et%22);%0A%0A%09
-// 
 %09%09$scope
@@ -977,19 +977,16 @@
 ion()%7B%0A%09
-// 
 %09%09%09if (a
@@ -999,27 +999,24 @@
 leRooms) %7B%0A%09
-// 
 %09%09%09%09console.
@@ -1033,27 +1033,24 @@
 bleRooms);%0A%09
-// 
 %09%09%09%09$scope.r
@@ -1073,19 +1073,16 @@
 Rooms;%0A%09
-// 
 %09%09%09%7D els
@@ -1086,19 +1086,16 @@
 else %7B%0A%09
-// 
 %09%09%09%09cons
@@ -1116,19 +1116,16 @@
 oms%22);%0A%09
-// 
 %09%09%09%09$sco
@@ -1179,39 +1179,27 @@
 %22;%0A%09
-// 
 %09%09%09%7D%0A%09
-// 
 %09%09%7D);%0A%09
-// 
 %09%7D);%0A%09
-// 
 %7D);%0A

use .currentUser insted of .user