Begin moving a few DOM manipulations to cash-do

This commit is contained in:
projectmoon 2023-03-27 21:40:43 +02:00
parent 6c399bc669
commit 2a5415bc70
1 changed files with 5 additions and 6 deletions

View File

@ -40,7 +40,6 @@ function displayError(errorDiv: HTMLElement, category: string, ex: Error) {
console.error(ex);
const errorHeading = errorDiv.querySelector('.alert-heading') as HTMLElement | null;
//clear all error text, but not heading
const errorMessages = errorDiv.querySelectorAll('span');
errorMessages.forEach(message => errorDiv.removeChild(message));
@ -98,17 +97,17 @@ function checkOverflow(elem: HTMLElement) {
function processFragment() {
// add username popover
document
.querySelectorAll('[data-bs-toggle="popover"]')
.forEach(popover => new bootstrap.Popover(popover, { trigger: 'focus' }));
$('[data-bs-toggle="popover"]')
.each((_, popover) => new bootstrap.Popover(popover, { trigger: 'focus' }));
// indicate overflow on mobile
document.querySelectorAll('.message-content div').forEach(div => {
if (checkOverflow(div as HTMLElement)) {
$('.message-content div').each((_, div) => {
if (checkOverflow(div)) {
div.parentElement?.classList.add('overflow-icon');
}
});
// uniquely color usernames
const colorMap = new Map(
Array.from($('.message-from-user'))
.map(el => el?.textContent || '')