mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
43 lines
1.5 KiB
Text
43 lines
1.5 KiB
Text
|
subscribe_button = document.getElementById("subscribe");
|
||
|
if (subscribe_button.getAttribute('onclick')) {
|
||
|
subscribe_button["href"] = "javascript:void(0)";
|
||
|
}
|
||
|
|
||
|
function subscribe() {
|
||
|
var url = "/subscription_ajax?action_create_subscription_to_channel=1&c=<%= 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 = '<b><%= translate(locale, "Unsubscribe") %> | <%= sub_count_text %></b>'
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function unsubscribe() {
|
||
|
var url = "/subscription_ajax?action_remove_subscriptions=1&c=<%= 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 = '<b><%= translate(locale, "Subscribe") %> | <%= sub_count_text %></b>'
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|