Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. function openD(id, last) {
  2. currentId = id;
  3. lastMessage = last;
  4. nameInterlocutor = $("#n" + id).html();
  5. photoInterlocutor = $("#av" + id).attr("src");
  6. $.post("/openD", {id: id}, dialog);
  7. timer = setInterval(function() {
  8. if(!bysy) {
  9. getMessage();
  10. }
  11. }, 3000);
  12. }
  13. function getMessage() {
  14. $.post("/getMessage", {userId: currentId, messageId: lastMessage}, displayMessage);
  15. }
  16.  
  17. function displayMessage(data) {
  18. bysy = true;
  19. var a = JSON.parse(data);
  20. if(data.length > 0) {
  21. var chat = $("#chat");
  22. $.each(a, function() {
  23. alert(this.text);
  24. $("#chat").append('<div class="message me">' +
  25. '<img src="' + photoInterlocutor + '" />' +
  26. '<div><p><strong>' + nameInterlocutor + ' : </strong>' + this.text + '<br/>' + messageDate.toLocaleDateString("ru", {
  27. hour : "numeric",
  28. minute : "numeric"
  29. }) + '</p></div>' +
  30. '</div>');
  31. lastMessage = this.id;
  32. });
  33. };
  34. bysy = false;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement