video comments on profile comment page
This commit is contained in:
@@ -35,6 +35,7 @@ if (!window.UserCommentSystem) {
|
|||||||
const contentEl = el.querySelector('.comment-content');
|
const contentEl = el.querySelector('.comment-content');
|
||||||
if (contentEl) {
|
if (contentEl) {
|
||||||
contentEl.innerHTML = this.renderCommentContent(data.content, data.item_id);
|
contentEl.innerHTML = this.renderCommentContent(data.content, data.item_id);
|
||||||
|
this.playEmojiVideos(contentEl);
|
||||||
el.classList.remove('new-item-fade');
|
el.classList.remove('new-item-fade');
|
||||||
void el.offsetWidth;
|
void el.offsetWidth;
|
||||||
el.classList.add('new-item-fade');
|
el.classList.add('new-item-fade');
|
||||||
@@ -118,6 +119,7 @@ if (!window.UserCommentSystem) {
|
|||||||
const html = this.renderComment(c);
|
const html = this.renderComment(c);
|
||||||
this.container.insertAdjacentHTML('beforeend', html);
|
this.container.insertAdjacentHTML('beforeend', html);
|
||||||
});
|
});
|
||||||
|
this.playEmojiVideos(this.container);
|
||||||
this.page++;
|
this.page++;
|
||||||
} else {
|
} else {
|
||||||
this.finished = true;
|
this.finished = true;
|
||||||
@@ -133,9 +135,22 @@ if (!window.UserCommentSystem) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
playEmojiVideos(container) {
|
||||||
|
if (!container) return;
|
||||||
|
container.querySelectorAll('video.emoji').forEach(v => {
|
||||||
|
v.play().catch(() => {
|
||||||
|
v.addEventListener('canplay', () => v.play().catch(() => {}), { once: true });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
renderEmoji(match, name) {
|
renderEmoji(match, name) {
|
||||||
if (this.customEmojis && this.customEmojis[name]) {
|
if (this.customEmojis && this.customEmojis[name]) {
|
||||||
return `<img src="${this.customEmojis[name]}" class="emoji" alt="${match}" title="${match}">`;
|
const url = this.customEmojis[name];
|
||||||
|
if (url.endsWith('.webm')) {
|
||||||
|
return `<video src="${url}" class="emoji" autoplay loop muted playsinline title=":${name}:"></video>`;
|
||||||
|
}
|
||||||
|
return `<img src="${url}" class="emoji" alt="${match}" title="${match}">`;
|
||||||
}
|
}
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user