text
stringlengths
0
106k
urls = ["https://i.ibb.co/k0W6V1v/Dream-Shaper-v7-blonde-hermione-emma-watsonpink-dress-silver-ti-3.jpg",
"https://i.ibb.co/4tVHbcq/Dream-Shaper-v7-blonde-hermione-emma-watsonpink-dress-silver-ti-2.jpg",
"https://i.ibb.co/wLzpXb2/Photo-Real-blonde-hermione-emma-watsonpink-dress-blushing-weddi-0.jpg",
"https://i.ibb.co/pjbT6Gd/Photo-Real-blonde-hermione-emma-watsonpink-dress-silver-tiara-b-1.jpg"]
// Display the placeholders
let imageContainer = document.createElement('div');
imageContainer.style.display = 'flex';
imageContainer.style.flexWrap = 'wrap';
imageContainer.style.justifyContent = 'space-around';
imageContainer.style.marginTop = '20px';
urls.forEach((url, index) => {
let link = document.createElement('a');
link.href = url;
link.setAttribute('data-fancybox','gallery');
link.style.width = isMobile() ? 'calc(100% - 20px)' : 'calc(50% - 20px)';
link.style.display = 'flex';
link.style.justifyContent = 'center';
link.style.alignItems = 'center';
link.style.position = 'relative';
let spinner = document.createElement('div');
spinner.className = 'spinner';
for(let i = 1; i <= 5; i++) {
let div = document.createElement('div');
div.className = 'rect' + i;
spinner.appendChild(div);
}
link.appendChild(spinner);
// Create the timer element
let timer = document.createElement('div');
timer.style.position = 'absolute';
timer.style.bottom = '10px';
timer.style.left = '0';
timer.style.right = '0';
timer.style.textAlign = 'center';
timer.style.color = '#fff';
link.appendChild(timer);
let startTime = Date.now();
setInterval(() => {
let elapsed = Math.round((Date.now() - startTime) / 1000);
timer.textContent = elapsed + ' seconds elapsed';
}, 1000);
imageContainer.appendChild(link);
// Replace the placeholder with the image when it has loaded
let img = new Image();
img.onload = function() {
setTimeout(() => {
spinner.style.display = 'none';
timer.style.display = 'none';
link.appendChild(img);
}, 5000); // Add 5 seconds delay here
};
img.src = url;
img.style.width = '100%';
img.style.height = 'auto';
img.style.margin = '10px';
img.style.borderRadius = '10px';
});
// Add the image container to the DOM, right after the Generate button
document.querySelector('.btn').after(imageContainer);
$('[data-fancybox="gallery"]').fancybox({
buttons: [
'zoom',
'fullScreen',
'download',
'close'
],
thumbs: {
autoStart: false,
hideOnClose: true
}
});
}
```
Now, the spinner should be centered within each image placeholder, and there should be a timer below it, showing the elapsed time in seconds.
[USER]: give full modified code
[AI]: Sure, here is the full modified code:
```css
.spinner-container {
display: flex;
justify-content: center;
align-items: center;
height: 100%; /* Set this to the height of your images */
width: 100%; /* Set this to the width of your images */
position: relative; /* Add this line */
}
.spinner {
margin: 0 auto;
width: 50px;
height: 40px;
text-align: center;