Add 'unrm' option when in show_seen mode

This commit is contained in:
John Mertz 2022-09-25 20:37:17 -04:00
parent e886fb3d59
commit 8cf6fde5ca
1 changed files with 39 additions and 9 deletions

View File

@ -208,7 +208,7 @@ function get_permissions($settings)
}
# Print one row given the video details
function print_video($video,$settings,$mobile)
function print_video($video,$settings,$mobile,$show_seen)
{
$html = '
<div class="row">
@ -256,13 +256,25 @@ function print_video($video,$settings,$mobile)
}
$html .= '
<a href="https://'.($mobile ? 'm' : 'www').'.youtube.com/watch?v=' . $video['videoId'] . '" target="_blank"><div class="web"><img src="images/web.svg"></div></a>
<a onclick="clipboard(\'' . $video['videoId'] . '\',\'https://youtube.com/watch?v=' . $video['videoId'] . '\');"><div class="clip"><img src="images/clip.svg"></div></a>
<a onclick="clipboard(\'' . $video['videoId'] . '\',\'https://youtube.com/watch?v=' . $video['videoId'] . '\');"><div class="clip"><img src="images/clip.svg"></div></a>';
if (isset($show_seen) && $show_seen && isset($video['seen']) && $video['seen']) {
$html .= '
<a href="?unrm=' . $video['videoId'] . '">
<div class="seen">
<span class="unmark">
<h3>*</h3>
</span>
</div>';
} else {
$html .= '
<a href="?rm=' . $video['videoId'] . '">
<div class="seen">
<span class="mark">
<h3>X</h3>
<h3><b>X</b></h3>
</span>
</div>
</div>';
}
$html .= '
</a>
</div>
' . $default .'
@ -300,9 +312,17 @@ function print_video($video,$settings,$mobile)
$html .= '
<div class="web"><a href="https://'.($mobile ? 'm' : 'www').'.youtube.com/watch?v=' . $video['videoId'] . '" target="_blank"><img src="images/web.svg"></a></div>
<div class="clip"><a onclick="clipboard(\'' . $video['videoId'] . '\',\'https://youtube.com/watch?v=' . $video['videoId'] . '\');"><img src="images/clip.svg"></a></div>
</div>
</div>';
if (isset($show_seen) && $show_seen && isset($video['seen']) && $video['seen']) {
$html .= '
<a href="?unrm=' . $video['videoId'] . '">
<div class="seen"><span class="unmark"><h3>*</h3></span></div></a>';
} else {
$html .= '
<a href="?rm=' . $video['videoId'] . '">
<div class="seen"><span class="mark"><h3>X</h3></span></div></a>
<div class="seen"><span class="mark"><h3><b>X</b></h3></span></div></a>';
}
$html .= '
</div>';
}
return $html;
@ -560,6 +580,16 @@ if ( !$no_db && $reload && $permissions['writable'] ) {
$target = remove_arg($target,'rm');
}
# Mark one or all videos as played.
if (isset($args['unrm'])) {
if (preg_match("/^([^']{11})$/",urldecode($args['unrm']))) {
$debug_text .= "<p>Restoring " . urldecode($args['unrm']) . "</p>";
$unrm = sql_escape(urldecode($args['unrm']));
$handle->query("UPDATE videos SET seen = 0 WHERE videoId = '$unrm'");
}
$target = remove_arg($target,'unrm');
}
# Update the refresh interval
if (isset($args['refresh'])) {
$interval = urldecode($args['refresh']);
@ -911,7 +941,7 @@ if (isset($permissions['readable']) && $permissions['readable']) {
}
$header .= '</input>
<button type="submit">Search</button>
<button type="submit" name="search_clear">X</button>
<button type="submit" name="search_clear"><b>X</b></button>
</form>';
}
@ -1128,7 +1158,7 @@ if (isset($permissions['readable']) && $permissions['readable']) {
<li>
<a href="https://'.($mobile ? 'm' : 'www').'.youtube.com/channel/' . $row['channelId'] . '/videos" target="_blank"><img title="' . $row['channelName'] . '" src="' . $row['channelThumbnail'] . '"></a>
<div class="unsubscribe" title="Unsubscribe from ' . $row['channelName'] . '">
<a onclick="if (confirm(\'Unsubscribe from ' . $row['channelName'] . '?\')) { window.location = \'' . $target . ((isset($category)) ? '?filter='.$category.'&' : '?') . 'unsub=' . $row['channelId'] . '\'; }">X</a>
<a onclick="if (confirm(\'Unsubscribe from ' . $row['channelName'] . '?\')) { window.location = \'' . $target . ((isset($category)) ? '?filter='.$category.'&' : '?') . 'unsub=' . $row['channelId'] . '\'; }"><b>X</b></a>
</div>';
if (isset($chan_filter)) {
@ -1232,7 +1262,7 @@ if (isset($permissions['readable']) && $permissions['readable']) {
continue;
} else {
$row['channelThumbnail'] = $thumbnails[$row['channelId']];
$body .= print_video($row,$settings,$mobile);
$body .= print_video($row,$settings,$mobile,$show_seen);
$x++;
}
}