latest update

This commit is contained in:
ghassan committed 2026-04-05 03:30:22 +03:00
1 parent 64eadfaf56
commit 2a562b99f1
25 files changed
+2617 -2337

No files matched your search

+3 -3
View File
@@ -509,7 +509,7 @@
<span>Trending</span>
</a>
<a href="{{ auth()->check() ? route('videos.create') : route('login') }}" class="yt-bottom-nav-item {{ request()->routeIs('videos.create') ? 'active' : '' }}">
<i class="bi bi-play-circle-fill"></i>
<i class="bi bi-plus-circle-fill"></i>
<span>Upload</span>
</a>
<a href="{{ route('history') }}" class="yt-bottom-nav-item {{ request()->routeIs('history') ? 'active' : '' }}">
@@ -687,8 +687,8 @@
if (modal) {
modal.hide();
}
// Reload the page
window.location.reload();
// Redirect to videos index
window.location.href = "{{ route('videos.index') }}";
} else if (response.status === 403) {
alert('You do not have permission to delete this video.');
} else if (response.status === 404) {
@@ -1,10 +1,14 @@
<!-- Add to Playlist Modal -->
<div id="addToPlaylistModal" class="playlist-modal-overlay" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); z-index: 9999; align-items: center; justify-content: center;">
<div class="playlist-modal-content" style="background: #282828; border-radius: 12px; width: 90%; max-width: 380px; max-height: 85vh; display: flex; flex-direction: column; box-shadow: 0 8px 32px rgba(0,0,0,0.5); overflow: hidden;">
<div id="addToPlaylistModal" class="playlist-modal-overlay"
style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); z-index: 9999; align-items: center; justify-content: center;">
<div class="playlist-modal-content"
style="background: #282828; border-radius: 12px; width: 90%; max-width: 380px; max-height: 85vh; display: flex; flex-direction: column; box-shadow: 0 8px 32px rgba(0,0,0,0.5); overflow: hidden;">
<!-- Header -->
<div class="playlist-modal-header" style="display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid #3f3f3f;">
<div class="playlist-modal-header"
style="display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid #3f3f3f;">
<h2 style="font-size: 18px; font-weight: 600; margin: 0; color: #fff;">Save to playlist</h2>
<button type="button" id="closePlaylistModalBtn" style="background: transparent; border: none; color: #aaa; cursor: pointer; font-size: 24px; padding: 4px; line-height: 1; border-radius: 50%; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; transition: all 0.2s;">
<button type="button" id="closePlaylistModalBtn"
style="background: transparent; border: none; color: #aaa; cursor: pointer; font-size: 24px; padding: 4px; line-height: 1; border-radius: 50%; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; transition: all 0.2s;">
<i class="bi bi-x-lg"></i>
</button>
</div>
@@ -13,24 +17,29 @@
<div style="padding: 16px 24px; flex: 1; overflow-y: auto;">
<!-- Create New Playlist Option -->
@auth
<div style="margin-bottom: 16px;">
<button onclick="showCreatePlaylistInModal()" class="create-playlist-btn" style="width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: transparent; border: none; color: #fff; cursor: pointer; border-radius: 8px; transition: background 0.2s; font-size: 14px;">
<span style="width: 36px; height: 36px; background: #3f3f3f; border-radius: 50%; display: flex; align-items: center; justify-content: center;">
<i class="bi bi-plus-lg" style="font-size: 18px;"></i>
</span>
<span style="font-weight: 500;">Create new playlist</span>
</button>
</div>
<!-- Create Playlist Form (Hidden by default) -->
<div id="createPlaylistInModal" style="display: none; margin-bottom: 16px; padding: 16px; background: #1f1f1f; border-radius: 10px; border: 1px solid #3f3f3f;">
<input type="text" id="newPlaylistName" placeholder="Playlist name"
style="width: 100%; padding: 12px 14px; margin-bottom: 12px; border: 1px solid #3f3f3f; border-radius: 8px; background: #121212; color: #fff; font-size: 14px; outline: none; transition: border-color 0.2s;">
<div style="display: flex; gap: 10px; justify-content: flex-end;">
<button onclick="hideCreatePlaylistInModal()" style="padding: 8px 16px; background: #3f3f3f; color: #fff; border: none; border-radius: 18px; cursor: pointer; font-size: 14px; font-weight: 500; transition: background 0.2s;">Cancel</button>
<button onclick="createPlaylistFromModal()" style="padding: 8px 16px; background: #e61e1e; color: #fff; border: none; border-radius: 18px; cursor: pointer; font-size: 14px; font-weight: 500; transition: background 0.2s;">Create</button>
<div style="margin-bottom: 16px;">
<button onclick="showCreatePlaylistInModal()" class="create-playlist-btn"
style="width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: transparent; border: none; color: #fff; cursor: pointer; border-radius: 8px; transition: background 0.2s; font-size: 14px;">
<span
style="width: 36px; height: 36px; background: #3f3f3f; border-radius: 50%; display: flex; align-items: center; justify-content: center;">
<i class="bi bi-plus-lg" style="font-size: 18px;"></i>
</span>
<span style="font-weight: 500;">Create new playlist</span>
</button>
</div>
<!-- Create Playlist Form (Hidden by default) -->
<div id="createPlaylistInModal"
style="display: none; margin-bottom: 16px; padding: 16px; background: #1f1f1f; border-radius: 10px; border: 1px solid #3f3f3f;">
<input type="text" id="newPlaylistName" placeholder="Playlist name"
style="width: 100%; padding: 12px 14px; margin-bottom: 12px; border: 1px solid #3f3f3f; border-radius: 8px; background: #121212; color: #fff; font-size: 14px; outline: none; transition: border-color 0.2s;">
<div style="display: flex; gap: 10px; justify-content: flex-end;">
<button onclick="hideCreatePlaylistInModal()"
style="padding: 8px 16px; background: #3f3f3f; color: #fff; border: none; border-radius: 18px; cursor: pointer; font-size: 14px; font-weight: 500; transition: background 0.2s;">Cancel</button>
<button onclick="createPlaylistFromModal()"
style="padding: 8px 16px; background: #e61e1e; color: #fff; border: none; border-radius: 18px; cursor: pointer; font-size: 14px; font-weight: 500; transition: background 0.2s;">Create</button>
</div>
</div>
</div>
@endauth
<!-- Playlist List Container -->
@@ -41,7 +50,8 @@
<!-- Footer -->
<div style="padding: 16px 24px; border-top: 1px solid #3f3f3f;">
<a href="{{ route('playlists.index') }}" style="display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-size: 14px; padding: 10px 12px; border-radius: 8px; transition: background 0.2s;">
<a href="{{ route('playlists.index') }}"
style="display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-size: 14px; padding: 10px 12px; border-radius: 8px; transition: background 0.2s;">
<i class="bi bi-collection-play" style="font-size: 18px;"></i>
<span style="font-weight: 500;">View all playlists</span>
</a>
@@ -50,161 +60,189 @@
</div>
<style>
/* Modal Overlay with proper centering */
.playlist-modal-overlay {
backdrop-filter: blur(2px);
}
/* Modal Overlay with proper centering */
.playlist-modal-overlay {
backdrop-filter: blur(2px);
}
/* Modal Content */
.playlist-modal-content {
font-family: "Roboto", "Arial", sans-serif;
}
/* Modal Content */
.playlist-modal-content {
font-family: "Roboto", "Arial", sans-serif;
}
/* Header button hover */
.playlist-modal-header button:hover {
background: #3f3f3f !important;
color: #fff !important;
}
/* Header button hover */
.playlist-modal-header button:hover {
background: #3f3f3f !important;
color: #fff !important;
}
/* Create playlist button hover */
.create-playlist-btn:hover {
background: #3f3f3f !important;
}
/* Create playlist button hover */
.create-playlist-btn:hover {
background: #3f3f3f !important;
}
/* Input focus */
#newPlaylistName:focus {
border-color: #e61e1e !important;
}
/* Input focus */
#newPlaylistName:focus {
border-color: #e61e1e !important;
}
/* Button hover effects */
#createPlaylistInModal button:hover {
opacity: 0.9;
}
/* Button hover effects */
#createPlaylistInModal button:hover {
opacity: 0.9;
}
#createPlaylistInModal button:last-child:hover {
background: #cc1a1a !important;
}
#createPlaylistInModal button:last-child:hover {
background: #cc1a1a !important;
}
/* Footer link hover */
.playlist-modal-footer a:hover {
background: #3f3f3f;
}
/* Footer link hover */
.playlist-modal-footer a:hover {
background: #3f3f3f;
}
/* Playlist items */
.playlist-item {
border-radius: 8px;
}
/* Playlist items */
.playlist-item {
border-radius: 8px;
}
.playlist-item:hover {
background: #3f3f3f !important;
}
.playlist-item:hover {
background: #3f3f3f !important;
}
/* Scrollbar styling */
#playlistListContainer::-webkit-scrollbar {
width: 8px;
}
/* Scrollbar styling */
#playlistListContainer::-webkit-scrollbar {
width: 8px;
}
#playlistListContainer::-webkit-scrollbar-track {
background: transparent;
}
#playlistListContainer::-webkit-scrollbar-track {
background: transparent;
}
#playlistListContainer::-webkit-scrollbar-thumb {
background: #555;
border-radius: 4px;
}
#playlistListContainer::-webkit-scrollbar-thumb {
background: #555;
border-radius: 4px;
}
#playlistListContainer::-webkit-scrollbar-thumb:hover {
background: #666;
}
#playlistListContainer::-webkit-scrollbar-thumb:hover {
background: #666;
}
/* Mobile centering fix */
@media (max-width: 576px) {
body.modal-open {
overflow: hidden !important;
}
.playlist-modal-overlay {
min-height: 100vh !important;
height: 100dvh !important;
padding: 70px 0 80px 0 !important;
box-sizing: border-box !important;
width: 100vw !important;
left: 0 !important;
}
.playlist-modal-content {
max-height: 90dvh !important;
margin: 0 auto !important;
width: 95vw !important;
max-width: 95vw !important;
border-radius: 16px !important;
}
}
</style>
<script>
let currentModalVideoId = null;
let currentModalVideoId = null;
// Check if user is authenticated
function isAuthenticated() {
return {{ auth()->check() ? 'true' : 'false' }};
}
// Check if user is authenticated
function isAuthenticated() {
return {{ auth()->check() ? 'true' : 'false' }};
}
// Close button event listener
document.addEventListener('DOMContentLoaded', function() {
const closeBtn = document.getElementById('closePlaylistModalBtn');
if (closeBtn) {
closeBtn.addEventListener('click', function(e) {
e.stopPropagation();
closeAddToPlaylistModal();
// Close button event listener
document.addEventListener('DOMContentLoaded', function() {
const closeBtn = document.getElementById('closePlaylistModalBtn');
if (closeBtn) {
closeBtn.addEventListener('click', function(e) {
e.stopPropagation();
closeAddToPlaylistModal();
});
}
});
function openAddToPlaylistModal(videoId) {
currentModalVideoId = videoId;
// Close any open dropdown menus first
const activeDropdowns = document.querySelectorAll('.dropdown-menu.show');
activeDropdowns.forEach(function(dropdown) {
dropdown.classList.remove('show');
});
}
});
function openAddToPlaylistModal(videoId) {
currentModalVideoId = videoId;
// Also close Bootstrap dropdowns
const dropdownToggles = document.querySelectorAll('.dropdown-toggle[aria-expanded="true"]');
dropdownToggles.forEach(function(toggle) {
toggle.click();
});
// Close any open dropdown menus first
const activeDropdowns = document.querySelectorAll('.dropdown-menu.show');
activeDropdowns.forEach(function(dropdown) {
dropdown.classList.remove('show');
});
document.body.classList.add('modal-open');
// Also close Bootstrap dropdowns
const dropdownToggles = document.querySelectorAll('.dropdown-toggle[aria-expanded="true"]');
dropdownToggles.forEach(function(toggle) {
toggle.click();
});
const modal = document.getElementById('addToPlaylistModal');
modal.style.display = 'flex';
document.getElementById('createPlaylistInModal').style.display = 'none';
// Load playlists when modal opens
loadPlaylistsForModal(videoId);
}
function closeAddToPlaylistModal() {
const modal = document.getElementById('addToPlaylistModal');
modal.style.display = 'none';
currentModalVideoId = null;
}
// Close modal when clicking outside
document.getElementById('addToPlaylistModal').addEventListener('click', function(e) {
if (e.target === this) {
closeAddToPlaylistModal();
}
});
// Close on escape key
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
const modal = document.getElementById('addToPlaylistModal');
if (modal && modal.style.display === 'flex') {
modal.style.display = 'flex';
document.getElementById('createPlaylistInModal').style.display = 'none';
// Load playlists when modal opens
loadPlaylistsForModal(videoId);
}
function closeAddToPlaylistModal() {
const modal = document.getElementById('addToPlaylistModal');
modal.style.display = 'none';
document.body.classList.remove('modal-open');
currentModalVideoId = null;
}
// Close modal when clicking outside
document.getElementById('addToPlaylistModal').addEventListener('click', function(e) {
if (e.target === this) {
closeAddToPlaylistModal();
}
}
});
});
// Load playlists for modal
function loadPlaylistsForModal(videoId) {
const container = document.getElementById('playlistListContainer');
@auth
// Fetch playlists data
fetch('{{ route("playlists.userPlaylists") }}', {
headers: {
'Accept': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}'
// Close on escape key
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
const modal = document.getElementById('addToPlaylistModal');
if (modal && modal.style.display === 'flex') {
closeAddToPlaylistModal();
}
}
})
.then(response => response.json())
.then(data => {
if (data.success && data.playlists && data.playlists.length > 0) {
let html = '';
data.playlists.forEach(function(playlist) {
const isInPlaylist = playlist.video_ids && playlist.video_ids.includes(parseInt(videoId));
const visibilityText = playlist.visibility === 'public' ? 'Public' : 'Private';
const durationText = playlist.formatted_duration || '0m';
html += `
});
// Load playlists for modal
function loadPlaylistsForModal(videoId) {
const container = document.getElementById('playlistListContainer');
@auth
// Fetch playlists data
fetch('{{ route('playlists.userPlaylists') }}', {
headers: {
'Accept': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}'
}
})
.then(response => response.json())
.then(data => {
if (data.success && data.playlists && data.playlists.length > 0) {
let html = '';
data.playlists.forEach(function(playlist) {
const isInPlaylist = playlist.video_ids && playlist.video_ids.includes(parseInt(
videoId));
const visibilityText = playlist.visibility === 'public' ? 'Public' : 'Private';
const durationText = playlist.formatted_duration || '0m';
html += `
<div class="playlist-item" style="display: flex; align-items: flex-start; justify-content: space-between; padding: 12px; border-radius: 8px; cursor: pointer; transition: background 0.2s; margin-bottom: 8px;"
onmouseover="this.style.background='#3f3f3f'"
onmouseout="this.style.background='transparent'"
@@ -238,29 +276,29 @@ function loadPlaylistsForModal(videoId) {
</div>
</div>
`;
});
container.innerHTML = html;
} else {
container.innerHTML = `
});
container.innerHTML = html;
} else {
container.innerHTML = `
<div style="text-align: center; color: #aaa; padding: 30px 20px;">
<i class="bi bi-collection-play" style="font-size: 36px; margin-bottom: 12px; display: block; color: #555;"></i>
<p style="margin: 0 0 8px; font-size: 14px; color: #fff;">No playlists yet</p>
<p style="margin: 0; font-size: 12px;">Create a playlist to save videos</p>
</div>
`;
}
})
.catch(error => {
console.error('Error loading playlists:', error);
container.innerHTML = `
}
})
.catch(error => {
console.error('Error loading playlists:', error);
container.innerHTML = `
<div style="text-align: center; color: #aaa; padding: 30px 20px;">
<i class="bi bi-exclamation-circle" style="font-size: 28px; margin-bottom: 12px; display: block; color: #ef4444;"></i>
<p style="margin: 0; font-size: 14px; color: #fff;">Failed to load playlists</p>
</div>
`;
});
});
@else
container.innerHTML = `
container.innerHTML = `
<div style="text-align: center; color: #aaa; padding: 30px 20px;">
<i class="bi bi-person-circle" style="font-size: 40px; margin-bottom: 12px; display: block; color: #555;"></i>
<p style="margin: 0 0 8px; font-size: 14px; color: #fff;">Sign in to save videos to playlists</p>
@@ -272,96 +310,98 @@ function loadPlaylistsForModal(videoId) {
</div>
`;
@endauth
}
// Toggle video in playlist
function toggleVideoInPlaylist(playlistId, videoId) {
if (!videoId) return;
// Check authentication before adding
if (!isAuthenticated()) {
window.location.href = '{{ route("login") }}?redirect=' + encodeURIComponent(window.location.href);
return;
}
fetch(`/playlists/${playlistId}/videos`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'Accept': 'application/json'
},
body: JSON.stringify({ video_id: videoId })
})
.then(response => response.json())
.then(data => {
if (data.success) {
showToast(data.message || 'Video added to playlist');
// Reload playlists to update checkmarks
loadPlaylistsForModal(videoId);
// Toggle video in playlist
function toggleVideoInPlaylist(playlistId, videoId) {
if (!videoId) return;
// Check authentication before adding
if (!isAuthenticated()) {
window.location.href = '{{ route('login') }}?redirect=' + encodeURIComponent(window.location.href);
return;
}
})
.catch(error => console.error('Error:', error));
}
// Show create playlist form in modal
function showCreatePlaylistInModal() {
// Check authentication before creating playlist
if (!isAuthenticated()) {
window.location.href = '{{ route("login") }}?redirect=' + encodeURIComponent(window.location.href);
return;
}
document.getElementById('createPlaylistInModal').style.display = 'block';
document.getElementById('newPlaylistName').focus();
}
// Hide create playlist form
function hideCreatePlaylistInModal() {
document.getElementById('createPlaylistInModal').style.display = 'none';
document.getElementById('newPlaylistName').value = '';
}
// Create playlist from modal
function createPlaylistFromModal() {
const name = document.getElementById('newPlaylistName').value.trim();
if (!name) {
alert('Please enter a playlist name');
return;
fetch(`/playlists/${playlistId}/videos`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'Accept': 'application/json'
},
body: JSON.stringify({
video_id: videoId
})
})
.then(response => response.json())
.then(data => {
if (data.success) {
showToast(data.message || 'Video added to playlist');
// Reload playlists to update checkmarks
loadPlaylistsForModal(videoId);
}
})
.catch(error => console.error('Error:', error));
}
fetch('{{ route("playlists.store") }}', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'Accept': 'application/json'
},
body: JSON.stringify({
name: name,
visibility: 'private'
})
})
.then(response => response.json())
.then(data => {
if (data.success) {
hideCreatePlaylistInModal();
showToast('Playlist created!');
// Reload playlists to show new playlist
loadPlaylistsForModal(currentModalVideoId);
// Show create playlist form in modal
function showCreatePlaylistInModal() {
// Check authentication before creating playlist
if (!isAuthenticated()) {
window.location.href = '{{ route('login') }}?redirect=' + encodeURIComponent(window.location.href);
return;
}
})
.catch(error => console.error('Error:', error));
}
document.getElementById('createPlaylistInModal').style.display = 'block';
document.getElementById('newPlaylistName').focus();
}
// Simple toast notification
function showToast(message) {
// Remove existing toast if any
const existing = document.querySelector('.playlist-toast');
if (existing) existing.remove();
// Hide create playlist form
function hideCreatePlaylistInModal() {
document.getElementById('createPlaylistInModal').style.display = 'none';
document.getElementById('newPlaylistName').value = '';
}
const toast = document.createElement('div');
toast.className = 'playlist-toast';
toast.style.cssText = `
// Create playlist from modal
function createPlaylistFromModal() {
const name = document.getElementById('newPlaylistName').value.trim();
if (!name) {
alert('Please enter a playlist name');
return;
}
fetch('{{ route('playlists.store') }}', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'Accept': 'application/json'
},
body: JSON.stringify({
name: name,
visibility: 'private'
})
})
.then(response => response.json())
.then(data => {
if (data.success) {
hideCreatePlaylistInModal();
showToast('Playlist created!');
// Reload playlists to show new playlist
loadPlaylistsForModal(currentModalVideoId);
}
})
.catch(error => console.error('Error:', error));
}
// Simple toast notification
function showToast(message) {
// Remove existing toast if any
const existing = document.querySelector('.playlist-toast');
if (existing) existing.remove();
const toast = document.createElement('div');
toast.className = 'playlist-toast';
toast.style.cssText = `
position: fixed;
bottom: 80px;
left: 50%;
@@ -378,24 +418,38 @@ function showToast(message) {
max-width: 90%;
text-align: center;
`;
toast.textContent = message;
document.body.appendChild(toast);
toast.textContent = message;
document.body.appendChild(toast);
setTimeout(() => {
toast.style.animation = 'fadeOutDown 0.3s ease';
setTimeout(() => toast.remove(), 300);
}, 2500);
}
setTimeout(() => {
toast.style.animation = 'fadeOutDown 0.3s ease';
setTimeout(() => toast.remove(), 300);
}, 2500);
}
</script>
<style>
@keyframes fadeInUp {
from { opacity: 0; transform: translateX(-50%) translateY(20px); }
to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes fadeOutDown {
from { opacity: 1; transform: translateX(-50%) translateY(0); }
to { opacity: 0; transform: translateX(-50%) translateY(20px); }
}
</style>
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateX(-50%) translateY(20px);
}
to {
opacity: 1;
transform: translateX(-50%) translateY(0);
}
}
@keyframes fadeOutDown {
from {
opacity: 1;
transform: translateX(-50%) translateY(0);
}
to {
opacity: 0;
transform: translateX(-50%) translateY(20px);
}
}
</style>