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

84 lines
3.0 KiB
Plaintext
Raw Normal View History

2018-07-06 06:18:55 +05:30
<% content_for "header" do %>
2018-12-21 03:02:09 +05:30
<title><%= translate(locale, "Subscription manager") %> - Invidious</title>
2018-07-06 06:18:55 +05:30
<% end %>
<div class="pure-g h-box">
<div class="pure-u-1-3">
<h3>
2019-05-02 06:33:39 +05:30
<a href="/feed/subscriptions">
<%= translate(locale, "`x` subscriptions", %(<span id="count">#{subscriptions.size}</span>)) %>
</a>
</h3>
</div>
2019-04-19 02:53:50 +05:30
<div class="pure-u-1-3" style="text-align:center">
<h3>
2019-05-02 06:33:39 +05:30
<a href="/feed/history">
<%= translate(locale, "Watch history") %>
</a>
</h3>
</div>
2019-04-19 02:53:50 +05:30
<div class="pure-u-1-3" style="text-align:right">
<h3>
2019-05-03 22:45:21 +05:30
<a href="/data_control?referer=<%= URI.escape(referer) %>">
2019-05-02 06:33:39 +05:30
<%= translate(locale, "Import/export") %>
</a>
</h3>
</div>
</div>
2018-07-06 06:18:55 +05:30
<% subscriptions.each do |channel| %>
2019-05-02 06:33:39 +05:30
<div class="h-box">
<div class="pure-g<% if channel.deleted %> deleted <% end %>">
<div class="pure-u-2-5">
<h3 style="padding-left:0.5em">
<a href="/channel/<%= channel.id %>"><%= channel.author %></a>
</h3>
</div>
<div class="pure-u-2-5"></div>
<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>
</h3>
</div>
2018-07-06 06:18:55 +05:30
</div>
2019-05-02 06:33:39 +05:30
<% if subscriptions[-1].author != channel.author %>
<hr>
<% end %>
</div>
2018-08-17 21:34:38 +05:30
<% end %>
2018-11-22 01:05:37 +05:30
<script>
function remove_subscription(target) {
var row = target.parentNode.parentNode.parentNode.parentNode.parentNode;
2019-05-02 06:33:39 +05:30
row.style.display = 'none';
var count = document.getElementById('count');
count.innerText = count.innerText - 1;
2018-11-22 01:05:37 +05:30
2019-05-02 06:33:39 +05:30
var url = '/subscription_ajax?action_remove_subscriptions=1&redirect=false' +
'&referer=<%= env.get("current_page") %>' +
'&c=' + target.getAttribute('data-ucid');
2018-11-22 01:05:37 +05:30
var xhr = new XMLHttpRequest();
2019-05-02 06:33:39 +05:30
xhr.responseType = 'json';
2019-06-16 23:04:00 +05:30
xhr.timeout = 10000;
2019-05-02 06:33:39 +05:30
xhr.open('POST', url, true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2018-11-22 01:05:37 +05:30
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status != 200) {
2019-05-02 06:33:39 +05:30
count.innerText = parseInt(count.innerText) + 1;
row.style.display = '';
2018-11-22 01:05:37 +05:30
}
}
}
2019-06-15 20:38:06 +05:30
xhr.send('csrf_token=<%= URI.escape(env.get?("csrf_token").try &.as(String) || "") %>');
2018-11-22 01:05:37 +05:30
}
2019-05-02 06:33:39 +05:30
</script>