Advertisement
benshepherd

Untitled

Jan 9th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. var chatbox = {
  2.  
  3. // Ajax URLs
  4. listenURL: null,
  5. sendURL: null,
  6.  
  7. // Current site
  8. // Used to return chat for a certain game site
  9. // Gets different chat depending on the game
  10. game: null,
  11.  
  12. // Logged in status
  13. auth: false,
  14.  
  15. // DOM
  16. $chatbox: $('.chatbox'),
  17. $input: chatbox.$chatbox.find('.input input'),
  18. $box: chatbox.$chatbox.find('.inner'),
  19.  
  20. setListenUrl: function(url) {
  21. chatbox.listenURL = url;
  22. },
  23. setSendURL: function(url) {
  24. chatbox.sendURL = url
  25. },
  26. setGame: function(game) {
  27. chatbox.game = game;
  28. },
  29. setAuth: function(auth) {
  30. chatbox.auth = auth;
  31. },
  32.  
  33. // Setup chat feature
  34. init: function()
  35. {
  36. setInterval(chatbox.listen, 1000);
  37. },
  38.  
  39. // listen for new chats
  40. listen: function()
  41. {
  42. $.getJSON(chatbox.listenUR + '?game=' + chatbox.game, function(response) {
  43. console.table(response);
  44.  
  45. });
  46. },
  47.  
  48. // send chat
  49. send: function()
  50. {
  51.  
  52. },
  53.  
  54. addMessage: function(author, message)
  55. {
  56. var $msg = $('<div class="message"></div>');
  57. var $p = $('<p><span class="author">'+author+'</span>' + message + '</p>');
  58.  
  59. $p.appendTo($msg);
  60.  
  61. $inner.append( $msg.html() );
  62.  
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement