diff --git a/assets/js/community.js b/assets/js/community.js new file mode 100644 index 00000000..754ec6d3 --- /dev/null +++ b/assets/js/community.js @@ -0,0 +1,101 @@ +String.prototype.supplant = function (o) { + return this.replace(/{([^{}]*)}/g, function (a, b) { + var r = o[b]; + return typeof r === 'string' || typeof r === 'number' ? r : a; + }); +} + +function hide_youtube_replies(event) { + var target = event.target; + + sub_text = target.getAttribute('data-inner-text'); + inner_text = target.getAttribute('data-sub-text'); + + body = target.parentNode.parentNode.children[1]; + body.style.display = 'none'; + + target.innerHTML = sub_text; + target.onclick = show_youtube_replies; + target.setAttribute('data-inner-text', inner_text); + target.setAttribute('data-sub-text', sub_text); +} + +function show_youtube_replies(event) { + var target = event.target; + + sub_text = target.getAttribute('data-inner-text'); + inner_text = target.getAttribute('data-sub-text'); + + body = target.parentNode.parentNode.children[1]; + body.style.display = ''; + + target.innerHTML = sub_text; + target.onclick = hide_youtube_replies; + target.setAttribute('data-inner-text', inner_text); + target.setAttribute('data-sub-text', sub_text); +} + +function number_with_separator(val) { + while (/(\d+)(\d{3})/.test(val.toString())) { + val = val.toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2'); + } + return val; +} + +function get_youtube_replies(target, load_more) { + var continuation = target.getAttribute('data-continuation'); + + var body = target.parentNode.parentNode; + var fallback = body.innerHTML; + body.innerHTML = + '
#{translate(locale, "View `x` replies", child["replies"]["replyCount"].to_s)} + onclick="get_youtube_replies(this)">#{translate(locale, "View `x` replies", number_with_separator(child["replies"]["replyCount"]))}
@@ -310,11 +310,66 @@ def template_youtube_comments(comments, locale, thin_mode) #{child["author"]}
#{child["contentHtml"]}
- #{translate(locale, "`x` ago", recode_date(Time.unix(child["published"].as_i64), locale))} #{child["isEdited"] == true ? translate(locale, "(edited)") : ""} - | - [YT] - | - #{number_with_separator(child["likeCount"])} + END_HTML + + if child["attachment"]? + attachment = child["attachment"] + + case attachment["type"] + when "image" + attachment = attachment["imageThumbnails"][1] + + html << <<-END_HTML +#{attachment["error"]}
+ END_HTML + else + html << <<-END_HTML + + END_HTML + end + + html << <<-END_HTML +<%= error_message %>
++ community.js + | + ++ AGPL-3.0 + | + ++ <%= translate(locale, "source") %> + | +
embed.js
diff --git a/src/invidious/views/playlists.ecr b/src/invidious/views/playlists.ecr
index 8d1236aa..0a5a0c13 100644
--- a/src/invidious/views/playlists.ecr
+++ b/src/invidious/views/playlists.ecr
@@ -36,7 +36,7 @@
- <%= translate(locale, "View channel on YouTube") %>
+ <%= translate(locale, "View channel on YouTube") %>
<%= translate(locale, "Videos") %>
@@ -46,6 +46,11 @@
<%= translate(locale, "Playlists") %>
<% end %>
+
+ <% if channel.tabs.includes? "community" %>
+ <%= translate(locale, "Community") %>
+ <% end %>
+
|