main.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. angular.module('taboo', ['chatServices', 'tabooServices'])
  2. function partial(template) {
  3. return jsRoutes.controllers.Assets.at('partials/'+template+'.html').url;
  4. }
  5. function ViewCtrl($scope, Connection) {
  6. $scope.service = Connection;
  7. $scope.partial = partial;
  8. $scope.view = 'about';
  9. $scope.nav = [
  10. {partial: 'about', name: 'About'},
  11. {partial: 'chatRoom', name: 'Chat'},
  12. {partial: 'contribute', name: 'Contribute'}
  13. ];
  14. $scope.setView = function(p) {
  15. $scope.view = p;
  16. }
  17. $scope.$on('ws:connected', function() {
  18. $scope.view = 'chatRoom';
  19. });
  20. }
  21. function LoginCtrl($scope, Connection) {
  22. $scope.service = Connection;
  23. }
  24. function ChatCtrl($scope, Chat) {
  25. $scope.service = Chat;
  26. $scope.onType = function(event) {
  27. if(event.keyCode == 13) {
  28. Chat.send($scope.text);
  29. $scope.text = '';
  30. event.originalEvent.preventDefault();
  31. }
  32. }
  33. }
  34. function GameCtrl($scope, Taboo) {
  35. $scope.game = Taboo;
  36. }
  37. function ContributeCtrl($scope, $http) {
  38. function init() {
  39. $scope.card = {
  40. word: '',
  41. taboos: []
  42. };
  43. }
  44. $scope.submit = function() {
  45. $http.post(jsRoutes.controllers.Cards.add().url, $scope.card)
  46. .then(function() {
  47. alert("Thank you for your contribution!");
  48. init();
  49. });
  50. }
  51. init();
  52. }