Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function openD(id, last) {
- currentId = id;
- lastMessage = last;
- nameInterlocutor = $("#n" + id).html();
- photoInterlocutor = $("#av" + id).attr("src");
- $.post("/openD", {id: id}, dialog);
- timer = setInterval(function() {
- if(!bysy) {
- getMessage();
- }
- }, 3000);
- }
- function getMessage() {
- $.post("/getMessage", {userId: currentId, messageId: lastMessage}, displayMessage);
- }
- function displayMessage(data) {
- bysy = true;
- var a = JSON.parse(data);
- if(data.length > 0) {
- var chat = $("#chat");
- $.each(a, function() {
- alert(this.text);
- $("#chat").append('<div class="message me">' +
- '<img src="' + photoInterlocutor + '" />' +
- '<div><p><strong>' + nameInterlocutor + ' : </strong>' + this.text + '<br/>' + messageDate.toLocaleDateString("ru", {
- hour : "numeric",
- minute : "numeric"
- }) + '</p></div>' +
- '</div>');
- lastMessage = this.id;
- });
- };
- bysy = false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement