mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-03-16.git
synced 2024-08-15 00:53:18 +00:00
Add ability to mark videos as watched in subscription feed
This commit is contained in:
parent
c7e8d623c0
commit
6b12f11e10
8 changed files with 206 additions and 25 deletions
|
@ -507,7 +507,7 @@ def content_to_comment_html(content)
|
|||
length_seconds = watch_endpoint["startTimeSeconds"].as_i
|
||||
video_id = watch_endpoint["videoId"].as_s
|
||||
|
||||
text = %(<a href="javascript:void();" onclick="player.currentTime(#{length_seconds})">#{text}</a>)
|
||||
text = %(<a href="javascript:void(0)" onclick="player.currentTime(#{length_seconds})">#{text}</a>)
|
||||
elsif url = run["navigationEndpoint"]["commandMetadata"]?.try &.["webCommandMetadata"]["url"].as_s
|
||||
text = %(<a href="#{url}">#{text}</a>)
|
||||
end
|
||||
|
|
|
@ -90,7 +90,7 @@
|
|||
</div>
|
||||
|
||||
<script>
|
||||
document.getElementById("subscribe")["href"] = "javascript:void(0);"
|
||||
document.getElementById("subscribe")["href"] = "javascript:void(0)"
|
||||
|
||||
function subscribe() {
|
||||
var url = "/subscription_ajax?action_create_subscription_to_channel=1&c=<%= ucid %>&referer=<%= env.get("current_page") %>";
|
||||
|
|
|
@ -74,6 +74,21 @@
|
|||
<% else %>
|
||||
<div class="thumbnail">
|
||||
<img class="thumbnail" src="/vi/<%= item.id %>/mqdefault.jpg"/>
|
||||
<% if env.get? "show_watched" %>
|
||||
<p class="watched">
|
||||
<a onclick="mark_watched(this)"
|
||||
data-id="<%= item.id %>"
|
||||
onmouseenter='this["href"]="javascript:void(0)"'
|
||||
href="/mark_watched?id=<%= item.id %>"'
|
||||
>
|
||||
<i onmouseenter='this.setAttribute("class", "icon ion-ios-eye-off")'
|
||||
onmouseleave='this.setAttribute("class", "icon ion-ios-eye")'
|
||||
class="icon ion-ios-eye"
|
||||
>
|
||||
</i>
|
||||
</a>
|
||||
</p>
|
||||
<% end %>
|
||||
<p class="length"><%= recode_length_seconds(item.length_seconds) %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
73
src/invidious/views/history.ecr
Normal file
73
src/invidious/views/history.ecr
Normal file
|
@ -0,0 +1,73 @@
|
|||
<% content_for "header" do %>
|
||||
<title>History - Invidious</title>
|
||||
<% end %>
|
||||
|
||||
<div class="pure-g">
|
||||
<% watched.each_slice(4) do |slice| %>
|
||||
<% slice.each do |item| %>
|
||||
<div class="pure-u-1 pure-u-md-1-4">
|
||||
<div class="h-box">
|
||||
<a style="width:100%;" href="/watch?v=<%= item %>">
|
||||
<% if env.get?("user") && env.get("user").as(User).preferences.thin_mode %>
|
||||
<% else %>
|
||||
<div class="thumbnail">
|
||||
<img class="thumbnail" src="/vi/<%= item %>/mqdefault.jpg"/>
|
||||
<p class="watched">
|
||||
<a onclick="mark_unwatched(this)"
|
||||
data-id="<%= item %>"
|
||||
onmouseenter='this["href"]="javascript:void(0)"'
|
||||
href="/mark_unwatched?id=<%= item %>"'
|
||||
>
|
||||
<i onmouseenter='this.setAttribute("class", "icon ion-ios-eye")'
|
||||
onmouseleave='this.setAttribute("class", "icon ion-ios-eye-off")'
|
||||
class="icon ion-ios-eye-off"
|
||||
>
|
||||
</i>
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<p></p>
|
||||
<% end %>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function mark_unwatched(target) {
|
||||
var tile = target.parentNode.parentNode.parentNode.parentNode;
|
||||
tile.style.display = "none";
|
||||
|
||||
var url = "/mark_unwatched?redirect=false&id=" + target.getAttribute("data-id");
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.responseType = "json";
|
||||
xhr.timeout = 20000;
|
||||
xhr.open("GET", url, true);
|
||||
xhr.setRequestHeader("Redirect", "false");
|
||||
xhr.send();
|
||||
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState == 4) {
|
||||
if (xhr.status != 200) {
|
||||
tile.style.display = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="pure-g h-box">
|
||||
<div class="pure-u-1 pure-u-md-1-5">
|
||||
<% if page >= 2 %>
|
||||
<a href="/feed/history?page=<%= page - 1 %>">Previous page</a>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="pure-u-1 pure-u-md-3-5"></div>
|
||||
<div style="text-align:right;" class="pure-u-1 pure-u-md-1-5">
|
||||
<% if watched.size >= limit %>
|
||||
<a href="/feed/history?page=<%= page + 1 %>">Next page</a>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
|
@ -43,6 +43,28 @@
|
|||
<% end %>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function mark_watched(target) {
|
||||
var tile = target.parentNode.parentNode.parentNode.parentNode;
|
||||
tile.style.display = "none";
|
||||
|
||||
var url = "/mark_watched?redirect=false&id=" + target.getAttribute("data-id");
|
||||
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) {
|
||||
tile.style.display = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="pure-g">
|
||||
<div class="pure-u-1 pure-u-md-1-5">
|
||||
<% if page >= 2 %>
|
||||
|
|
|
@ -225,7 +225,7 @@ function number_with_separator(val) {
|
|||
|
||||
subscribe_button = document.getElementById("subscribe");
|
||||
if (subscribe_button.getAttribute('onclick')) {
|
||||
subscribe_button["href"] = "javascript:void(0);";
|
||||
subscribe_button["href"] = "javascript:void(0)";
|
||||
}
|
||||
|
||||
function subscribe() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue