Files
memevizor/static/index.html
Maksim Pischulenok ea7db3e6fe Add dynamic background image synchronization with main image
- Define CSS variable for background image in root element
- Create updateBackgroundImage function to sync background with main image
- Modify refreshImage to update both main and background images
- Maintain consistent gradient overlay for both images
- Keep existing 5-minute refresh interval
2025-06-08 13:31:51 +03:00

86 lines
2.5 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>📺</text></svg>">
<title>memes-tv</title>
<style>
:root {
--bg-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('_.jpeg');
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: black;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
overflow: hidden;
position: relative;
}
body::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: var(--bg-image);
background-size: cover;
background-position: center;
background-repeat: no-repeat;
filter: blur(20px);
transform: scale(1.1);
z-index: -1;
}
img {
width: 100%;
height: 100%;
object-fit: contain;
position: relative;
z-index: 1;
}
</style>
</head>
<body>
<img id="image" src="_.jpeg" alt="Fullscreen Image">
</body>
<script>
const img = document.getElementById('image');
function updateBackgroundImage(url) {
// Update the background image with the same URL as the main image
document.documentElement.style.setProperty(
'--bg-image',
`linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('${url}')`
);
}
function refreshImage() {
// Add timestamp to URL to bypass cache
const newSrc = img.src.split('?')[0] + '?t=' + new Date().getTime();
img.src = newSrc;
updateBackgroundImage(newSrc);
}
// Refresh every 5 minutes
setInterval(refreshImage, 300000);
// Add click listener to refresh on demand (anywhere on the page)
document.addEventListener('click', refreshImage);
// Add spacebar listener to refresh on demand
document.addEventListener('keydown', function(event) {
if (event.code === 'Space') {
event.preventDefault(); // Prevent page scroll
refreshImage()
}
});
</script>
</html>