From 3e6f8aedad5278e67719fa6d143997df1ed312dc Mon Sep 17 00:00:00 2001 From: Piyush Mishra Date: Tue, 11 May 2021 14:23:18 +0530 Subject: [PATCH] bug fix --- static/js/message.js | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/static/js/message.js b/static/js/message.js index 4fa626a..c842f24 100644 --- a/static/js/message.js +++ b/static/js/message.js @@ -67,8 +67,8 @@ let Messages = class { var area = $('#message_area'); var elm = $('
', {class: 'message '+(isMe?'message-me':'message-other'), msgid: msg_id}); if(!no_name_message) { - elm.append($('
', {class: 'message-sub'}) - .append(vayakti[sender]+'('+sender.substr(0, 8)+')') + elm.append($('
', {class: 'message-sub', name: 'by'}) + .append($('').text(vayakti[sender]+'('+sender.substr(0, 8)+')')) .append($('', {class: 'pull-right'}).text(Messages.currentTime()))); } if(reply != null && reply.length > 0) { @@ -92,7 +92,9 @@ let Messages = class { var area = $('#message_area'); var elm = $('
', {class: 'message '+(isMe?'message-me':'message-other'), msgid: msg_id}); if(!no_name_message) { - elm.append($('
', {class: 'message-by'}).append(vayakti[sender]+'('+sender.substr(0, 8)+')')) + elm.append($('
', {class: 'message-sub', name: 'by'}) + .append($('').text(vayakti[sender]+'('+sender.substr(0, 8)+')')) + .append($('', {class: 'pull-right'}).text(Messages.currentTime()))); } elm.append($('', {src: src, width: 300})); elm.click(function() { @@ -116,17 +118,17 @@ let Messages = class { } static selectedMessageToText() { - var text = ""; - $('.message.active').each(function() { - text += $(this).find('.message-by').text() + ' : '; - text += $(this).find('pre').last().text() + '\n'; - }); + return text.trim(); } static prepareReply() { - var text = Messages.selectedMessageToText(); + var text = ""; + $('.message.active').each(function() { + text += $(this).find('[name=by]').find('span:not(.pull-right)').text() + ' : '; + text += $(this).find('pre').last().text() + '\n'; + }); var el = $('#reply_clip'); el.removeClass('is-hidden'); el.attr('msg', text); @@ -135,9 +137,23 @@ let Messages = class { } static copyMessagesToClipboard() { + var text = ""; + $('.message.active').each(function() { + text += $(this).find('[name=by]').find('span:not(.pull-right)').text() + ' : '; + var pr = $(this).find('pre'); + if (pr.length > 1) text += '\n'; + for(var i = 0; i < pr.length-1; i++) { + $(pr[i]).text().split('\n').forEach(function (t) { + if(t.trim().length <= 0) return; + text += ' ' + t + '\n'; + }); + } + text += pr.last().text(); + }); + var $temp = $("