Refactored javascript to use chatViewModel.