1
0

main.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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, Connection) {
  25. $scope.service = Connection;
  26. }
  27. function ChatCtrl($scope, Chat, Connection) {
  28. $scope.service = Connection;
  29. $scope.chat = Chat;
  30. $scope.onType = function(event) {
  31. if(event.keyCode == 13) {
  32. Chat.send($scope.text);
  33. $scope.text = '';
  34. event.originalEvent.preventDefault();
  35. }
  36. }
  37. }
  38. function GameCtrl($scope, Taboo) {
  39. $scope.game = Taboo;
  40. }
  41. function ContributeCtrl($scope, $http, $timeout) {
  42. $scope.submitting = false;
  43. function init() {
  44. $scope.card = {
  45. word: '',
  46. taboos: []
  47. };
  48. }
  49. $scope.submit = function() {
  50. if($scope.submitting) return;
  51. $scope.submitting = true;
  52. $http.post(jsRoutes.controllers.Cards.add().url, $scope.card)
  53. .then(function() {
  54. $scope.submitting = false;
  55. $scope.thanks = true;
  56. $timeout(function() {
  57. $scope.thanks = false;
  58. }, 3000);
  59. init();
  60. $('#inputWord').focus();
  61. });
  62. }
  63. init();
  64. }