invidious-mod/src/invidious/views/subscription_manager.ecr

74 行
2.8 KiB
Plaintext
Raw 通常表示 履歴

2018-07-06 09:48:55 +09:00
<% content_for "header" do %>
2018-12-21 06:32:09 +09:00
<title><%= translate(locale, "Subscription manager") %> - Invidious</title>
2018-07-06 09:48:55 +09:00
<% end %>
<div class="pure-g h-box">
<div class="pure-u-1-3">
<h3>
<a href="/feed/subscriptions"><%= translate(locale, "`x` subscriptions", %(<span id="count">#{subscriptions.size}</span>)) %></a>
</h3>
</div>
2019-04-19 06:23:50 +09:00
<div class="pure-u-1-3" style="text-align:center">
<h3>
2018-12-21 06:32:09 +09:00
<a href="/feed/history"><%= translate(locale, "Watch history") %></a>
</h3>
</div>
2019-04-19 06:23:50 +09:00
<div class="pure-u-1-3" style="text-align:right">
<h3>
2019-04-20 01:14:11 +09:00
<a href="/data_control?referer=<%= referer %>"><%= translate(locale, "Import/export") %></a>
</h3>
</div>
</div>
2018-07-06 09:48:55 +09:00
<% subscriptions.each do |channel| %>
2018-08-06 09:59:45 +09:00
<div class="h-box">
2019-04-19 06:23:50 +09:00
<div class="pure-g<% if channel.deleted %> deleted <% end %>">
2018-07-06 09:48:55 +09:00
<div class="pure-u-2-5">
2019-04-19 06:23:50 +09:00
<h3 style="padding-left:0.5em">
2018-08-06 09:59:45 +09:00
<a href="/channel/<%= channel.id %>"><%= channel.author %></a>
</h3>
2018-07-06 09:48:55 +09:00
</div>
<div class="pure-u-2-5"></div>
2019-04-19 06:23:50 +09:00
<div class="pure-u-1-5" style="text-align:right">
<h3 style="padding-right:0.5em">
<form onsubmit="return false" action="/subscription_ajax?action_remove_subscriptions=1&c=<%= channel.id %>&referer=<%= env.get("current_page") %>" method="post">
<input type="hidden" name="csrf_token" value="<%= URI.escape(env.get?("csrf_token").try &.as(String) || "") %>">
<a onclick="remove_subscription(this)" data-ucid="<%= channel.id %>" href="#">
<input style="all:unset" type="submit" value="<%= translate(locale, "unsubscribe") %>">
</a>
</form>
2018-08-06 09:59:45 +09:00
</h3>
2018-07-06 09:48:55 +09:00
</div>
</div>
2018-08-06 09:59:45 +09:00
<% if subscriptions[-1].author != channel.author %>
<hr>
<% end %>
</div>
2018-08-18 01:04:38 +09:00
<% end %>
2018-11-22 04:35:37 +09:00
<script>
function remove_subscription(target) {
var row = target.parentNode.parentNode.parentNode.parentNode.parentNode;
2018-11-22 04:35:37 +09:00
row.style.display = "none";
var count = document.getElementById("count")
count.innerText = count.innerText - 1;
2018-11-22 04:35:37 +09:00
var url = "/subscription_ajax?action_remove_subscriptions=1&redirect=false&referer=<%= env.get("current_page") %>&c=" + target.getAttribute("data-ucid");
2018-11-22 04:35:37 +09:00
var xhr = new XMLHttpRequest();
xhr.responseType = "json";
xhr.timeout = 20000;
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
2019-04-19 06:23:50 +09:00
xhr.send("csrf_token=<%= URI.escape(env.get?("csrf_token").try &.as(String) || "") %>");
2018-11-22 04:35:37 +09:00
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status != 200) {
count.innerText = count.innerText - 1 + 2;
2018-11-22 04:35:37 +09:00
row.style.display = "";
}
}
}
}
</script>