|
|
@ -280,24 +280,31 @@ function dmDataToSnippetItem(dmData, remoteUser) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// format dmdata (returned by getdirectmsgs) to display in conversation thread
|
|
|
|
// format dmdata (returned by getdirectmsgs) to display in conversation thread
|
|
|
|
function dmDataToConversationItem(dmData, localUser, remoteUser) { |
|
|
|
function postToElemDM(dmData, localUser, remoteUser) { |
|
|
|
var from = (dmData.from && dmData.from.length && dmData.from.charCodeAt(0)) |
|
|
|
var senderAlias = (dmData.from && dmData.from.length && dmData.from.charCodeAt(0)) |
|
|
|
? dmData.from |
|
|
|
? dmData.from : (dmData.fromMe ? localUser : remoteUser); |
|
|
|
: (dmData.fromMe ? localUser : remoteUser); |
|
|
|
var elem = $('#dm-chat-template').clone(true) |
|
|
|
var classDm = dmData.fromMe ? "sent" : "received"; |
|
|
|
.removeAttr('id') |
|
|
|
var dmItem = $("#dm-chat-template").clone(true); |
|
|
|
.addClass(dmData.fromMe ? 'sent' : 'received') |
|
|
|
dmItem.removeAttr('id'); |
|
|
|
; |
|
|
|
dmItem.addClass(classDm); |
|
|
|
|
|
|
|
getAvatar(from, dmItem.find(".post-photo").find("img") ); |
|
|
|
var elemName = elem.find('.post-info-name') |
|
|
|
dmItem.find('.post-info-time') |
|
|
|
.attr('href', $.MAL.userUrl(senderAlias)); |
|
|
|
|
|
|
|
if (senderAlias[0] === '*' ) |
|
|
|
|
|
|
|
getGroupChatName(senderAlias, elemName); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
getFullname(senderAlias, elemName); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getAvatar(senderAlias, elem.find('.post-photo').find('img')); |
|
|
|
|
|
|
|
elem.find('.post-info-time') |
|
|
|
.attr('title', timeSincePost(dmData.time)) |
|
|
|
.attr('title', timeSincePost(dmData.time)) |
|
|
|
.find('span:last') |
|
|
|
.find('span:last') |
|
|
|
.text(timeGmtToText(dmData.time)) |
|
|
|
.text(timeGmtToText(dmData.time)) |
|
|
|
; |
|
|
|
; |
|
|
|
setPostInfoSent(from,dmData.k,dmItem.find('.post-info-sent')); |
|
|
|
setPostInfoSent(senderAlias, dmData.k, elem.find('.post-info-sent')); |
|
|
|
dmItem.find('.post-text').html(htmlFormatMsg(dmData.text).html); |
|
|
|
elem.find('.post-text').html(htmlFormatMsg(dmData.text).html); |
|
|
|
|
|
|
|
|
|
|
|
return dmItem; |
|
|
|
return elem; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// convert message text to html, featuring @users and links formating.
|
|
|
|
// convert message text to html, featuring @users and links formating.
|
|
|
|