Autocompletion of nicknames in chat works. this commit will require a npm install to fetch new packages

This commit is contained in:
Nick Gordon
2013-11-11 22:32:52 -08:00
parent d802c502b0
commit cd693835ce
6 changed files with 72 additions and 5 deletions

View File

@@ -79,6 +79,32 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Groups', '$http', 'A
}
])
.controller('AutocompleteCtrl', ['$scope', 'Groups', 'User', function ($scope,Groups,User) {
$scope.clearUserlist = function() {
$scope.response = [];
$scope.usernames = [];
}
$scope.addNewUser = function(user) {
if($.inArray(user.user,$scope.usernames) == -1) {
$scope.usernames.push(user.user);
$scope.response.push(user);
}
}
$scope.clearUserlist();
$scope.chatChanged = function(newvalue,oldvalue){
if($scope.group.chat && $scope.group.chat.length > 0){
for(var i = 0; i < $scope.group.chat.length; i++) {
$scope.addNewUser($scope.group.chat[i]);
}
}
}
$scope.$watch('group.chat',$scope.chatChanged);
}])
.controller('ChatCtrl', ['$scope', 'Groups', 'User', function($scope, Groups, User){
$scope._chatMessage = '';
$scope._sending = false;