233 lines
8.1 KiB
HTML
233 lines
8.1 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Image Server</title>
|
|
$extra_meta
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
html, body { height: 100%; overflow: hidden; background: #1a1a1a; }
|
|
#container {
|
|
width: 100%;
|
|
height: 100%;
|
|
overflow: hidden;
|
|
zoom: 1;
|
|
}
|
|
.media {
|
|
max-width: 100%;
|
|
max-height: 100%;
|
|
width: 100%;
|
|
height: 100%;
|
|
cursor: pointer;
|
|
object-fit: contain;
|
|
display: block;
|
|
}
|
|
.chevron {
|
|
position: absolute;
|
|
top: 33%;
|
|
font-size: 96px;
|
|
color: rgba(255, 255, 255, 0.5);
|
|
cursor: pointer;
|
|
padding: 20px;
|
|
user-select: none;
|
|
transition: color 0.2s;
|
|
text-decoration: none;
|
|
}
|
|
.chevron:hover { color: rgba(255, 255, 255, 0.9); }
|
|
.chevron.left { left: 10px; }
|
|
.chevron.right { right: 10px; }
|
|
.play-btn {
|
|
position: fixed;
|
|
bottom: 20px;
|
|
right: 20px;
|
|
font-size: 48px;
|
|
color: rgba(255, 255, 255, 0.7);
|
|
cursor: pointer;
|
|
text-decoration: none;
|
|
transition: color 0.2s, transform 0.2s;
|
|
padding: 10px;
|
|
}
|
|
.play-btn:hover { color: rgba(255, 255, 255, 1); transform: scale(1.1); }
|
|
.hidden { display: none; }
|
|
#sidebar {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
width: 280px;
|
|
height: 100%;
|
|
background: #2a2a2a;
|
|
color: #ccc;
|
|
overflow-y: auto;
|
|
padding: 16px;
|
|
font-family: monospace;
|
|
font-size: 14px;
|
|
z-index: 100;
|
|
}
|
|
#sidebar a {
|
|
color: #aaa;
|
|
text-decoration: none;
|
|
display: block;
|
|
padding: 4px 8px;
|
|
border-radius: 4px;
|
|
text-wrap-mode: nowrap;
|
|
}
|
|
#sidebar a:hover {
|
|
background: #3a3a3a;
|
|
color: #fff;
|
|
}
|
|
.breadcrumb {
|
|
margin-bottom: 12px;
|
|
padding-bottom: 8px;
|
|
border-bottom: 1px solid #444;
|
|
}
|
|
.breadcrumb a {
|
|
color: #888;
|
|
padding: 0;
|
|
}
|
|
.breadcrumb a:hover {
|
|
color: #fff;
|
|
}
|
|
.index-item {
|
|
margin: 2px 0;
|
|
}
|
|
.index-item.folder a {
|
|
font-weight: bold;
|
|
color: #ddd;
|
|
}
|
|
.index-item.file.current a {
|
|
background: #444;
|
|
color: #fff;
|
|
}
|
|
#sidebar-toggle {
|
|
position: fixed;
|
|
top: 12px;
|
|
left: 280px;
|
|
z-index: 200;
|
|
font-size: 24px;
|
|
color: rgba(255, 255, 255, 0.7);
|
|
cursor: pointer;
|
|
text-decoration: none;
|
|
padding: 6px 10px;
|
|
background: rgba(0, 0, 0, 0.5);
|
|
border-radius: 4px;
|
|
transition: left 0.2s;
|
|
display: none;
|
|
}
|
|
#sidebar-toggle.collapsed {
|
|
left: 12px;
|
|
}
|
|
#sidebar-toggle:hover {
|
|
color: #fff;
|
|
background: rgba(0, 0, 0, 0.7);
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="sidebar" class="$sidebar_class">
|
|
$folder_index
|
|
</div>
|
|
<a id="sidebar-toggle" href="#" title="Toggle index (i)">☰</a>
|
|
<div id="container" class="$container_class">
|
|
<a href="$image_click_url">$media_element</a>
|
|
<a href="$prev_url" class="chevron left" id="prev-btn">‹</a>
|
|
<a href="$next_url" class="chevron right" id="next-btn">›</a>
|
|
$play_button
|
|
<a id="toggle-link" href="$toggle_url" class="hidden"></a>
|
|
</div>
|
|
<script>
|
|
function getRefreshParams() {
|
|
var params = new URLSearchParams(window.location.search);
|
|
var order = params.get('order');
|
|
if (order !== 'next' && order !== 'random') return null;
|
|
var delay = parseInt(params.get('delay'));
|
|
if (isNaN(delay)) return null;
|
|
var hash = window.location.pathname.slice(1);
|
|
return {
|
|
delay: delay,
|
|
order: order,
|
|
hash: hash
|
|
};
|
|
}
|
|
|
|
function buildUrl(hash, order, delay) {
|
|
return '/' + hash + '?order=' + order + '&delay=' + delay;
|
|
}
|
|
|
|
document.addEventListener('keydown', function(e) {
|
|
e.preventDefault();
|
|
if (e.code === 'Space') {
|
|
var playBtn = document.querySelector('.play-btn');
|
|
if (playBtn) playBtn.click();
|
|
} else if (e.code === 'ArrowLeft' || e.key.toLowerCase() === 'h') {
|
|
document.getElementById('prev-btn').click();
|
|
} else if (e.code === 'ArrowRight' || e.key.toLowerCase() === 'l') {
|
|
document.getElementById('next-btn').click();
|
|
} else if (e.code === 'Equal' || e.key.toLowerCase() === 'j') {
|
|
var params = getRefreshParams();
|
|
if (params) window.location.href = buildUrl(params.hash, params.order, params.delay + 1);
|
|
} else if (e.code === 'Minus' || e.key.toLowerCase() === 'k') {
|
|
var params = getRefreshParams();
|
|
if (params && params.delay > 1) window.location.href = buildUrl(params.hash, params.order, params.delay - 1);
|
|
} else if (e.key.toLowerCase() === 'b') {
|
|
document.getElementById('container').classList.toggle('hidden');
|
|
} else if (e.key.toLowerCase() === 'o') {
|
|
var params = getRefreshParams();
|
|
if (params) {
|
|
var newOrder = params.order === 'next' ? 'random' : 'next';
|
|
window.location.href = buildUrl(params.hash, newOrder, params.delay);
|
|
}
|
|
} else if (e.key.toLowerCase() === 'n') {
|
|
var link = document.getElementById('toggle-link');
|
|
if (link && link.getAttribute('href') !== '#') {
|
|
link.click();
|
|
}
|
|
} else if (e.key.toLowerCase() === 'i') {
|
|
document.getElementById('sidebar').classList.toggle('hidden');
|
|
document.getElementById('sidebar-toggle').classList.toggle('collapsed');
|
|
}
|
|
});
|
|
|
|
// Show sidebar toggle button when there is folder index content
|
|
(function() {
|
|
var sidebar = document.getElementById('sidebar');
|
|
var toggle = document.getElementById('sidebar-toggle');
|
|
if (sidebar && sidebar.textContent.trim()) {
|
|
toggle.style.display = 'block';
|
|
toggle.addEventListener('click', function(e) {
|
|
e.preventDefault();
|
|
sidebar.classList.toggle('hidden');
|
|
toggle.classList.toggle('collapsed');
|
|
});
|
|
}
|
|
})();
|
|
|
|
// Preserve sidebar scroll depth between page loads
|
|
(function() {
|
|
var sidebar = document.getElementById('sidebar');
|
|
if (!sidebar) return;
|
|
var saved = sessionStorage.getItem('sidebar-scroll');
|
|
if (saved !== null) sidebar.scrollTop = parseInt(saved, 10);
|
|
sidebar.addEventListener('scroll', function() {
|
|
sessionStorage.setItem('sidebar-scroll', sidebar.scrollTop);
|
|
});
|
|
})();
|
|
|
|
// Preserve video volume and mute status between page loads
|
|
(function() {
|
|
var video = document.querySelector('video');
|
|
if (!video) return;
|
|
var saved = sessionStorage.getItem('video-volume');
|
|
if (saved !== null) {
|
|
var v = parseFloat(saved);
|
|
video.volume = v;
|
|
video.muted = v === 0;
|
|
}
|
|
video.addEventListener('volumechange', function() {
|
|
sessionStorage.setItem('video-volume', video.muted ? '0' : video.volume);
|
|
});
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html>
|