image_server/frontend.html

94 lines
3.4 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 {
position: relative;
height: 100%;
display: table;
width: 100%;
}
img {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
max-width: 100%;
max-height: 100%;
cursor: pointer;
}
img { max-width: 100%; max-height: 100%; cursor: pointer; }
.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; }
</style>
</head>
<body>
<div id="container">
<a href="$image_click_url"><img id="img" src="$img_url" title="$filename"></a>
<a href="$prev_url" class="chevron left" id="prev-btn">&#8249;</a>
<a href="$next_url" class="chevron right" id="next-btn">&#8250;</a>
</div>
<script>
function updateMetaRefresh(newDelay, newUrl) {
var metaRefresh = document.querySelector('meta[http-equiv="refresh"]');
if (metaRefresh) {
metaRefresh.setAttribute('content', newDelay + ';url=' + newUrl);
}
}
function getRefreshParams() {
var metaRefresh = document.querySelector('meta[http-equiv="refresh"]');
if (!metaRefresh) return null;
var content = metaRefresh.getAttribute('content');
return {
delay: parseInt(content.split(';')[0].trim()),
url: content.split('url=')[1]
};
}
document.addEventListener('keydown', function(e) {
e.preventDefault();
if (e.code === 'Space') {
document.getElementById('img').click();
} else if (e.code === 'ArrowLeft') {
document.getElementById('prev-btn').click();
} else if (e.code === 'ArrowRight') {
document.getElementById('next-btn').click();
} else if (e.code === 'Equal') {
var params = getRefreshParams();
if (params) updateMetaRefresh(params.delay + 1, params.url);
} else if (e.code === 'Minus') {
var params = getRefreshParams();
if (params && params.delay > 1) updateMetaRefresh(params.delay - 1, params.url);
} else if (e.key.toLowerCase() === 'o') {
var params = getRefreshParams();
if (params) {
var newOrder = params.url.split('/')[1] === 'next' ? 'random' : 'next';
var newUrl = params.url.replace('/' + (newOrder === 'next' ? 'next' : 'random') + '/', '/' + newOrder + '/');
updateMetaRefresh(params.delay, newUrl);
window.location.href = newUrl;
}
}
});
</script>
</body>
</html>