1
0

main.js 1.6 KB

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