From 6218078c517abe88f8dc6470eb5bc83b12d990d6 Mon Sep 17 00:00:00 2001
From: Omar Roth
- ">
- <%= translate(locale, "Unsubscribe") %> | <%= number_to_short_text(sub_count) %>
-
-
- ">
- <%= translate(locale, "Subscribe") %> | <%= number_to_short_text(sub_count) %>
-
-
- ">
- <%= translate(locale, "Login to subscribe to `x`", author) %>
-
-
+ ">
+ <%= translate(locale, "Unsubscribe") %> | <%= sub_count_text %>
+
+
+ ">
+ <%= translate(locale, "Subscribe") %> | <%= sub_count_text %>
+
+
+ ">
+ <%= translate(locale, "Login to subscribe to `x`", author) %>
+
+ <%= video.author %>
- "> - <%= translate(locale, "Unsubscribe") %> | <%= video.sub_count_text %> - -
- <% else %> -- "> - <%= translate(locale, "Subscribe") %> | <%= video.sub_count_text %> - -
- <% end %> - <% else %> -- "> - <%= translate(locale, "Login to subscribe to `x`", video.author) %> - -
- <% end %> + <% ucid = video.ucid %> + <% author = video.author %> + <% sub_count_text = video.sub_count_text %> + <%= rendered "components/subscribe_widget" %><%= translate(locale, "Shared `x`", video.published.to_s("%B %-d, %Y")) %>
@@ -252,48 +232,11 @@ function number_with_separator(val) { return val; } -subscribe_button = document.getElementById("subscribe"); -if (subscribe_button.getAttribute('onclick')) { - subscribe_button["href"] = "javascript:void(0)"; -} +<% ucid = video.ucid %> +<% author = video.author %> +<% sub_count_text = video.sub_count_text %> +<%= rendered "components/subscribe_widget_script" %> -function subscribe() { - var url = "/subscription_ajax?action_create_subscription_to_channel=1&c=<%= video.ucid %>&referer=<%= env.get("current_page") %>"; - var xhr = new XMLHttpRequest(); - xhr.responseType = "json"; - xhr.timeout = 20000; - xhr.open("GET", url, true); - xhr.send(); - - xhr.onreadystatechange = function() { - if (xhr.readyState == 4) { - if (xhr.status == 200) { - subscribe_button = document.getElementById("subscribe"); - subscribe_button.onclick = unsubscribe; - subscribe_button.innerHTML = '<%= translate(locale, "Unsubscribe") %> | <%= video.sub_count_text %>' - } - } - } -} - -function unsubscribe() { - var url = "/subscription_ajax?action_remove_subscriptions=1&c=<%= video.ucid %>&referer=<%= env.get("current_page") %>"; - var xhr = new XMLHttpRequest(); - xhr.responseType = "json"; - xhr.timeout = 20000; - xhr.open("GET", url, true); - xhr.send(); - - xhr.onreadystatechange = function() { - if (xhr.readyState == 4) { - if (xhr.status == 200) { - subscribe_button = document.getElementById("subscribe"); - subscribe_button.onclick = subscribe; - subscribe_button.innerHTML = '<%= translate(locale, "Subscribe") %> | <%= video.sub_count_text %>' - } - } - } -} <% if plid %> function get_playlist(timeouts = 0) {