all is working great

This commit is contained in:
ghassan 2026-03-15 04:06:35 +03:00
parent 69f5df163a
commit f850f40f78
11 changed files with 4609 additions and 5282 deletions

View File

@ -23,7 +23,7 @@ class VideoController extends Controller
public function index()
{
$videos = Video::public()->latest()->paginate(12);
$videos = Video::public()->latest()->get();
return view('videos.index', compact('videos'));
}
@ -42,7 +42,7 @@ class VideoController extends Controller
->orWhere('description', 'like', "%{$query}%");
})
->latest()
->paginate(12);
->get();
return view('videos.index', compact('videos', 'query'));
}
@ -491,7 +491,7 @@ class VideoController extends Controller
->where('status', 'ready')
->with('user')
->latest()
->paginate(12);
->get();
return view('videos.shorts', compact('videos'));
}

View File

@ -1,14 +1,41 @@
<!DOCTYPE html>
<html>
<head>
<style>
body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; }
.container { max-width: 600px; margin: 0 auto; padding: 20px; }
.header { background: #e61e1e; color: white; padding: 20px; text-align: center; }
.content { padding: 20px; background: #f9f9f9; }
.footer { text-align: center; padding: 20px; color: #666; font-size: 12px; }
body {
font-family: Arial, sans-serif;
line-height: 1.6;
color: #333;
}
.container {
max-width: 600px;
margin: 0 auto;
padding: 20px;
}
.header {
background: #e61e1e;
color: white;
padding: 20px;
text-align: center;
}
.content {
padding: 20px;
background: #f9f9f9;
}
.footer {
text-align: center;
padding: 20px;
color: #666;
font-size: 12px;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
@ -19,16 +46,44 @@
<p>Hi {{ $userName }},</p>
<p>Your video <strong>"{{ $video->title }}"</strong> has been uploaded successfully!</p>
<p>Your video is now being processed and will be available shortly.</p>
<p>Video Details:</p>
<ul>
<li>Size: {{ round($video->size / 1024 / 1024, 2) }} MB</li>
<li>Orientation: {{ $video->orientation }}</li>
</ul>
<p><a href="{{ url('/videos/' . $video->id) }}" style="background: #e61e1e; color: white; padding: 10px 20px; text-decoration: none; border-radius: 5px;">View Video</a></p>
<p>Check out your uploaded video:</p>
<div style="margin: 20px 0; text-align: center;">
@if ($video->thumbnail)
<a href="{{ url('/videos/' . $video->id) }}">
<img src="{{ asset('storage/thumbnails/' . $video->thumbnail) }}" alt="{{ $video->title }}"
style="max-width: 100%; height: auto; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.3); display: block; margin: 0 auto;">
</a>
@else
<div
style="width: 100%; height: 200px; background: linear-gradient(45deg, #e61e1e, #ff4757); border-radius: 12px; display: flex; align-items: center; justify-content: center; margin: 0 auto; color: white; font-size: 18px; font-weight: bold; box-shadow: 0 8px 24px rgba(230,30,30,0.4);">
<i class="bi bi-play-circle-fill" style="font-size: 48px; margin-right: 16px;"></i>
{{ Str::limit($video->title, 30) }}
</div>
<p style="margin-top: 12px; color: #666; font-size: 14px;">Thumbnail generating...</p>
@endif
</div>
<div style="background: #f0f0f0; padding: 16px; border-radius: 8px; margin: 20px 0;">
<h4 style="margin-top: 0; color: #333;">Video Details:</h4>
<ul style="margin: 0; padding-left: 20px;">
<li><strong>Title:</strong> {{ $video->title }}</li>
<li><strong>Size:</strong> {{ round($video->size / 1024 / 1024, 2) }} MB</li>
<li><strong>Orientation:</strong> {{ $video->orientation ?? 'Horizontal' }}</li>
</ul>
</div>
<p style="text-align: center;">
<a href="{{ url('/videos/' . $video->id) }}"
style="background: #e61e1e; color: white; padding: 12px 24px; text-decoration: none; border-radius: 25px; font-weight: 600; font-size: 16px; display: inline-block; box-shadow: 0 4px 12px rgba(230,30,30,0.4);">▶️
Watch Video</a>
</p>
</div>
<div class="footer">
<p>TAKEONE Video Platform</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,29 @@
<div class="modal fade" id="confirmDeleteModal{{ $commentId }}" tabindex="-1" aria-labelledby="confirmDeleteModalLabel{{ $commentId }}" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-sm">
<div class="modal-content" style="background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 12px;">
<div class="modal-header" style="border-bottom: 1px solid var(--border-color); padding: 20px;">
<h5 class="modal-title" id="confirmDeleteModalLabel{{ $commentId }}" style="color: var(--text-primary); font-weight: 600;">
<i class="bi bi-exclamation-triangle-fill" style="color: var(--brand-red); margin-right: 8px;"></i>
Delete Comment
</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body" style="padding: 20px;">
<p style="color: var(--text-primary); margin-bottom: 16px; line-height: 1.5;">
Are you sure you want to delete this comment? This action cannot be undone.
</p>
<div class="comment-preview" style="background: var(--bg-primary); border-radius: 8px; padding: 12px; font-size: 14px; line-height: 1.4;">
{{ Str::limit($body, 100) }}
</div>
</div>
<div class="modal-footer" style="border-top: 1px solid var(--border-color); padding: 16px 20px; gap: 8px;">
<button type="button" class="btn" style="background: var(--bg-primary); color: var(--text-primary); border: 1px solid var(--border-color); padding: 8px 16px; border-radius: 6px; font-weight: 500;" data-bs-dismiss="modal">
Cancel
</button>
<button type="button" class="btn" style="background: var(--brand-red); color: white; padding: 8px 16px; border-radius: 6px; font-weight: 500; border: none;" onclick="deleteCommentWithModal({{ $commentId }})">
Delete
</button>
</div>
</div>
</div>
</div>

View File

@ -1,6 +1,7 @@
@extends('layouts.app')
@section('title', isset($query) ? 'Search: ' . $query . ' | ' . config('app.name') : 'Video Gallery | ' . config('app.name'))
@section('title', isset($query) ? 'Search: ' . $query . ' | ' . config('app.name') : 'Video Gallery | ' .
config('app.name'))
@section('extra_styles')
<style>
@ -113,7 +114,8 @@
text-decoration: none;
}
.yt-channel-name, .yt-video-meta {
.yt-channel-name,
.yt-video-meta {
color: var(--text-secondary);
font-size: 14px;
}
@ -151,7 +153,9 @@
font-size: 14px;
}
.yt-more-dropdown-item:hover { background: var(--border-color); }
.yt-more-dropdown-item:hover {
background: var(--border-color);
}
/* Empty State */
.yt-empty {
@ -192,7 +196,10 @@
.yt-video-grid {
grid-template-columns: 1fr;
}
.yt-header-right .yt-icon-btn:not(:last-child) { display: none; }
.yt-header-right .yt-icon-btn:not(:last-child) {
display: none;
}
}
</style>
@endsection
@ -234,7 +241,6 @@
@endforeach
</div>
<div class="mt-4">{{ $videos->links() }}</div>
@endif
@include('layouts.partials.share-modal')
@ -275,14 +281,18 @@ document.addEventListener('touchstart', function(e) {
});
playVideo(card);
}
}, { passive: true });
}, {
passive: true
});
document.addEventListener('touchend', function(e) {
const card = e.target.closest('.yt-video-card');
if (card) {
stopVideo(card);
}
}, { passive: true });
}, {
passive: true
});
</script>
@endsection
@ -293,26 +303,34 @@ document.addEventListener('touchend', function(e) {
.yt-video-grid {
gap: 12px;
}
.yt-video-thumb {
border-radius: 8px;
}
.yt-video-info {
gap: 8px;
margin-top: 8px;
}
.yt-channel-icon {
width: 28px;
height: 28px;
}
.yt-video-title {
font-size: 13px;
}
.yt-channel-name, .yt-video-meta {
.yt-channel-name,
.yt-video-meta {
font-size: 11px;
}
.search-info {
padding: 12px;
}
.search-info h2 {
font-size: 16px;
}

View File

@ -37,9 +37,11 @@
@if ($video->user)
<div class="shorts-channel-row">
@if ($video->user->avatar_url)
<img src="{{ $video->user->avatar_url }}" class="shorts-avatar" alt="{{ $video->user->name }}">
<img src="{{ $video->user->avatar_url }}" class="shorts-avatar"
alt="{{ $video->user->name }}">
@else
<div class="shorts-avatar-placeholder">{{ substr($video->user->name, 0, 1) }}</div>
<div class="shorts-avatar-placeholder">
{{ substr($video->user->name, 0, 1) }}</div>
@endif
<span class="shorts-channel-name">{{ $video->user->name }}</span>
</div>
@ -69,12 +71,7 @@
@endforelse
</div>
<!-- Pagination -->
@if($videos->hasPages())
<div class="shorts-pagination">
{{ $videos->links() }}
</div>
@endif
</div>
</div>
@ -213,7 +210,8 @@
gap: 8px;
}
.shorts-avatar, .shorts-avatar-placeholder {
.shorts-avatar,
.shorts-avatar-placeholder {
width: 24px;
height: 24px;
border-radius: 50%;
@ -350,4 +348,3 @@
}
</style>
@endsection

View File

@ -492,7 +492,8 @@
</button>
@auth
<!-- Quick Watch Later Button -->
<form method="POST" action="{{ route('videos.watchLater', $video->id) }}" class="d-inline" style="display: inline;">
<form method="POST" action="{{ route('videos.watchLater', $video->id) }}" class="d-inline"
style="display: inline;">
@csrf
<button type="submit" class="yt-action-btn" title="Watch Later">
<i class="bi bi-clock"></i>
@ -613,7 +614,8 @@
<img src="{{ Auth::user()->avatar_url }}" class="channel-avatar" style="width: 40px; height: 40px;"
alt="{{ Auth::user()->name }}">
<div style="flex: 1;">
<textarea id="commentBody" class="form-control" placeholder="Add a comment... Use @ to mention someone" rows="3"
<textarea id="commentBody" class="form-control" placeholder="Add a comment... Use @ to mention someone"
rows="3"
style="background: var(--bg-secondary); border: 1px solid var(--border-color); color: var(--text-primary); border-radius: 8px; padding: 12px; width: 100%; resize: none;"></textarea>
<div style="display: flex; gap: 8px; margin-top: 8px; justify-content: flex-end;">
<button type="button" class="yt-action-btn"
@ -708,7 +710,9 @@
<h3 style="font-size: 16px; font-weight: 500; margin-bottom: 12px;">
<i class="bi bi-collection-play" style="margin-right: 8px;"></i>
{{ $playlist->name }}
<span style="font-weight: 400; color: var(--text-secondary); font-size: 14px;">({{ $playlistVideos->count() }} videos)</span>
<span
style="font-weight: 400; color: var(--text-secondary); font-size: 14px;">({{ $playlistVideos->count() }}
videos)</span>
</h3>
<div class="recommended-videos-list">
@foreach ($playlistVideos as $index => $playlistVideo)
@ -724,7 +728,8 @@
alt="{{ $playlistVideo->title }}">
@endif
@if ($playlistVideo->duration)
<span class="yt-video-duration">{{ gmdate('i:s', $playlistVideo->duration) }}</span>
<span
class="yt-video-duration">{{ gmdate('i:s', $playlistVideo->duration) }}</span>
@endif
@if ($playlistVideo->is_shorts)
<span class="yt-shorts-badge"
@ -733,7 +738,8 @@
</span>
@endif
<!-- Playlist position indicator -->
<span style="position: absolute; bottom: 4px; left: 4px; background: rgba(0,0,0,0.8); color: white; padding: 2px 6px; border-radius: 4px; font-size: 12px; font-weight: 500;">
<span
style="position: absolute; bottom: 4px; left: 4px; background: rgba(0,0,0,0.8); color: white; padding: 2px 6px; border-radius: 4px; font-size: 12px; font-weight: 500;">
{{ $index + 1 }}
</span>
</div>
@ -754,7 +760,8 @@
@endforeach
</div>
@if ($playlist->canEdit(Auth::user()))
<a href="{{ route('playlists.show', $playlist->id) }}" class="yt-action-btn" style="margin-top: 12px; display: inline-block;">
<a href="{{ route('playlists.show', $playlist->id) }}" class="yt-action-btn"
style="margin-top: 12px; display: inline-block;">
<i class="bi bi-pencil"></i> Edit Playlist
</a>
@endif

View File

@ -234,6 +234,47 @@
background: var(--border-color);
}
.action-btn,
.comments-section .action-btn {
border: none;
border-radius: 8px;
padding: 8px 14px;
font-size: 0.82rem;
font-weight: 500;
cursor: pointer;
background: var(--bg-secondary);
border: 1px solid var(--border-color);
color: var(--text-primary);
display: flex;
align-items: center;
gap: 6px;
transition: all 0.2s ease;
}
.action-btn:hover,
.comments-section .action-btn:hover {
background: var(--border-color);
transform: translateY(-1px);
}
.action-btn:active,
.comments-section .action-btn:active {
transform: translateY(0);
}
.action-btn svg,
.action-btn i,
.comments-section .action-btn svg,
.comments-section .action-btn i {
flex-shrink: 0;
}
.action-btn.comment-btn {
background: var(--brand-red);
color: white;
border-color: var(--brand-red);
}
.yt-action-btn.liked {
color: var(--brand-red);
}
@ -530,8 +571,9 @@
@if (Auth::id() !== $video->user_id)
<button class="subscribe-btn">Subscribe</button>
@else
<button class="yt-action-btn" onclick="openEditVideoModal({{ $video->id }})">
<i class="bi bi-pencil"></i> Edit
<button class="action-btn" onclick="openEditVideoModal({{ $video->id }})">
<i class="bi bi-pencil"></i>
<span>Edit</span>
</button>
@endif
@else
@ -543,7 +585,7 @@
action="{{ $video->isLikedBy(Auth::user()) ? route('videos.unlike', $video->id) : route('videos.like', $video->id) }}"
class="d-inline">
@csrf
<button type="submit" class="yt-action-btn {{ $video->isLikedBy(Auth::user()) ? 'liked' : '' }}">
<button type="submit" class="action-btn {{ $video->isLikedBy(Auth::user()) ? 'liked' : '' }}">
<i
class="bi {{ $video->isLikedBy(Auth::user()) ? 'bi-hand-thumbs-up-fill' : 'bi-hand-thumbs-up' }}"></i>
{{ $video->like_count > 0 ? number_format($video->like_count) : 'Like' }}
@ -556,11 +598,22 @@
@endauth
@if ($video->isShareable())
<button class="yt-action-btn"
<button class="action-btn"
onclick="openShareModal('{{ $video->share_url }}', '{{ addslashes($video->title) }}')">
<i class="bi bi-share"></i> Share
</button>
@endif
<!-- Save to Playlist Button -->
<button class="action-btn" onclick="openAddToPlaylistModal({{ $video->id }})">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"></path>
</svg>
<span>Save</span>
</button>
</div>
</div>
@ -646,15 +699,20 @@
<div class="comment-form" style="display: flex; gap: 12px; margin-bottom: 24px;">
<img src="{{ Auth::user()->avatar_url }}" class="channel-avatar" style="width: 40px; height: 40px;"
alt="{{ Auth::user()->name }}">
<div style="flex: 1;">
<textarea id="commentBody" class="form-control" placeholder="Add a comment... Use @ to mention someone" rows="3"
style="background: var(--bg-secondary); border: 1px solid var(--border-color); color: var(--text-primary); border-radius: 8px; padding: 12px; width: 100%; resize: none;"></textarea>
<div style="display: flex; gap: 8px; margin-top: 8px; justify-content: flex-end;">
<button type="button" class="yt-action-btn"
onclick="document.getElementById('commentBody').value = ''">Cancel</button>
<button type="button" class="yt-action-btn" style="background: var(--brand-red); color: white;"
onclick="submitComment({{ $video->id }})">Comment</button>
</div>
<div style="flex: 1; display: flex; align-items: center; gap: 8px;">
<textarea id="commentBody" class="form-control" placeholder="Add a comment... Use @ to mention someone"
rows="1"
style="background: transparent; border: none; border-bottom: 2px solid var(--border-color); color: var(--text-primary); border-radius: 0; padding: 12px 0 8px 0; flex: 1; margin: 0; height: 40px; font-size: 14px; outline: none; overflow: hidden;"></textarea>
<button type="button" class="action-btn"
onclick="document.getElementById('commentBody').value = ''" style="flex-shrink: 0;">
<i class="bi bi-x-lg"></i>
<span>Cancel</span>
</button>
<button type="button" class="action-btn comment-btn"
onclick="submitComment({{ $video->id }})" style="flex-shrink: 0;">
<i class="bi bi-chat-dots"></i>
<span>Comment</span>
</button>
</div>
</div>
@else
@ -690,17 +748,51 @@
})
})
.then(response => response.json())
.catch(error => {
console.error('Error:', error);
alert('Failed to post comment: ' + error);
})
.then(data => {
if (data.success) {
if (data && data.success) {
document.getElementById('commentBody').value = '';
location.reload();
addCommentToList(data.comment);
} else {
alert('Failed to post comment');
}
});
}
function deleteComment(commentId) {
if (!confirm('Are you sure you want to delete this comment?')) return;
function addCommentToList(comment) {
const commentsList = document.getElementById('commentsList');
const commentHtml = `
<div class="comment-item" style="display: flex; gap: 12px; margin-bottom: 16px;" id="comment-${comment.id}">
<img src="${comment.user.avatar_url}" class="channel-avatar" style="width: 36px; height: 36px; flex-shrink: 0;" alt="${comment.user.name}">
<div style="flex: 1;">
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 4px;">
<span style="font-weight: 600; font-size: 14px;">${comment.user.name}</span>
<span style="color: var(--text-secondary); font-size: 12px;">just now</span>
</div>
<div class="comment-body" style="font-size: 14px; line-height: 1.5; word-wrap: break-word;">
${comment.body.replace(/@(\\w+)/g, '<span style="color: #3ea6ff; font-weight: 500;">@$1</span>')}
</div>
<div style="display: flex; gap: 12px; margin-top: 8px;">
<button onclick="toggleReplyForm(${comment.id})" style="background: none; border: none; color: var(--text-secondary); font-size: 12px; font-weight: 600; cursor: pointer; padding: 0;">
Reply
</button>
</div>
</div>
</div>
`;
commentsList.insertAdjacentHTML('afterbegin', commentHtml);
const commentCount = document.querySelector('h3 span');
if (commentCount) {
const count = parseInt(commentCount.textContent.match(/\\((\\d+)\\)/)?.[2] || 0) + 1;
commentCount.textContent = `(${count})`;
}
}
function deleteComment(commentId) {
if (confirm('Are you sure you want to delete this comment?')) {
fetch(`/comments/${commentId}`, {
method: 'DELETE',
headers: {
@ -710,10 +802,16 @@
.then(response => response.json())
.then(data => {
if (data.success) {
location.reload();
document.getElementById('comment-' + commentId).remove();
const commentCount = document.querySelector('h3 span');
if (commentCount) {
const count = parseInt(commentCount.textContent.match(/\\((\\d+)\\)/)?.[2] || 0) - 1;
commentCount.textContent = `(${count})`;
}
}
});
}
}
document.addEventListener('DOMContentLoaded', function() {
const commentTexts = document.querySelectorAll('.comment-body');
@ -756,7 +854,9 @@
<h3 style="font-size: 16px; font-weight: 500; margin-bottom: 12px;">
<i class="bi bi-collection-play" style="margin-right: 8px;"></i>
{{ $playlist->name }}
<span style="font-weight: 400; color: var(--text-secondary); font-size: 14px;">({{ $playlistVideos->count() }} videos)</span>
<span
style="font-weight: 400; color: var(--text-secondary); font-size: 14px;">({{ $playlistVideos->count() }}
videos)</span>
</h3>
<div class="recommended-videos-list">
@foreach ($playlistVideos as $index => $playlistVideo)
@ -772,7 +872,8 @@
alt="{{ $playlistVideo->title }}">
@endif
@if ($playlistVideo->duration)
<span class="yt-video-duration">{{ gmdate('i:s', $playlistVideo->duration) }}</span>
<span
class="yt-video-duration">{{ gmdate('i:s', $playlistVideo->duration) }}</span>
@endif
@if ($playlistVideo->is_shorts)
<span class="yt-shorts-badge"
@ -781,7 +882,8 @@
</span>
@endif
<!-- Playlist position indicator -->
<span style="position: absolute; bottom: 4px; left: 4px; background: rgba(0,0,0,0.8); color: white; padding: 2px 6px; border-radius: 4px; font-size: 12px; font-weight: 500;">
<span
style="position: absolute; bottom: 4px; left: 4px; background: rgba(0,0,0,0.8); color: white; padding: 2px 6px; border-radius: 4px; font-size: 12px; font-weight: 500;">
{{ $index + 1 }}
</span>
</div>
@ -802,7 +904,8 @@
@endforeach
</div>
@if ($playlist->canEdit(Auth::user()))
<a href="{{ route('playlists.show', $playlist->id) }}" class="yt-action-btn" style="margin-top: 12px; display: inline-block;">
<a href="{{ route('playlists.show', $playlist->id) }}" class="yt-action-btn"
style="margin-top: 12px; display: inline-block;">
<i class="bi bi-pencil"></i> Edit Playlist
</a>
@endif
@ -938,11 +1041,9 @@
// Keyboard navigation
document.addEventListener('keydown', function(e) {
// Only handle if not typing in an input
if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') {
return;
}
if (e.key === 'ArrowLeft') {
e.preventDefault();
goToPreviousVideo();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,10 @@
@section('extra_styles')
<style>
/* Video Section */
.yt-video-section { flex: 1; min-width: 0; }
.yt-video-section {
flex: 1;
min-width: 0;
}
/* Video Player */
.video-container {
@ -28,11 +31,26 @@
width: auto;
}
.video-container.portrait { aspect-ratio: 9/16; max-width: 50vh; }
.video-container.square { aspect-ratio: 1/1; max-width: 70vh; }
.video-container.ultrawide { aspect-ratio: 21/9; max-width: 100%; }
.video-container.portrait {
aspect-ratio: 9/16;
max-width: 50vh;
}
.video-container video { width: 100%; height: 100%; object-fit: contain; }
.video-container.square {
aspect-ratio: 1/1;
max-width: 70vh;
}
.video-container.ultrawide {
aspect-ratio: 21/9;
max-width: 100%;
}
.video-container video {
width: 100%;
height: 100%;
object-fit: contain;
}
/* Playlist Navigation Controls */
.playlist-controls {
@ -52,7 +70,9 @@
}
.video-container:hover .playlist-controls,
.playlist-controls.visible { opacity: 1; }
.playlist-controls.visible {
opacity: 1;
}
.playlist-nav-btn {
background: transparent;
@ -67,10 +87,22 @@
transition: background 0.2s ease;
}
.playlist-nav-btn:hover { background: rgba(255, 255, 255, 0.2); }
.playlist-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.playlist-nav-btn:disabled:hover { background: transparent; }
.playlist-nav-btn i { font-size: 20px; }
.playlist-nav-btn:hover {
background: rgba(255, 255, 255, 0.2);
}
.playlist-nav-btn:disabled {
opacity: 0.3;
cursor: not-allowed;
}
.playlist-nav-btn:disabled:hover {
background: transparent;
}
.playlist-nav-btn i {
font-size: 20px;
}
.playlist-nav-label {
font-size: 12px;
@ -97,13 +129,25 @@
white-space: nowrap;
}
.autoplay-switch { position: relative; width: 36px; height: 20px; }
.autoplay-switch input { opacity: 0; width: 0; height: 0; }
.autoplay-switch {
position: relative;
width: 36px;
height: 20px;
}
.autoplay-switch input {
opacity: 0;
width: 0;
height: 0;
}
.autoplay-slider {
position: absolute;
cursor: pointer;
top: 0; left: 0; right: 0; bottom: 0;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #666;
transition: 0.3s;
border-radius: 20px;
@ -121,8 +165,13 @@
border-radius: 50%;
}
.autoplay-switch input:checked + .autoplay-slider { background-color: var(--brand-red); }
.autoplay-switch input:checked + .autoplay-slider:before { transform: translateX(16px); }
.autoplay-switch input:checked+.autoplay-slider {
background-color: var(--brand-red);
}
.autoplay-switch input:checked+.autoplay-slider:before {
transform: translateX(16px);
}
/* Keyboard hint */
.keyboard-hint {
@ -154,7 +203,12 @@
gap: 12px;
}
.video-stats-left { display: flex; align-items: center; gap: 16px; color: var(--text-secondary); }
.video-stats-left {
display: flex;
align-items: center;
gap: 16px;
color: var(--text-secondary);
}
.video-actions {
display: flex;
@ -176,9 +230,54 @@
font-weight: 500;
}
.yt-action-btn:hover { background: var(--border-color); }
.yt-action-btn:hover {
background: var(--border-color);
}
.yt-action-btn.liked { color: var(--brand-red); }
.action-btn,
.comments-section .action-btn {
border: none;
border-radius: 8px;
padding: 8px 14px;
font-size: 0.82rem;
font-weight: 500;
cursor: pointer;
background: var(--bg-secondary);
border: 1px solid var(--border-color);
color: var(--text-primary);
display: flex;
align-items: center;
gap: 6px;
transition: all 0.2s ease;
}
.action-btn:hover,
.comments-section .action-btn:hover {
background: var(--border-color);
transform: translateY(-1px);
}
.action-btn:active,
.comments-section .action-btn:active {
transform: translateY(0);
}
.action-btn svg,
.action-btn i,
.comments-section .action-btn svg,
.comments-section .action-btn i {
flex-shrink: 0;
}
.action-btn.comment-btn {
background: var(--brand-red);
color: white;
border-color: var(--brand-red);
}
.yt-action-btn.liked {
color: var(--brand-red);
}
/* Channel Row */
.channel-row {
@ -195,7 +294,10 @@
}
.channel-avatar {
width: 48px; height: 48px; border-radius: 50%; background: #555;
width: 48px;
height: 48px;
border-radius: 50%;
background: #555;
}
.channel-name {
@ -256,9 +358,16 @@
flex-shrink: 0;
}
.sidebar-thumb img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-thumb img {
width: 100%;
height: 100%;
object-fit: cover;
}
.sidebar-info { flex: 1; min-width: 0; }
.sidebar-info {
flex: 1;
min-width: 0;
}
.sidebar-title {
font-size: 14px;
@ -270,26 +379,45 @@
overflow: hidden;
}
.sidebar-meta { font-size: 12px; color: var(--text-secondary); }
.sidebar-meta {
font-size: 12px;
color: var(--text-secondary);
}
/* Responsive */
@media (max-width: 1300px) {
.yt-sidebar-container { width: 300px; }
.yt-sidebar-container {
width: 300px;
}
}
@media (max-width: 991px) {
.yt-main { margin-left: 0; flex-direction: column; }
.yt-sidebar-container { width: 100%; }
.sidebar-video-card { flex-direction: column; }
.sidebar-thumb { width: 100%; }
.yt-main {
margin-left: 0;
flex-direction: column;
}
.yt-sidebar-container {
width: 100%;
}
.sidebar-video-card {
flex-direction: column;
}
.sidebar-thumb {
width: 100%;
}
.video-layout-container {
flex-direction: column !important;
}
.yt-video-section {
width: 100% !important;
flex: none !important;
}
.yt-sidebar-container {
width: 100% !important;
margin-top: 16px;
@ -297,32 +425,49 @@
}
@media (max-width: 576px) {
.video-stats-row { flex-direction: column; align-items: flex-start; }
.video-actions { width: 100%; overflow-x: auto; justify-content: flex-start; }
.yt-main { padding: 12px !important; }
.video-stats-row {
flex-direction: column;
align-items: flex-start;
}
.video-actions {
width: 100%;
overflow-x: auto;
justify-content: flex-start;
}
.yt-main {
padding: 12px !important;
}
.video-container {
max-height: 50vh !important;
border-radius: 0 !important;
}
.video-container video {
object-fit: contain !important;
}
.video-title {
font-size: 16px !important;
margin: 12px 0 6px !important;
}
.channel-row {
flex-direction: column;
align-items: flex-start !important;
gap: 12px;
}
.channel-info {
width: 100%;
}
.subscribe-btn {
width: 100%;
}
.video-description {
padding: 12px !important;
}
@ -338,7 +483,8 @@
<!-- Video Section -->
<div class="yt-video-section">
<!-- Video Player -->
<div class="video-container @if($video->orientation === 'portrait') portrait @elseif($video->orientation === 'square') square @elseif($video->orientation === 'ultrawide') ultrawide @endif" id="videoContainer">
<div class="video-container @if ($video->orientation === 'portrait') portrait @elseif($video->orientation === 'square') square @elseif($video->orientation === 'ultrawide') ultrawide @endif"
id="videoContainer">
<video id="videoPlayer" controls playsinline preload="metadata" autoplay>
<source src="{{ route('videos.stream', $video->id) }}" type="video/mp4">
</video>
@ -401,17 +547,21 @@
</div>
<!-- Channel Row - All in one line -->
<div class="channel-row" style="display: flex; align-items: center; justify-content: space-between; padding: 12px 0; flex-wrap: wrap; gap: 16px;">
<div class="channel-row"
style="display: flex; align-items: center; justify-content: space-between; padding: 12px 0; flex-wrap: wrap; gap: 16px;">
<div style="display: flex; align-items: center; gap: 12px;">
<a href="{{ route('channel', $video->user_id) }}" class="channel-info text-decoration-none" style="color: inherit; display: flex; align-items: center; gap: 12px;">
<a href="{{ route('channel', $video->user_id) }}" class="channel-info text-decoration-none"
style="color: inherit; display: flex; align-items: center; gap: 12px;">
@if ($video->user)
<img src="{{ $video->user->avatar_url }}" class="channel-avatar" style="width: 40px; height: 40px; border-radius: 50%;" alt="{{ $video->user->name }}">
<img src="{{ $video->user->avatar_url }}" class="channel-avatar"
style="width: 40px; height: 40px; border-radius: 50%;" alt="{{ $video->user->name }}">
@else
<div class="channel-avatar" style="width: 40px; height: 40px; border-radius: 50%;"></div>
@endif
<div>
<div class="channel-name" style="font-weight: 600;">{{ $video->user->name ?? 'Unknown' }}</div>
<div class="channel-subs" style="font-size: 12px; color: var(--text-secondary);">{{ number_format($video->user->subscriber_count ?? 0) }} subscribers</div>
<div class="channel-subs" style="font-size: 12px; color: var(--text-secondary);">
{{ number_format($video->user->subscriber_count ?? 0) }} subscribers</div>
</div>
</a>
</div>
@ -421,8 +571,9 @@
@if (Auth::id() !== $video->user_id)
<button class="subscribe-btn">Subscribe</button>
@else
<button class="yt-action-btn" onclick="openEditVideoModal({{ $video->id }})">
<i class="bi bi-pencil"></i> Edit
<button class="action-btn" onclick="openEditVideoModal({{ $video->id }})">
<i class="bi bi-pencil"></i>
<span>Edit</span>
</button>
@endif
@else
@ -430,10 +581,13 @@
@endauth
@auth
<form method="POST" action="{{ $video->isLikedBy(Auth::user()) ? route('videos.unlike', $video->id) : route('videos.like', $video->id) }}" class="d-inline">
<form method="POST"
action="{{ $video->isLikedBy(Auth::user()) ? route('videos.unlike', $video->id) : route('videos.like', $video->id) }}"
class="d-inline">
@csrf
<button type="submit" class="yt-action-btn {{ $video->isLikedBy(Auth::user()) ? 'liked' : '' }}">
<i class="bi {{ $video->isLikedBy(Auth::user()) ? 'bi-hand-thumbs-up-fill' : 'bi-hand-thumbs-up' }}"></i>
<button type="submit" class="action-btn {{ $video->isLikedBy(Auth::user()) ? 'liked' : '' }}">
<i
class="bi {{ $video->isLikedBy(Auth::user()) ? 'bi-hand-thumbs-up-fill' : 'bi-hand-thumbs-up' }}"></i>
{{ $video->like_count > 0 ? number_format($video->like_count) : 'Like' }}
</button>
</form>
@ -444,10 +598,22 @@
@endauth
@if ($video->isShareable())
<button class="yt-action-btn" onclick="openShareModal('{{ $video->share_url }}', '{{ addslashes($video->title) }}')">
<button class="action-btn"
onclick="openShareModal('{{ $video->share_url }}', '{{ addslashes($video->title) }}')">
<i class="bi bi-share"></i> Share
</button>
@endif
<!-- Save to Playlist Button -->
<button class="action-btn" onclick="openAddToPlaylistModal({{ $video->id }})">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"></path>
</svg>
<span>Save</span>
</button>
</div>
</div>
@ -459,7 +625,8 @@
$needsExpand = strlen($fullDescription) > 200;
@endphp
<div class="video-description-box" style="background: var(--bg-secondary); border-radius: 12px; padding: 12px; margin-bottom: 16px;">
<div class="video-description-box"
style="background: var(--bg-secondary); border-radius: 12px; padding: 12px; margin-bottom: 16px;">
<div class="description-stats" style="font-size: 14px; font-weight: 500; margin-bottom: 8px;">
<span>{{ number_format($video->view_count) }} views</span>
<span></span>
@ -475,7 +642,8 @@
<div class="description-full" id="descFull" style="display: none;">
<span class="description-text">{!! Str::markdown($fullDescription) !!}</span>
</div>
<button onclick="toggleDescription()" id="descToggleBtn" style="background: none; border: none; color: var(--text-primary); font-weight: 600; font-size: 14px; cursor: pointer; padding: 0; margin-top: 4px;">
<button onclick="toggleDescription()" id="descToggleBtn"
style="background: none; border: none; color: var(--text-primary); font-weight: 600; font-size: 14px; cursor: pointer; padding: 0; margin-top: 4px;">
Show more
</button>
@else
@ -503,37 +671,53 @@
</script>
<style>
.video-description-box .description-text { font-size: 14px; line-height: 1.5; color: var(--text-primary); }
.video-description-box .description-text p { margin-bottom: 8px; }
.video-description-box .description-text a { color: #3ea6ff; }
.video-description-box .description-text {
font-size: 14px;
line-height: 1.5;
color: var(--text-primary);
}
.video-description-box .description-text p {
margin-bottom: 8px;
}
.video-description-box .description-text a {
color: #3ea6ff;
}
</style>
@endif
<!-- Comment Section -->
<div class="comments-section" style="margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border-color);">
<div class="comments-section"
style="margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border-color);">
<h3 style="font-size: 18px; font-weight: 600; margin-bottom: 16px;">
Comments <span style="color: var(--text-secondary); font-weight: 400;">({{ $video->comment_count }})</span>
Comments <span
style="color: var(--text-secondary); font-weight: 400;">({{ $video->comment_count }})</span>
</h3>
@auth
<div class="comment-form" style="display: flex; gap: 12px; margin-bottom: 24px;">
<img src="{{ Auth::user()->avatar_url }}" class="channel-avatar" style="width: 40px; height: 40px;" alt="{{ Auth::user()->name }}">
<div style="flex: 1;">
<textarea
id="commentBody"
class="form-control"
placeholder="Add a comment... Use @ to mention someone"
rows="3"
style="background: var(--bg-secondary); border: 1px solid var(--border-color); color: var(--text-primary); border-radius: 8px; padding: 12px; width: 100%; resize: none;"
></textarea>
<div style="display: flex; gap: 8px; margin-top: 8px; justify-content: flex-end;">
<button type="button" class="yt-action-btn" onclick="document.getElementById('commentBody').value = ''">Cancel</button>
<button type="button" class="yt-action-btn" style="background: var(--brand-red); color: white;" onclick="submitComment({{ $video->id }})">Comment</button>
</div>
<img src="{{ Auth::user()->avatar_url }}" class="channel-avatar" style="width: 40px; height: 40px;"
alt="{{ Auth::user()->name }}">
<div style="flex: 1; display: flex; align-items: center; gap: 8px;">
<textarea id="commentBody" class="form-control" placeholder="Add a comment... Use @ to mention someone"
rows="1"
style="background: transparent; border: none; border-bottom: 2px solid var(--border-color); color: var(--text-primary); border-radius: 0; padding: 12px 0 8px 0; flex: 1; margin: 0; height: 40px; font-size: 14px; outline: none; overflow: hidden;"></textarea>
<button type="button" class="action-btn"
onclick="document.getElementById('commentBody').value = ''" style="flex-shrink: 0;">
<i class="bi bi-x-lg"></i>
<span>Cancel</span>
</button>
<button type="button" class="action-btn comment-btn"
onclick="submitComment({{ $video->id }})" style="flex-shrink: 0;">
<i class="bi bi-chat-dots"></i>
<span>Comment</span>
</button>
</div>
</div>
@else
<div style="margin-bottom: 24px; padding: 16px; background: var(--bg-secondary); border-radius: 8px; text-align: center;">
<div
style="margin-bottom: 24px; padding: 16px; background: var(--bg-secondary); border-radius: 8px; text-align: center;">
<a href="{{ route('login') }}" style="color: var(--brand-red);">Sign in</a> to comment
</div>
@endauth
@ -542,7 +726,8 @@
@forelse($video->comments()->whereNull('parent_id')->with('user', 'replies.user')->latest()->get() as $comment)
@include('videos.partials.comment', ['comment' => $comment])
@empty
<p style="color: var(--text-secondary); text-align: center; padding: 20px;">No comments yet. Be the first to comment!</p>
<p style="color: var(--text-secondary); text-align: center; padding: 20px;">No comments yet. Be the
first to comment!</p>
@endforelse
</div>
</div>
@ -558,20 +743,56 @@
'Content-Type': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
body: JSON.stringify({ body: body })
body: JSON.stringify({
body: body
})
})
.then(response => response.json())
.catch(error => {
console.error('Error:', error);
alert('Failed to post comment: ' + error);
})
.then(data => {
if (data.success) {
if (data && data.success) {
document.getElementById('commentBody').value = '';
location.reload();
addCommentToList(data.comment);
} else {
alert('Failed to post comment');
}
});
}
function deleteComment(commentId) {
if (!confirm('Are you sure you want to delete this comment?')) return;
function addCommentToList(comment) {
const commentsList = document.getElementById('commentsList');
const commentHtml = `
<div class="comment-item" style="display: flex; gap: 12px; margin-bottom: 16px;" id="comment-${comment.id}">
<img src="${comment.user.avatar_url}" class="channel-avatar" style="width: 36px; height: 36px; flex-shrink: 0;" alt="${comment.user.name}">
<div style="flex: 1;">
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 4px;">
<span style="font-weight: 600; font-size: 14px;">${comment.user.name}</span>
<span style="color: var(--text-secondary); font-size: 12px;">just now</span>
</div>
<div class="comment-body" style="font-size: 14px; line-height: 1.5; word-wrap: break-word;">
${comment.body.replace(/@(\\w+)/g, '<span style="color: #3ea6ff; font-weight: 500;">@$1</span>')}
</div>
<div style="display: flex; gap: 12px; margin-top: 8px;">
<button onclick="toggleReplyForm(${comment.id})" style="background: none; border: none; color: var(--text-secondary); font-size: 12px; font-weight: 600; cursor: pointer; padding: 0;">
Reply
</button>
</div>
</div>
</div>
`;
commentsList.insertAdjacentHTML('afterbegin', commentHtml);
const commentCount = document.querySelector('h3 span');
if (commentCount) {
const count = parseInt(commentCount.textContent.match(/\\((\\d+)\\)/)?.[2] || 0) + 1;
commentCount.textContent = `(${count})`;
}
}
function deleteComment(commentId) {
if (confirm('Are you sure you want to delete this comment?')) {
fetch(`/comments/${commentId}`, {
method: 'DELETE',
headers: {
@ -581,15 +802,22 @@
.then(response => response.json())
.then(data => {
if (data.success) {
location.reload();
document.getElementById('comment-' + commentId).remove();
const commentCount = document.querySelector('h3 span');
if (commentCount) {
const count = parseInt(commentCount.textContent.match(/\\((\\d+)\\)/)?.[2] || 0) - 1;
commentCount.textContent = `(${count})`;
}
}
});
}
}
document.addEventListener('DOMContentLoaded', function() {
const commentTexts = document.querySelectorAll('.comment-body');
commentTexts.forEach(text => {
const html = text.innerHTML.replace(/@(\w+)/g, '<span style="color: #3ea6ff; font-weight: 500;">@$1</span>');
const html = text.innerHTML.replace(/@(\w+)/g,
'<span style="color: #3ea6ff; font-weight: 500;">@$1</span>');
text.innerHTML = html;
});
});
@ -605,7 +833,10 @@
'Content-Type': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
body: JSON.stringify({ body: body, parent_id: parentId })
body: JSON.stringify({
body: body,
parent_id: parentId
})
})
.then(response => response.json())
.then(data => {
@ -623,7 +854,9 @@
<h3 style="font-size: 16px; font-weight: 500; margin-bottom: 12px;">
<i class="bi bi-collection-play" style="margin-right: 8px;"></i>
{{ $playlist->name }}
<span style="font-weight: 400; color: var(--text-secondary); font-size: 14px;">({{ $playlistVideos->count() }} videos)</span>
<span
style="font-weight: 400; color: var(--text-secondary); font-size: 14px;">({{ $playlistVideos->count() }}
videos)</span>
</h3>
<div class="recommended-videos-list">
@foreach ($playlistVideos as $index => $playlistVideo)
@ -632,20 +865,25 @@
onclick="window.location.href='{{ route('videos.show', $playlistVideo->id) }}?playlist={{ $playlist->id }}'">
<div class="sidebar-thumb" style="position: relative;">
@if ($playlistVideo->thumbnail)
<img src="{{ asset('storage/thumbnails/' . $playlistVideo->thumbnail) }}" alt="{{ $playlistVideo->title }}">
<img src="{{ asset('storage/thumbnails/' . $playlistVideo->thumbnail) }}"
alt="{{ $playlistVideo->title }}">
@else
<img src="https://picsum.photos/seed/{{ $playlistVideo->id }}/320/180" alt="{{ $playlistVideo->title }}">
<img src="https://picsum.photos/seed/{{ $playlistVideo->id }}/320/180"
alt="{{ $playlistVideo->title }}">
@endif
@if ($playlistVideo->duration)
<span class="yt-video-duration">{{ gmdate('i:s', $playlistVideo->duration) }}</span>
<span
class="yt-video-duration">{{ gmdate('i:s', $playlistVideo->duration) }}</span>
@endif
@if ($playlistVideo->is_shorts)
<span class="yt-shorts-badge" style="position: absolute; top: 8px; left: 8px; font-size: 10px; padding: 2px 6px;">
<span class="yt-shorts-badge"
style="position: absolute; top: 8px; left: 8px; font-size: 10px; padding: 2px 6px;">
<i class="bi bi-collection-play-fill"></i> SHORTS
</span>
@endif
<!-- Playlist position indicator -->
<span style="position: absolute; bottom: 4px; left: 4px; background: rgba(0,0,0,0.8); color: white; padding: 2px 6px; border-radius: 4px; font-size: 12px; font-weight: 500;">
<span
style="position: absolute; bottom: 4px; left: 4px; background: rgba(0,0,0,0.8); color: white; padding: 2px 6px; border-radius: 4px; font-size: 12px; font-weight: 500;">
{{ $index + 1 }}
</span>
</div>
@ -657,7 +895,8 @@
</div>
<div class="sidebar-meta">
<div>{{ $playlistVideo->user->name ?? 'Unknown' }}</div>
<div>{{ number_format($playlistVideo->view_count) }} views {{ $playlistVideo->created_at->diffForHumans() }}</div>
<div>{{ number_format($playlistVideo->view_count) }} views
{{ $playlistVideo->created_at->diffForHumans() }}</div>
</div>
</div>
</div>
@ -665,7 +904,8 @@
@endforeach
</div>
@if ($playlist->canEdit(Auth::user()))
<a href="{{ route('playlists.show', $playlist->id) }}" class="yt-action-btn" style="margin-top: 12px; display: inline-block;">
<a href="{{ route('playlists.show', $playlist->id) }}" class="yt-action-btn"
style="margin-top: 12px; display: inline-block;">
<i class="bi bi-pencil"></i> Edit Playlist
</a>
@endif
@ -674,30 +914,36 @@
@if ($recommendedVideos && $recommendedVideos->count() > 0)
<div class="recommended-videos-list">
@foreach ($recommendedVideos as $recVideo)
<div class="sidebar-video-card" onclick="window.location.href='{{ route('videos.show', $recVideo->id) }}'">
<div class="sidebar-video-card"
onclick="window.location.href='{{ route('videos.show', $recVideo->id) }}'">
<div class="sidebar-thumb">
@if ($recVideo->thumbnail)
<img src="{{ asset('storage/thumbnails/' . $recVideo->thumbnail) }}" alt="{{ $recVideo->title }}">
<img src="{{ asset('storage/thumbnails/' . $recVideo->thumbnail) }}"
alt="{{ $recVideo->title }}">
@else
<img src="https://picsum.photos/seed/{{ $recVideo->id }}/320/180" alt="{{ $recVideo->title }}">
<img src="https://picsum.photos/seed/{{ $recVideo->id }}/320/180"
alt="{{ $recVideo->title }}">
@endif
@if ($recVideo->duration)
<span class="yt-video-duration">{{ gmdate('i:s', $recVideo->duration) }}</span>
@endif
@if ($recVideo->is_shorts)
<span class="yt-shorts-badge" style="position: absolute; top: 8px; left: 8px; font-size: 10px; padding: 2px 6px;">
<span class="yt-shorts-badge"
style="position: absolute; top: 8px; left: 8px; font-size: 10px; padding: 2px 6px;">
<i class="bi bi-collection-play-fill"></i> SHORTS
</span>
@endif
</div>
<div class="sidebar-info">
<div class="sidebar-title">
<i class="bi {{ match($recVideo->type) { 'music' => 'bi-music-note', 'match' => 'bi-trophy', default => 'bi-film' } }}" style="color: #ef4444; margin-right: 4px; font-size: 12px;"></i>
<i class="bi {{ match ($recVideo->type) {'music' => 'bi-music-note','match' => 'bi-trophy',default => 'bi-film'} }}"
style="color: #ef4444; margin-right: 4px; font-size: 12px;"></i>
{{ Str::limit($recVideo->title, 60) }}
</div>
<div class="sidebar-meta">
<div>{{ $recVideo->user->name ?? 'Unknown' }}</div>
<div>{{ number_format($recVideo->view_count) }} views {{ $recVideo->created_at->diffForHumans() }}</div>
<div>{{ number_format($recVideo->view_count) }} views
{{ $recVideo->created_at->diffForHumans() }}</div>
</div>
</div>
</div>
@ -741,7 +987,11 @@
videoPlayer.volume = 0.5;
var playPromise = videoPlayer.play();
if (playPromise !== undefined) {
playPromise.then(function() { console.log('Video autoplayed'); }).catch(function(error) { console.log('Autoplay blocked'); });
playPromise.then(function() {
console.log('Video autoplayed');
}).catch(function(error) {
console.log('Autoplay blocked');
});
}
// Handle video ended - autoplay next
@ -766,8 +1016,12 @@
});
// Initially show for a few seconds
setTimeout(function() { playlistControls.classList.add('visible'); }, 2000);
setTimeout(function() { playlistControls.classList.remove('visible'); }, 6000);
setTimeout(function() {
playlistControls.classList.add('visible');
}, 2000);
setTimeout(function() {
playlistControls.classList.remove('visible');
}, 6000);
}
// Autoplay toggle handler
@ -787,18 +1041,29 @@
// Keyboard navigation
document.addEventListener('keydown', function(e) {
if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') { return; }
if (e.key === 'ArrowLeft') { e.preventDefault(); goToPreviousVideo(); }
else if (e.key === 'ArrowRight') { e.preventDefault(); goToNextVideo(); }
if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') {
return;
}
if (e.key === 'ArrowLeft') {
e.preventDefault();
goToPreviousVideo();
} else if (e.key === 'ArrowRight') {
e.preventDefault();
goToNextVideo();
}
});
});
function goToPreviousVideo() {
if (previousVideoUrl) { window.location.href = previousVideoUrl; }
if (previousVideoUrl) {
window.location.href = previousVideoUrl;
}
}
function goToNextVideo() {
if (nextVideoUrl) { window.location.href = nextVideoUrl; }
if (nextVideoUrl) {
window.location.href = nextVideoUrl;
}
}
</script>
@endsection

View File

@ -0,0 +1,45 @@
<script>
function showDeleteCommentModal(commentId, commentBody) {
const modalId = 'confirmDeleteModal' + commentId;
const modalElement = document.getElementById(modalId);
if (modalElement) {
const modal = new bootstrap.Modal(modalElement);
modal.show();
window.currentDeleteCommentId = commentId;
}
}
function deleteCommentWithModal(commentId) {
fetch(`/comments/${commentId}`, {
method: 'DELETE',
headers: {
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content'),
'Accept': 'application/json'
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
document.getElementById('comment-' + commentId).remove();
const commentCount = document.querySelector('h3 span');
if (commentCount) {
const count = parseInt(commentCount.textContent.match(/\\((\\d+)\\)/)?.[2] || 0) - 1;
commentCount.textContent = `(${Math.max(0, count)})`;
}
// Close modal
const modalId = 'confirmDeleteModal' + commentId;
const modalElement = document.getElementById(modalId);
if (modalElement) {
const modal = bootstrap.Modal.getInstance(modalElement);
modal.hide();
}
} else {
alert('Failed to delete comment');
}
})
.catch(error => {
console.error('Error:', error);
alert('Failed to delete comment');
});
}
</script>