feat: add copy stream URL menu and desktop sidebar collapse (closes #43, closes #45)

This commit is contained in:
Trevor Mears
2026-01-16 18:04:24 -08:00
parent 196b9520b7
commit b467471590
7 changed files with 327 additions and 5 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "nodecast-tv", "name": "nodecast-tv",
"version": "1.4.4", "version": "1.5.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "nodecast-tv", "name": "nodecast-tv",
"version": "1.4.4", "version": "1.5.0",
"description": "Modern IPTV Player", "description": "Modern IPTV Player",
"license": "GPL-3.0-only", "license": "GPL-3.0-only",
"main": "server/index.js", "main": "server/index.js",
+130
View File
@@ -360,6 +360,93 @@ h4 {
border-bottom: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border);
} }
.sidebar-header-row {
display: flex;
align-items: center;
gap: var(--space-sm);
}
.sidebar-header-row .search-wrapper {
flex: 1;
}
.sidebar-collapse-btn {
display: none;
/* Hidden on mobile */
flex-shrink: 0;
padding: var(--space-xs);
}
.sidebar-collapse-btn .icon {
transition: transform 0.2s ease;
}
/* Desktop collapse button visibility */
@media (min-width: 769px) {
.sidebar-collapse-btn {
display: flex;
}
}
/* Collapsed sidebar state (desktop only) */
.channel-sidebar.collapsed {
width: 0;
min-width: 0;
overflow: hidden;
border-right: none;
}
.channel-sidebar.collapsed .sidebar-header,
.channel-sidebar.collapsed .channel-list {
opacity: 0;
visibility: hidden;
}
/* Expand button when sidebar is collapsed */
.sidebar-expand-btn {
display: none;
position: absolute;
left: 0;
top: calc(var(--navbar-height) + var(--space-md));
z-index: 50;
background: var(--glass-bg);
backdrop-filter: blur(12px);
border: 1px solid var(--glass-border);
border-left: none;
border-radius: 0 var(--radius-md) var(--radius-md) 0;
padding: var(--space-sm);
cursor: pointer;
color: var(--color-text-primary);
transition: opacity 0.3s ease, background var(--transition-fast);
opacity: 0;
pointer-events: none;
}
.sidebar-expand-btn:hover {
background: var(--color-bg-hover);
}
.sidebar-expand-btn .icon {
width: 20px;
height: 20px;
}
/* Show expand button when sidebar is collapsed */
.home-layout.sidebar-collapsed .sidebar-expand-btn {
display: flex;
}
/* Fade in expand button with player controls */
.home-layout.sidebar-collapsed .sidebar-expand-btn.visible {
opacity: 1;
pointer-events: auto;
}
/* Smooth transitions */
.channel-sidebar {
transition: width 0.2s ease, min-width 0.2s ease;
}
.search-input { .search-input {
width: 100%; width: 100%;
padding: var(--space-sm) var(--space-md); padding: var(--space-sm) var(--space-md);
@@ -3888,4 +3975,47 @@ kbd {
.next-info h4 { .next-info h4 {
max-width: none; max-width: none;
} }
}
/* Player Overflow Menu */
.player-overflow-wrapper {
position: relative;
}
.player-overflow-menu {
position: absolute;
bottom: 100%;
right: 0;
margin-bottom: var(--space-sm);
background: var(--glass-bg);
backdrop-filter: blur(12px);
border: 1px solid var(--glass-border);
border-radius: var(--radius-md);
min-width: 180px;
overflow: hidden;
z-index: 100;
}
.overflow-menu-item {
display: flex;
align-items: center;
gap: var(--space-sm);
width: 100%;
padding: var(--space-sm) var(--space-md);
background: transparent;
border: none;
color: var(--color-text-primary);
font-size: 0.875rem;
cursor: pointer;
transition: background var(--transition-fast);
}
.overflow-menu-item:hover {
background: var(--color-bg-hover);
}
.overflow-menu-item .icon {
width: 18px;
height: 18px;
flex-shrink: 0;
} }
+54 -3
View File
@@ -97,12 +97,27 @@
<!-- Overlay for drawer --> <!-- Overlay for drawer -->
<div class="channel-sidebar-overlay" id="channel-sidebar-overlay"></div> <div class="channel-sidebar-overlay" id="channel-sidebar-overlay"></div>
<!-- Expand button (visible when sidebar collapsed on desktop) -->
<button class="sidebar-expand-btn" id="sidebar-expand-btn" title="Expand sidebar">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="icon">
<path d="M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z" />
</svg>
</button>
<!-- Channel Sidebar --> <!-- Channel Sidebar -->
<aside class="channel-sidebar" id="channel-sidebar"> <aside class="channel-sidebar" id="channel-sidebar">
<div class="sidebar-header"> <div class="sidebar-header">
<div class="search-wrapper"> <div class="sidebar-header-row">
<input type="text" id="channel-search" placeholder="Search channels..." class="search-input"> <div class="search-wrapper">
<button type="button" class="search-clear" title="Clear search">&times;</button> <input type="text" id="channel-search" placeholder="Search channels..." class="search-input">
<button type="button" class="search-clear" title="Clear search">&times;</button>
</div>
<button id="sidebar-collapse-btn" class="btn btn-sm btn-ghost sidebar-collapse-btn"
title="Collapse sidebar">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="icon">
<path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z" />
</svg>
</button>
</div> </div>
<div class="sidebar-controls"> <div class="sidebar-controls">
<select id="source-select" class="source-select"> <select id="source-select" class="source-select">
@@ -201,6 +216,24 @@
<path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" /> <path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" />
</svg> </svg>
</button> </button>
<!-- Overflow Menu -->
<div class="player-overflow-wrapper">
<button class="watch-btn" id="btn-overflow" title="More options">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="icon">
<path
d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" />
</svg>
</button>
<div class="player-overflow-menu hidden" id="player-overflow-menu">
<button class="overflow-menu-item" id="btn-copy-url">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="icon">
<path
d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z" />
</svg>
Copy Stream URL
</button>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@@ -707,6 +740,24 @@
<path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" /> <path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" />
</svg> </svg>
</button> </button>
<!-- Overflow Menu -->
<div class="player-overflow-wrapper">
<button class="watch-btn" id="watch-overflow" title="More options">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="icon">
<path
d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" />
</svg>
</button>
<div class="player-overflow-menu hidden" id="watch-overflow-menu">
<button class="overflow-menu-item" id="watch-copy-url">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="icon">
<path
d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z" />
</svg>
Copy Stream URL
</button>
</div>
</div>
</div> </div>
</div> </div>
+23
View File
@@ -82,6 +82,29 @@ class App {
}); });
} }
// Desktop sidebar collapse toggle
const sidebarCollapseBtn = document.getElementById('sidebar-collapse-btn');
const sidebarExpandBtn = document.getElementById('sidebar-expand-btn');
const homeLayout = document.querySelector('.home-layout');
const toggleSidebarCollapse = () => {
channelSidebar?.classList.toggle('collapsed');
homeLayout?.classList.toggle('sidebar-collapsed');
// Persist preference
const isCollapsed = channelSidebar?.classList.contains('collapsed');
localStorage.setItem('sidebarCollapsed', isCollapsed ? 'true' : 'false');
};
sidebarCollapseBtn?.addEventListener('click', toggleSidebarCollapse);
sidebarExpandBtn?.addEventListener('click', toggleSidebarCollapse);
// Restore sidebar state from localStorage
if (localStorage.getItem('sidebarCollapsed') === 'true') {
channelSidebar?.classList.add('collapsed');
homeLayout?.classList.add('sidebar-collapsed');
}
// Navigation handling // Navigation handling
document.querySelectorAll('.nav-link').forEach(link => { document.querySelectorAll('.nav-link').forEach(link => {
link.addEventListener('click', (e) => { link.addEventListener('click', (e) => {
+59
View File
@@ -275,14 +275,41 @@ class VideoPlayer {
this.togglePictureInPicture(); this.togglePictureInPicture();
}); });
// Overflow Menu
const btnOverflow = document.getElementById('btn-overflow');
const overflowMenu = document.getElementById('player-overflow-menu');
btnOverflow?.addEventListener('click', (e) => {
e.stopPropagation();
overflowMenu?.classList.toggle('hidden');
});
// Copy Stream URL
const btnCopyUrl = document.getElementById('btn-copy-url');
btnCopyUrl?.addEventListener('click', (e) => {
e.stopPropagation();
this.copyStreamUrl();
overflowMenu?.classList.add('hidden');
});
// Close overflow menu when clicking outside
document.addEventListener('click', (e) => {
if (overflowMenu && !overflowMenu.classList.contains('hidden') &&
!overflowMenu.contains(e.target) && e.target !== btnOverflow) {
overflowMenu.classList.add('hidden');
}
});
this.container.addEventListener('dblclick', () => this.toggleFullscreen()); this.container.addEventListener('dblclick', () => this.toggleFullscreen());
// Overlay Auto-hide Logic // Overlay Auto-hide Logic
let overlayTimeout; let overlayTimeout;
const sidebarExpandBtn = document.getElementById('sidebar-expand-btn');
const showOverlay = () => { const showOverlay = () => {
this.controlsOverlay.classList.remove('hidden'); this.controlsOverlay.classList.remove('hidden');
this.container.style.cursor = 'default'; this.container.style.cursor = 'default';
sidebarExpandBtn?.classList.add('visible');
resetOverlayTimer(); resetOverlayTimer();
}; };
@@ -290,6 +317,7 @@ class VideoPlayer {
if (!this.video.paused) { if (!this.video.paused) {
this.controlsOverlay.classList.add('hidden'); this.controlsOverlay.classList.add('hidden');
this.container.style.cursor = 'none'; this.container.style.cursor = 'none';
sidebarExpandBtn?.classList.remove('visible');
} }
}; };
@@ -351,6 +379,37 @@ class VideoPlayer {
} }
} }
/**
* Copy current stream URL to clipboard
*/
copyStreamUrl() {
if (!this.currentUrl) {
console.warn('[Player] No stream URL to copy');
return;
}
let streamUrl = this.currentUrl;
// If it's a relative URL, make it absolute
if (streamUrl.startsWith('/')) {
streamUrl = window.location.origin + streamUrl;
}
navigator.clipboard.writeText(streamUrl).then(() => {
// Show brief feedback
const btn = document.getElementById('btn-copy-url');
if (btn) {
const originalText = btn.textContent;
btn.textContent = '✓ Copied!';
setTimeout(() => {
btn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="icon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg> Copy Stream URL`;
}, 1500);
}
console.log('[Player] Stream URL copied:', streamUrl);
}).catch(() => {
prompt('Copy this URL:', streamUrl);
});
}
/** /**
+59
View File
@@ -106,6 +106,31 @@ class WatchPage {
const pipBtn = document.getElementById('watch-pip'); const pipBtn = document.getElementById('watch-pip');
pipBtn?.addEventListener('click', () => this.togglePictureInPicture()); pipBtn?.addEventListener('click', () => this.togglePictureInPicture());
// Overflow Menu
const overflowBtn = document.getElementById('watch-overflow');
const overflowMenu = document.getElementById('watch-overflow-menu');
overflowBtn?.addEventListener('click', (e) => {
e.stopPropagation();
overflowMenu?.classList.toggle('hidden');
});
// Copy Stream URL
const copyUrlBtn = document.getElementById('watch-copy-url');
copyUrlBtn?.addEventListener('click', (e) => {
e.stopPropagation();
this.copyStreamUrl();
overflowMenu?.classList.add('hidden');
});
// Close overflow menu when clicking outside
document.addEventListener('click', (e) => {
if (overflowMenu && !overflowMenu.classList.contains('hidden') &&
!overflowMenu.contains(e.target) && e.target !== overflowBtn) {
overflowMenu.classList.add('hidden');
}
});
// Progress bar // Progress bar
this.progressSlider?.addEventListener('input', (e) => this.seek(e.target.value)); this.progressSlider?.addEventListener('input', (e) => this.seek(e.target.value));
@@ -210,6 +235,9 @@ class WatchPage {
} }
async loadVideo(url) { async loadVideo(url) {
// Store the URL for copy functionality
this.currentUrl = url;
// Stop any existing playback // Stop any existing playback
this.stop(); this.stop();
@@ -428,6 +456,37 @@ class WatchPage {
} }
} }
/**
* Copy current stream URL to clipboard
*/
copyStreamUrl() {
if (!this.currentUrl) {
console.warn('[WatchPage] No stream URL to copy');
return;
}
let streamUrl = this.currentUrl;
// If it's a relative URL, make it absolute
if (streamUrl.startsWith('/')) {
streamUrl = window.location.origin + streamUrl;
}
navigator.clipboard.writeText(streamUrl).then(() => {
// Show brief feedback
const btn = document.getElementById('watch-copy-url');
if (btn) {
btn.textContent = '✓ Copied!';
setTimeout(() => {
btn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="icon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg> Copy Stream URL`;
}, 1500);
}
console.log('[WatchPage] Stream URL copied:', streamUrl);
}).catch(() => {
prompt('Copy this URL:', streamUrl);
});
}
// === UI Updates === // === UI Updates ===
updateProgress() { updateProgress() {