tooltip filename
This commit is contained in:
parent
b87bcdbb53
commit
4cc68e2535
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Random Image</title>
|
||||
<title>File Server</title>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
html, body { height: 100%; overflow: hidden; background: #1a1a1a; }
|
||||
@ -33,7 +33,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<img id="random-img" alt="Random image">
|
||||
<img id="img" alt="Random image">
|
||||
<div class="chevron left" id="prev-btn">‹</div>
|
||||
<div class="chevron right" id="next-btn">›</div>
|
||||
</div>
|
||||
@ -41,7 +41,7 @@
|
||||
let currentData = null;
|
||||
|
||||
function loadImageSrc(hash) {
|
||||
document.getElementById('random-img').src = '/' + hash + '/data';
|
||||
document.getElementById('img').src = '/' + hash + '/data';
|
||||
history.replaceState(null, '', '#' + hash);
|
||||
}
|
||||
|
||||
@ -49,6 +49,7 @@
|
||||
const response = await fetch('/' + hash);
|
||||
currentData = await response.json();
|
||||
loadImageSrc(currentData.img);
|
||||
document.getElementById('img').title = currentData.filename || '';
|
||||
}
|
||||
|
||||
async function loadRandom() {
|
||||
@ -57,7 +58,7 @@
|
||||
await loadInfo(data.img);
|
||||
}
|
||||
|
||||
document.getElementById('random-img').addEventListener('click', loadRandom);
|
||||
document.getElementById('img').addEventListener('click', loadRandom);
|
||||
document.getElementById('prev-btn').addEventListener('click', function() {
|
||||
if (currentData && currentData.previous) loadInfo(currentData.previous);
|
||||
});
|
||||
|
||||
3
main.py
3
main.py
@ -152,7 +152,8 @@ async def get_file_info(file_hash: str):
|
||||
idx = keys.index(file_hash)
|
||||
next_hash = keys[(idx + 1) % len(keys)]
|
||||
prev_hash = keys[idx - 1] if idx > 0 else keys[-1]
|
||||
return {"img": file_hash, "next": next_hash, "previous": prev_hash}
|
||||
filename = indexer.get_filename_by_hash(file_hash)
|
||||
return {"img": file_hash, "next": next_hash, "previous": prev_hash, "filename": filename}
|
||||
|
||||
|
||||
# Optional: Add a health check endpoint
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user