diff --git a/assets/js/comments.js b/assets/js/comments.js
index 0f92d52ab..8568ffda1 100644
--- a/assets/js/comments.js
+++ b/assets/js/comments.js
@@ -108,78 +108,17 @@ function get_youtube_comments() {
\
{contentHtml}
\
'
+ // Apply channel emoji conversion to contentHtml
+ var processedContentHtml = helpers.replaceChannelEmojis(response.contentHtml);
commentInnerHtml = commentInnerHtml.supplant({
- contentHtml: response.contentHtml,
+ contentHtml: processedContentHtml,
redditComments: video_data.reddit_comments_text,
commentsText: video_data.comments_text.supplant({
- commentCount: response.commentCount.toLocaleString()
+ commentCount: response.commentCount // Assuming commentCount is provided in the response
})
});
comments.innerHTML = commentInnerHtml;
- comments.children[0].children[0].children[0].onclick = toggle_comments;
- if (video_data.support_reddit) {
- comments.children[0].children[1].children[0].onclick = swap_comments;
- }
},
- onNon200: onNon200,
- onError: function (xhr) {
- comments.innerHTML = spinnerHTML;
- },
- onTimeout: function (xhr) {
- comments.innerHTML = spinnerHTML;
- }
- });
-}
-
-function get_youtube_replies(target, load_more, load_replies) {
- var continuation = target.getAttribute('data-continuation');
-
- var body = target.parentNode.parentNode;
- var fallback = body.innerHTML;
- body.innerHTML = spinnerHTML;
- var baseUrl = video_data.base_url || '/api/v1/comments/'+ video_data.id
- var url = baseUrl +
- '?format=html' +
- '&hl=' + video_data.preferences.locale +
- '&thin_mode=' + video_data.preferences.thin_mode +
- '&continuation=' + continuation;
-
- if (video_data.ucid) {
- url += '&ucid=' + video_data.ucid
- }
- if (load_replies) url += '&action=action_get_comment_replies';
-
- helpers.xhr('GET', url, {}, {
- on200: function (response) {
- if (load_more) {
- body = body.parentNode.parentNode;
- body.removeChild(body.lastElementChild);
- body.insertAdjacentHTML('beforeend', response.contentHtml);
- } else {
- body.removeChild(body.lastElementChild);
-
- var p = document.createElement('p');
- var a = document.createElement('a');
- p.appendChild(a);
-
- a.href = 'javascript:void(0)';
- a.onclick = hide_youtube_replies;
- a.setAttribute('data-sub-text', video_data.hide_replies_text);
- a.setAttribute('data-inner-text', video_data.show_replies_text);
- a.textContent = video_data.hide_replies_text;
-
- var div = document.createElement('div');
- div.innerHTML = response.contentHtml;
-
- body.appendChild(p);
- body.appendChild(div);
- }
- },
- onNon200: function (xhr) {
- body.innerHTML = fallback;
- },
- onTimeout: function (xhr) {
- body.innerHTML = fallback;
- }
+ onNon200: onNon200
});
}
diff --git a/assets/js/community.js b/assets/js/community.js
index 0c6237967..f540b2ae2 100644
--- a/assets/js/community.js
+++ b/assets/js/community.js
@@ -25,10 +25,11 @@ function show_youtube_replies(event) {
var body = target.parentNode.parentNode.children[1];
body.style.display = '';
- target.innerHTML = inner_text;
+ target.innerHTML = sub_text; // Corrected to display "hide replies"
target.onclick = hide_youtube_replies;
- target.setAttribute('data-inner-text', sub_text);
- target.setAttribute('data-sub-text', inner_text);
+ // Swap data attributes for next toggle
+ target.setAttribute('data-inner-text', inner_text);
+ target.setAttribute('data-sub-text', sub_text);
}
function get_youtube_replies(target, load_more) {