From f5701b6c7602d3dc5a1f73366f5e52ca0b04d61f Mon Sep 17 00:00:00 2001 From: flashwave Date: Sun, 21 Jan 2024 16:57:56 +0000 Subject: [PATCH] Fixed actions not being italicised and backported the apostrophe thing. --- src/ami.js/messages.js | 27 +++++++++++++++++++-------- src/ami.js/sockchat.js | 11 ++++++----- src/ami.js/ts_20_ui.js | 2 ++ 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/ami.js/messages.js b/src/ami.js/messages.js index d334051..3cf9a33 100644 --- a/src/ami.js/messages.js +++ b/src/ami.js/messages.js @@ -52,18 +52,26 @@ var AmiMessageList = function(parent) { }, child: nameBody, }, - { + ]; + + if(msgInfo.showColon) + messageBody.push({ tag: 'span', attrs: { className: 'msgColon' }, - child: msgInfo.showColon ? ':' : '', - }, - ' ', - { + child: ':', + }); + + if(msgInfo.isAction) { + if(msgInfo.bodyText.indexOf("'") !== 0 || (msgInfo.bodyText.match(/\'/g).length % 2) === 0) + messageBody.push(' '); + } else { + messageBody.push(' '); + messageBody.push({ tag: 'span', attrs: { className: 'msgBreak' }, child: { tag: 'br' }, - }, - ]; + }); + } if(msgInfo.isPM) { if(msgInfo.pmTargetName) @@ -87,7 +95,10 @@ var AmiMessageList = function(parent) { child: messageBody, }); - message.insertAdjacentHTML('beforeend', msgInfo.bodyRaw); + let msgBodyTarget = message; + if(msgInfo.isAction) + message.appendChild(msgBodyTarget = $e({ tag: 'i' })); + msgBodyTarget.insertAdjacentHTML('beforeend', msgInfo.bodyRaw); if(msgInfo.canDelete) message.appendChild($e({ diff --git a/src/ami.js/sockchat.js b/src/ami.js/sockchat.js index 4a2220a..9cf84a9 100644 --- a/src/ami.js/sockchat.js +++ b/src/ami.js/sockchat.js @@ -44,11 +44,12 @@ var AmiSockChat = function(auth) { }; var parseMsgFlags = function(str) { return { - isNameBold: str[0] !== '0', - isNameItalic: str[1] !== '0', - isNameUnderline: str[2] !== '0', - isNameSeparate: str[3] !== '0', - isPrivate: str[4] !== '0', + nameBold: str[0] !== '0', + nameItalics: str[1] !== '0', + nameUnderline: str[2] !== '0', + showColon: str[3] !== '0', + isPM: str[4] !== '0', + isAction: str[1] !== '0' && str[3] === '0', }; }; diff --git a/src/ami.js/ts_20_ui.js b/src/ami.js/ts_20_ui.js index 9e39ff1..c2c2f34 100644 --- a/src/ami.js/ts_20_ui.js +++ b/src/ami.js/ts_20_ui.js @@ -100,6 +100,8 @@ var UI = (function () { nameUnderline: flags[2] !== '0', showColon: flags[3] !== '0', isPM: flags[4] !== '0', + isAction: flags[1] !== '0' && flags[3] === '0', + bodyText: msg, canDelete: 'self' in UserContext && !isNaN(parseInt(msgid)) && !u.isBot()