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