text
stringlengths
0
106k
font-size: 10px;
}
.elapsed-time {
position: absolute; /* Position the time label absolutely... */
bottom: 10px; /* ...at the bottom of the .spinner-container */
left: 0;
right: 0;
text-align: center; /* Center the text */
}
```
```javascript
async function generateImages() {
// Get the values from the form inputs
let provider = document.getElementById('provider').value;
let model = document.getElementById('model').value;
let style = document.getElementById('style').value;
let ratio = document.getElementById('ratio').value;
let numImages = document.getElementById('num-images').value;
// Generate the URLs
let 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"]
// Start the timer
let startTime = Date.now();
// 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.position = 'relative'; // Add this line
let spinnerContainer = document.createElement('div');
spinnerContainer.className = 'spinner-container';
link.appendChild(spinnerContainer);
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);
}
spinnerContainer.appendChild(spinner);
let elapsedTimeLabel = document.createElement('div');
elapsedTimeLabel.className = 'elapsed-time';
spinnerContainer.appendChild(elapsedTimeLabel);
// Update the elapsed time label every second
setInterval(() => {
let elapsedTime = Math.floor((Date.now() - startTime) / 1000);
elapsedTimeLabel.textContent = elapsedTime + ' seconds';
}, 1000);
// Replace the placeholder with the image when it has loaded
let img = new Image();
img.onload = function() {
setTimeout(() => {
spinnerContainer.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';
imageContainer.appendChild(link);
});
// 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
}