Support custom post FG and BG colors by settings "fedilove_pcolors" tag
This commit is contained in:
parent
f0ab1b80d3
commit
4c562ebaff
|
@ -21,6 +21,29 @@ const ATTACHMENTS = {
|
|||
return v.substr(0, 30)
|
||||
return v
|
||||
},
|
||||
fedilove_pcolors: (v) => {
|
||||
let colors
|
||||
v = v.replaceAll(/<[^<>]+>/g, '').trim()
|
||||
if (v === '')
|
||||
return {}
|
||||
if (v.includes(','))
|
||||
colors = v.split(',')
|
||||
else colors = [v]
|
||||
if (colors.length > 2)
|
||||
colors.splice(2)
|
||||
for (var i = colors.length -1; i >= 0; i--) {
|
||||
colors[i] = colors[i].trim()
|
||||
if (!colors[i].match(/^#?[a-zA-Z0-9]{3,16}$/)) {
|
||||
delete colors[i]
|
||||
continue
|
||||
}
|
||||
}
|
||||
if (colors.length === 2)
|
||||
return { bg: colors[0], fg: colors[1] }
|
||||
if (colors.length === 1)
|
||||
return { bg: colors[0] }
|
||||
return {}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,10 @@ var app = {
|
|||
defaults: {
|
||||
icon: '/assets/images/default_profile.png',
|
||||
meet: {
|
||||
text_bgcolor: '#93227ce8',
|
||||
item_pcolors: {
|
||||
bg: '#93227ce8',
|
||||
fg: '#fff',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -16,11 +16,23 @@ app.pages.meet = {
|
|||
if (k === 'date') return dayjs(v).fromNow(true);
|
||||
});
|
||||
var item = json[i];
|
||||
var textClr = item.text_color;
|
||||
if (textClr === undefined)
|
||||
textClr = app.vars.defaults.meet.text_bgcolor;
|
||||
if (item.props === undefined)
|
||||
item.props = { pcolors: {} }
|
||||
if (item.account.props.pcolors === undefined)
|
||||
item.account.props.pcolors = {};
|
||||
|
||||
var postFgColor = item.account.props.pcolors.fg
|
||||
|| app.vars.defaults.meet.item_pcolors.fg;
|
||||
var postBgColor = item.account.props.pcolors.bg
|
||||
|| app.vars.defaults.meet.item_pcolors.bg;
|
||||
if (item.props.pcolors.fg !== undefined)
|
||||
postFgColor = item.props.pcolors.fg;
|
||||
if (item.props.pcolors.bg !== undefined)
|
||||
postBgColor = item.props.pcolors.bg;
|
||||
|
||||
tpl = tpl.replaceAll('{actionsHeight}', '6em');
|
||||
tpl = tpl.replaceAll('{textColor}', htmlescape(textClr));
|
||||
tpl = tpl.replaceAll('{postFgColor}', htmlescape(postFgColor));
|
||||
tpl = tpl.replaceAll('{postBgColor}', htmlescape(postBgColor));
|
||||
dom.innerHTML += tpl;
|
||||
}
|
||||
}; _();
|
||||
|
|
|
@ -21,8 +21,10 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="status-content center width-max"
|
||||
style="background: {textColor};">
|
||||
<div class="text"><p>{.text}</p></div>
|
||||
style="background: {postBgColor};">
|
||||
<div class="text">
|
||||
<p style="color: {postFgColor} !important">{.text}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="profile flex">
|
||||
|
|
Loading…
Reference in New Issue