Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. <script type="text/javascript">
  2. $(document).ready(function(){
  3. $('#text').keypress(function(e){
  4. var cnt = 0;
  5. if (e.which == 13)
  6. {
  7. $('#submt_{{ user_to_username }}').click();
  8. }
  9. });
  10. });
  11. </script>
  12. <script type="text/javascript">
  13. $(document).ready(function(){
  14. $('#scroll-able').scrollTop( 100000000 );
  15. $('#submt_{{ user_to_username }}').click(function(){
  16. var message = $("#text").val();
  17. $.ajax({
  18. type: "GET",
  19. url: "/im/send_message/",
  20. data: { text_message : message , user_name : "{{ user_to_username }}" }
  21. })
  22. .done(function(data) {
  23. //$('#messages').append(data);
  24. $('#scroll-able').scrollTop( 100000000 );
  25. $("#text").val("");
  26. $('#text').focus();
  27. });
  28. });
  29. })
  30. </script>
  31. <script type="text/javascript">
  32. function show()
  33. {
  34. a = []
  35. a = $("*").html()
  36. var count = 0;
  37. for (var i=0; i<a.length - 7;i++)
  38. {
  39. if (a[i] == 'm' &&
  40. a[i + 1] == 's' &&
  41. a[i + 2] == 'g' &&
  42. a[i + 3] == '_' &&
  43. a[i + 4] == 'h' &&
  44. a[i + 5] == 'e' &&
  45. a[i + 6] == 'r' &&
  46. a[i + 7] == 'e'
  47. )
  48. count += 1;
  49. }
  50. console.log(count)
  51. $.ajax({
  52. type: "GET",
  53. url: "/im/check_new/",
  54. data: { count : count , user_to : "{{ user_to_username }}" },
  55. success: function(data){
  56. if (data != "-1")
  57. {
  58. $("#messages").append(data);
  59. $('#scroll-able').scrollTop( 100000000 );
  60. }
  61. }
  62. });
  63. }
  64.  
  65. $(document).ready(function(){
  66. $('#scroll-able').scrollTop( 100000000 );
  67. show();
  68. setInterval('show()', 1000);
  69. });
  70. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement