feat: add integrated deck queues and track loop functionality

This commit is contained in:
ComputerTech 2026-02-07 20:14:04 +00:00
parent 6246b26925
commit 12c01faa83
5 changed files with 1024 additions and 292 deletions

126
MOBILE_IMPROVEMENTS.md Normal file
View File

@ -0,0 +1,126 @@
# TechDJ Mobile Improvements Summary
## Overview
Comprehensive mobile optimization to make the TechDJ interface more compact, efficient, and user-friendly on mobile devices.
## Key Improvements
### 1. **Redesigned Mobile Tab Navigation**
- **Full-width bottom bar**: Changed from floating pill design to full-width bottom bar
- **More compact**: Reduced height from ~90px to 65px
- **Better visual feedback**: Active tabs now have enhanced glow and slight elevation
- **Improved spacing**: Tighter padding (6px 4px) for more tab buttons in same space
- **Better touch targets**: Minimum 50px width per tab
### 2. **Optimized Deck Layout**
- **Reduced padding**: Deck padding reduced from 15px to 10px
- **Compact disk**: Vinyl disk reduced from 180px to 140px (saves vertical space)
- **Smaller disk label**: 50px instead of 60px
- **Compact waveform**: Height reduced from 100px to 70px
- **Better scrolling**: Decks now properly scroll within viewport
### 3. **Improved Controls**
- **Compact buttons**: All buttons optimized to 40px min-height (still touchable)
- **Better spacing**: Reduced gaps from 8px to 6px throughout
- **Optimized sliders**: Height reduced to 36px for better space usage
- **Compact EQ/Volume faders**: Reduced from 220px to 120px height
- **Better filter controls**: Full-width sliders with 8px height
- **Compact pitch controls**: Smaller bend buttons (36px min-height)
### 4. **Enhanced Library**
- **Compact track rows**: Reduced padding from 12px to 10px
- **Better text sizing**: Track names at 0.85rem (readable but compact)
- **Optimized buttons**: Load buttons at 0.65rem with 36px min-height
- **Horizontal header**: Search and refresh button side-by-side
- **Better scrolling**: Custom thin scrollbars (6px width)
### 5. **Improved Queue Sections**
- **Compact layout**: Reduced padding from 20px to 12px
- **Full height**: Queue sections now use calc(100vh - 65px)
- **Smaller title**: 1.3rem instead of 1.5rem
- **Compact items**: Queue items at 10px padding with 50px min-height
- **Better buttons**: Queue action buttons at 36px min-height
### 6. **Optimized Floating Buttons**
- **Smaller size**: Reduced from 50px to 45px
- **Better positioning**: Moved to 75px from bottom (above tabs)
- **Tighter spacing**: Buttons closer together for easier reach
- **Compact icons**: Font size reduced to 0.8rem
### 7. **Better Visual Polish**
- **Smooth scrolling**: Added webkit smooth scrolling for touch devices
- **Custom scrollbars**: Thin (6px) cyan-themed scrollbars
- **Better transitions**: Smoother tab switching with 0.2s transitions
- **Enhanced active states**: Better visual feedback on active tabs
### 8. **Space Savings**
- **Reduced VU meters**: From 80px to 50px height on mobile
- **Compact text**: Reduced font sizes across the board (0.6-0.95rem)
- **Tighter margins**: Reduced margins from 8-10px to 4-6px
- **Better use of space**: Overall ~30% more compact while maintaining usability
## Mobile-Specific Features
### Portrait Mode
- Full-screen sections with bottom tab navigation
- Optimized for one-handed use
- Floating buttons positioned for thumb reach
- Crossfader integrated with deck views
### Landscape Mode
- Side-by-side deck layout (unchanged, already optimized)
- Full crossfader at bottom
- Compact controls for maximum deck visibility
## Technical Improvements
### Performance
- Reduced repaints with better CSS organization
- Optimized transitions (0.2s instead of 0.3s)
- Better scroll performance with webkit-overflow-scrolling
### Touch Optimization
- Minimum 40px touch targets (WCAG AA compliant)
- Better tap feedback with transform animations
- Optimized slider thumb sizes (28px)
### Visual Consistency
- Consistent spacing (6px, 10px, 12px scale)
- Unified font sizing (0.6rem to 0.95rem range)
- Better color contrast for readability
## Before vs After Metrics
| Metric | Before | After | Improvement |
|--------|--------|-------|-------------|
| Tab bar height | ~90px | 65px | 28% smaller |
| Deck padding | 15px | 10px | 33% reduction |
| Disk size | 180px | 140px | 22% smaller |
| Waveform height | 100px | 70px | 30% smaller |
| Button min-height | 44px | 40px | 9% smaller |
| Control gaps | 8px | 6px | 25% tighter |
| Overall vertical space | ~100% | ~70% | 30% more compact |
## User Experience Benefits
1. **More content visible**: ~30% more content fits on screen
2. **Less scrolling needed**: Compact layout reduces need to scroll
3. **Faster navigation**: Tighter spacing means less finger movement
4. **Better one-handed use**: Optimized button positions
5. **Cleaner interface**: Less wasted space, more focused design
6. **Maintained usability**: Still meets accessibility guidelines
## Browser Compatibility
- ✅ iOS Safari (webkit optimizations)
- ✅ Android Chrome (webkit optimizations)
- ✅ Mobile Firefox (fallback scrollbars)
- ✅ All modern mobile browsers
## Notes
- All changes maintain minimum 40px touch targets for accessibility
- Font sizes remain readable (minimum 0.6rem = ~9.6px on most devices)
- Scrollbars are thin but still visible and usable
- Active states provide clear visual feedback
- Smooth animations enhance perceived performance

View File

@ -11,6 +11,9 @@
<body>
<div id="start-overlay">
<h1 class="overlay-title">TECHDJ PROTOCOL</h1>
<div id="loading-status"
style="color: var(--primary-cyan); font-family: 'Orbitron'; margin-bottom: 20px; font-size: 0.8rem; letter-spacing: 2px;">
READY TO INITIALISE</div>
<button id="start-btn" onclick="initSystem()">INITIALISE SYSTEM</button>
<p style="color:#666; margin-top:20px; font-family:'Rajdhani'">v2.0 // NEON CORE</p>
</div>
@ -40,18 +43,10 @@
<span class="tab-icon"></span>
<span>DECK A</span>
</button>
<button class="tab-btn" onclick="switchTab('queue-A')">
<span class="tab-icon"></span>
<span>QUEUE A</span>
</button>
<button class="tab-btn" onclick="switchTab('deck-B')">
<span class="tab-icon"></span>
<span>DECK B</span>
</button>
<button class="tab-btn" onclick="switchTab('queue-B')">
<span class="tab-icon"></span>
<span>QUEUE B</span>
</button>
<button class="tab-btn fullscreen-btn" onclick="toggleFullScreen()" id="fullscreen-toggle">
<span class="tab-icon"></span>
<span>FULL</span>
@ -60,6 +55,10 @@
<!-- 1. LEFT: LIBRARY -->
<section class="library-section">
<div class="lib-mode-toggle mobile-only">
<button class="mode-btn active" id="btn-server-lib" onclick="setLibraryMode('server')">SERVER</button>
<button class="mode-btn" id="btn-local-lib" onclick="setLibraryMode('local')">LOCAL</button>
</div>
<div class="lib-header">
<input type="text" id="lib-search" placeholder="FILTER LIBRARY..." onkeyup="filterLibrary()">
<button class="refresh-btn" onclick="refreshLibrary()" title="Refresh Library">REFRESH</button>
@ -131,6 +130,16 @@
</div>
</div>
<!-- Integrated Queue -->
<div class="deck-queue">
<div class="queue-header">
<span>UP NEXT - DECK A</span>
<button class="mini-clear-btn" onclick="clearQueue('A')">CLEAR</button>
</div>
<div class="queue-list" id="deck-queue-list-A">
<div class="queue-empty">Queue is empty</div>
</div>
</div>
<div class="controls-grid">
<!-- Volume Fader -->
@ -182,6 +191,8 @@
<div class="transport">
<button class="big-btn play-btn" onclick="playDeck('A')">PLAY</button>
<button class="big-btn pause-btn" onclick="pauseDeck('A')">PAUSE</button>
<button class="big-btn repeat-btn" id="repeat-btn-A" onclick="toggleRepeat('A')"
title="Loop Track">LOOP</button>
<button class="big-btn sync-btn" onclick="syncDecks('A')">SYNC</button>
<button class="big-btn reset-btn" onclick="resetDeck('A')"
title="Reset all settings to default">RESET</button>
@ -246,7 +257,16 @@
</div>
</div>
<!-- Integrated Queue -->
<div class="deck-queue">
<div class="queue-header">
<span>UP NEXT - DECK B</span>
<button class="mini-clear-btn" onclick="clearQueue('B')">CLEAR</button>
</div>
<div class="queue-list" id="deck-queue-list-B">
<div class="queue-empty">Queue is empty</div>
</div>
</div>
<div class="controls-grid">
<!-- Volume Fader -->
@ -298,6 +318,8 @@
<div class="transport">
<button class="big-btn play-btn" onclick="playDeck('B')">PLAY</button>
<button class="big-btn pause-btn" onclick="pauseDeck('B')">PAUSE</button>
<button class="big-btn repeat-btn" id="repeat-btn-B" onclick="toggleRepeat('B')"
title="Loop Track">LOOP</button>
<button class="big-btn sync-btn" onclick="syncDecks('B')">SYNC</button>
<button class="big-btn reset-btn" onclick="resetDeck('B')"
title="Reset all settings to default">RESET</button>
@ -462,6 +484,7 @@
<input type="file" id="file-upload" accept="audio/mp3,audio/mpeg" multiple style="display:none"
onchange="handleFileUpload(event)">
<button class="settings-btn" onclick="toggleSettings()">SET</button>
<button class="library-toggle-mob" style="display:none" onclick="toggleMobileLibrary()">LIBRARY</button>
</body>
</html>

273
script.js
View File

@ -257,6 +257,57 @@ function initSystem() {
if (window.innerWidth <= 1024) {
switchTab('library');
}
initDropZones();
}
function initDropZones() {
['A', 'B'].forEach(id => {
const deckEl = document.getElementById(`deck-${id}`);
const queueEl = document.getElementById(`deck-queue-list-${id}`);
// Deck Drop Zone (Load Track)
if (deckEl) {
deckEl.ondragover = (e) => {
e.preventDefault();
deckEl.classList.add('drag-over');
};
deckEl.ondragleave = () => {
deckEl.classList.remove('drag-over');
};
deckEl.ondrop = (e) => {
e.preventDefault();
deckEl.classList.remove('drag-over');
const file = e.dataTransfer.getData('trackFile');
const title = e.dataTransfer.getData('trackTitle');
if (file && title) {
console.log(`Dropped track onto Deck ${id}: ${title}`);
loadFromServer(id, file, title);
}
};
}
// Queue Drop Zone (Add to Queue)
if (queueEl) {
queueEl.ondragover = (e) => {
e.preventDefault();
queueEl.classList.add('drag-over');
};
queueEl.ondragleave = () => {
queueEl.classList.remove('drag-over');
};
queueEl.ondrop = (e) => {
e.preventDefault();
queueEl.classList.remove('drag-over');
const file = e.dataTransfer.getData('trackFile');
const title = e.dataTransfer.getData('trackTitle');
if (file && title) {
console.log(`Dropped track into Queue ${id}: ${title}`);
addToQueue(id, file, title);
}
};
}
});
}
// VU Meter Animation with smoothing
@ -390,6 +441,27 @@ function switchTab(tabId) {
vibrate(10);
}
let libraryMode = 'server'; // 'server' or 'local'
function setLibraryMode(mode) {
libraryMode = mode;
// Update UI buttons
document.getElementById('btn-server-lib').classList.toggle('active', mode === 'server');
document.getElementById('btn-local-lib').classList.toggle('active', mode === 'local');
// Refresh list
renderLibrary();
vibrate(15);
}
function toggleMobileLibrary() {
// This is now handled by tabs, but keep for compatibility if needed
const lib = document.querySelector('.library-section');
lib.classList.toggle('active');
vibrate(20);
}
function dismissLandscapePrompt() {
const prompt = document.getElementById('landscape-prompt');
if (prompt) prompt.classList.add('dismissed');
@ -1143,15 +1215,40 @@ async function fetchLibrary() {
}
function renderLibrary(songs) {
if (!songs) songs = allSongs;
const list = document.getElementById('library-list');
list.innerHTML = '';
if (songs.length === 0) {
list.innerHTML = '<div style="padding:10px; opacity:0.5;">Library empty. Download some music!</div>';
// Filter by mode (Mobile Drawer specifically relies on this)
const filteredSongs = songs.filter(s => {
// If it's a server track, its type is usually 'remote' or it has a URL
// If it's a local track, its type is 'local'
// For simplicity, let's look for a type field
if (libraryMode === 'local') return s.type === 'local';
return s.type !== 'local';
});
if (filteredSongs.length === 0) {
list.innerHTML = `<div style="padding:20px; text-align:center; opacity:0.5;">No ${libraryMode} tracks found.</div>`;
return;
}
songs.forEach(t => {
filteredSongs.forEach(t => {
const item = document.createElement('div');
item.className = 'track-row';
item.draggable = true;
// Drag data
item.ondragstart = (e) => {
e.dataTransfer.setData('trackFile', t.file);
e.dataTransfer.setData('trackTitle', t.title);
e.dataTransfer.setData('source', 'library');
item.classList.add('dragging');
};
item.ondragend = () => {
item.classList.remove('dragging');
};
const trackName = document.createElement('span');
trackName.className = 'track-name';
@ -1418,7 +1515,25 @@ async function handleFileUpload(event) {
event.target.value = '';
}
function toggleRepeat(id, val) { settings[`repeat${id}`] = val; }
function toggleRepeat(id, val) {
if (val === undefined) {
settings[`repeat${id}`] = !settings[`repeat${id}`];
} else {
settings[`repeat${id}`] = val;
}
// Update UI
const btn = document.getElementById(`repeat-btn-${id}`);
const checkbox = document.getElementById(`repeat-${id}`);
if (btn) {
btn.classList.toggle('active', settings[`repeat${id}`]);
btn.textContent = settings[`repeat${id}`] ? 'LOOP ON' : 'LOOP';
}
if (checkbox) checkbox.checked = settings[`repeat${id}`];
console.log(`Deck ${id} Repeat: ${settings[`repeat${id}`]}`);
vibrate(10);
}
function toggleAutoMix(val) { settings.autoMix = val; }
function toggleShuffle(val) { settings.shuffleMode = val; }
function toggleQuantize(val) { settings.quantize = val; }
@ -2650,84 +2765,108 @@ function loadNextFromQueue(deckId) {
// Render queue UI
function renderQueue(deckId) {
const queueList = document.getElementById(`queue-list-${deckId}`);
if (!queueList) return;
const mainQueue = document.getElementById(`queue-list-${deckId}`);
const deckQueue = document.getElementById(`deck-queue-list-${deckId}`);
if (queues[deckId].length === 0) {
queueList.innerHTML = '<div class="queue-empty">Drop tracks here or click "Queue to ' + deckId + '" in library</div>';
return;
}
const targets = [mainQueue, deckQueue].filter(t => t !== null);
if (targets.length === 0) return;
queueList.innerHTML = '';
queues[deckId].forEach((track, index) => {
const item = document.createElement('div');
item.className = 'queue-item';
item.draggable = true;
const generateHTML = (isEmpty) => {
if (isEmpty) {
return '<div class="queue-empty">Queue is empty</div>';
}
return '';
};
const number = document.createElement('span');
number.className = 'queue-number';
number.textContent = (index + 1) + '.';
targets.forEach(container => {
if (queues[deckId].length === 0) {
container.innerHTML = generateHTML(true);
} else {
container.innerHTML = '';
queues[deckId].forEach((track, index) => {
const item = document.createElement('div');
item.className = 'queue-item';
item.draggable = true;
const title = document.createElement('span');
title.className = 'queue-track-title';
title.textContent = track.title;
const number = document.createElement('span');
number.className = 'queue-number';
number.textContent = (index + 1) + '.';
const actions = document.createElement('div');
actions.className = 'queue-actions';
const title = document.createElement('span');
title.className = 'queue-track-title';
title.textContent = track.title;
const loadBtn = document.createElement('button');
loadBtn.className = 'queue-load-btn';
loadBtn.textContent = '▶';
loadBtn.title = 'Load now';
loadBtn.onclick = () => {
loadFromServer(deckId, track.file, track.title);
removeFromQueue(deckId, index);
};
const actions = document.createElement('div');
actions.className = 'queue-actions';
const removeBtn = document.createElement('button');
removeBtn.className = 'queue-remove-btn';
removeBtn.textContent = '✕';
removeBtn.title = 'Remove from queue';
removeBtn.onclick = () => removeFromQueue(deckId, index);
const loadBtn = document.createElement('button');
loadBtn.className = 'queue-load-btn';
loadBtn.textContent = '▶';
loadBtn.title = 'Load now';
loadBtn.onclick = (e) => {
e.stopPropagation();
loadFromServer(deckId, track.file, track.title);
removeFromQueue(deckId, index);
};
actions.appendChild(loadBtn);
actions.appendChild(removeBtn);
const removeBtn = document.createElement('button');
removeBtn.className = 'queue-remove-btn';
removeBtn.textContent = '✕';
removeBtn.title = 'Remove from queue';
removeBtn.onclick = (e) => {
e.stopPropagation();
removeFromQueue(deckId, index);
};
item.appendChild(number);
item.appendChild(title);
item.appendChild(actions);
actions.appendChild(loadBtn);
actions.appendChild(removeBtn);
// Drag and drop reordering
item.ondragstart = (e) => {
e.dataTransfer.effectAllowed = 'move';
e.dataTransfer.setData('queueIndex', index);
e.dataTransfer.setData('queueDeck', deckId);
item.classList.add('dragging');
};
item.appendChild(number);
item.appendChild(title);
item.appendChild(actions);
item.ondragend = () => {
item.classList.remove('dragging');
};
// Click to load also
item.onclick = () => {
loadFromServer(deckId, track.file, track.title);
removeFromQueue(deckId, index);
};
item.ondragover = (e) => {
e.preventDefault();
e.dataTransfer.dropEffect = 'move';
};
// Drag and drop reordering
item.ondragstart = (e) => {
e.dataTransfer.effectAllowed = 'move';
e.dataTransfer.setData('queueIndex', index);
e.dataTransfer.setData('queueDeck', deckId);
item.classList.add('dragging');
};
item.ondrop = (e) => {
e.preventDefault();
const fromIndex = parseInt(e.dataTransfer.getData('queueIndex'));
const fromDeck = e.dataTransfer.getData('queueDeck');
item.ondragend = () => {
item.classList.remove('dragging');
};
if (fromDeck === deckId && fromIndex !== index) {
const [moved] = queues[deckId].splice(fromIndex, 1);
queues[deckId].splice(index, 0, moved);
renderQueue(deckId);
console.log(`Reordered Queue ${deckId}`);
}
};
item.ondragover = (e) => {
e.preventDefault();
e.dataTransfer.dropEffect = 'move';
};
queueList.appendChild(item);
item.ondrop = (e) => {
e.preventDefault();
const fromIndex = parseInt(e.dataTransfer.getData('queueIndex'));
const fromDeck = e.dataTransfer.getData('queueDeck');
if (fromDeck === deckId && fromIndex !== index) {
const [movedItem] = queues[deckId].splice(fromIndex, 1);
queues[deckId].splice(index, 0, movedItem);
renderQueue(deckId);
if (SERVER_SIDE_AUDIO && socket) {
socket.emit('audio_sync_queue', { deck: deckId, tracks: queues[deckId] });
}
}
};
container.appendChild(item);
});
}
});
}

716
style.css

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long