Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. <script type="text/javascript">
  2. var last_msg = 0;
  3. var needsDelay = false;
  4.  
  5. function update() {
  6. $.post("shout_box/action.php?chat=1", {
  7. last: last_msg
  8. },
  9. function(data) {
  10. if(data.msg_result == "pruned")
  11. window.location.reload();
  12. last_msg = data.last_msg;
  13. if(last_msg == 1)
  14. $( "div#post-result" ).empty();
  15. $("div#post-result").append(data.msg_value);
  16. $("#chat-1").animate({ scrollTop: $('#chat-1').prop("scrollHeight")}, 1000);
  17. },"json"
  18. );
  19. setTimeout('update()', 5000);
  20. }
  21. function enableMe()
  22. {
  23. $("#button-send").removeClass("disabled");
  24. }
  25. $(document).keypress(function(e) {
  26. if(e.which == 13) {
  27. if(!needsDelay)
  28. {
  29. needsDelay = true;
  30. setTimeout("needsDelay = false", 4000);
  31. $.post("shout_box/action.php?chat=1", {
  32. chat: $("#message").val(),
  33. last: last_msg
  34. },
  35. function(data) {
  36. if(data.msg_result == "pruned")
  37. window.location.reload();
  38. $("div#post-result").append(data.msg_value);
  39. last_msg = data.last_msg;
  40. $("#chat-1").animate({ scrollTop: $('#chat-1').prop("scrollHeight")}, 1000);
  41. $("#message").val("");
  42. },"json"
  43. );
  44. $("#button-send").addClass("disabled");
  45. setTimeout('enableMe()', 4000);
  46. }
  47. }
  48. });
  49. $(document).ready(
  50. function() {
  51. update();
  52. $("#button-send").click(
  53. function() {
  54. $.post("shout_box/action.php?chat=1", {
  55. chat: $("#message").val(),
  56. last: last_msg
  57. },
  58. function(data) {
  59. if(data.msg_result == "pruned")
  60. window.location.reload();
  61. $("div#post-result").append(data.msg_value);
  62. last_msg = data.last_msg;
  63. $("#chat-1").animate({ scrollTop: $('#chat-1').prop("scrollHeight")}, 1000);
  64. $("#message").val("");
  65. },"json"
  66. );
  67. $("#button-send").addClass("disabled");
  68. setTimeout('enableMe()', 4000);
  69. }
  70. );
  71. });
  72.  
  73. $(document).ready(function() {
  74. App.init();
  75. });
  76. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement