Fixed actions not being italicised and backported the apostrophe thing.

This commit is contained in:
flash 2024-01-21 16:57:56 +00:00
parent 2e20c23789
commit f5701b6c76
3 changed files with 27 additions and 13 deletions

View file

@ -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({

View file

@ -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',
};
};

View file

@ -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()