File size: 8,835 Bytes
8e0231f 68fff19 8e0231f 68fff19 8e0231f 68fff19 8e0231f 68fff19 8e0231f 68fff19 8e0231f 68fff19 8e0231f 68fff19 8e0231f 68fff19 8e0231f 68fff19 8e0231f 68fff19 8e0231f 68fff19 8e0231f 68fff19 8e0231f 68fff19 8e0231f 68fff19 8e0231f 68fff19 8e0231f 68fff19 8e0231f 68fff19 8e0231f 4f291ac |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Image Gallery</title>
<style>
/* Base Styling */
body {
font-family: 'Roboto', sans-serif;
margin: 0;
padding: 0;
background-color: #f0f4f8;
color: #333;
}
h1 {
text-align: center;
margin-top: 40px;
font-size: 40px;
color: #212121;
font-weight: 700;
letter-spacing: 1px;
}
.loading {
display: none;
text-align: center;
margin-top: 20px;
font-size: 18px;
color: #007bff;
}
/* Gallery */
.gallery {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: 20px;
padding: 30px;
max-width: 1200px;
margin: 0 auto;
}
.gallery img {
width: 100%;
height: auto;
border-radius: 15px;
box-shadow: 0 12px 25px rgba(0, 0, 0, 0.1);
transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
cursor: pointer;
border: 4px solid #fff;
}
.gallery img:hover {
transform: scale(1.05);
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}
/* Pagination */
.pagination {
display: flex;
justify-content: center;
align-items: center;
margin-top: 40px;
}
.pagination button {
padding: 12px 20px;
background: linear-gradient(45deg, #007bff, #00aaff);
color: white;
border: none;
border-radius: 50px;
font-size: 18px;
cursor: pointer;
margin: 0 10px;
box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease;
}
.pagination button:hover {
background: linear-gradient(45deg, #00aaff, #007bff);
box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
transform: scale(1.1);
}
.pagination button:disabled {
background: #ccc;
cursor: not-allowed;
}
.pagination .page-info {
font-size: 18px;
color: #333;
margin: 0 15px;
}
/* Modal */
.modal {
display: none;
position: fixed;
z-index: 9999;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.8);
justify-content: center;
align-items: center;
animation: fadeIn 0.3s ease;
}
.modal img {
max-width: 90%;
max-height: 90%;
border-radius: 10px;
}
.modal .close {
position: absolute;
top: 20px;
right: 30px;
color: white;
font-size: 40px;
font-weight: bold;
cursor: pointer;
background-color: transparent;
border: none;
}
.modal .close:hover {
color: #bbb;
}
/* Fade-in animation */
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
/* Loading Spinner */
.loading {
display: flex;
justify-content: center;
align-items: center;
margin-top: 20px;
}
.loading::before {
content: "";
border: 4px solid #f3f3f3;
border-top: 4px solid #007bff;
border-radius: 50%;
width: 40px;
height: 40px;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body>
<h1>AI Image Gallery</h1>
<div class="loading">Loading more images...</div>
<div class="gallery" id="gallery"></div>
<!-- Pagination Controls -->
<div class="pagination">
<button id="prevBtn" disabled>Previous</button>
<span class="page-info" id="pageInfo">Page 1 of 1</span>
<button id="nextBtn">Next</button>
</div>
<!-- Modal for displaying full-size images -->
<div id="myModal" class="modal">
<button class="close" id="closeModal">×</button>
<img id="modalImg" src="" alt="Expanded Image">
</div>
<script>
const markdownUrl = "https://proxy.gpt-chatbot.workers.dev/https://pub-fdaeaa9117e64f39ae731591e713d186.r2.dev/logs/imgnaicloud.txt";
const imagesPerPage = 8;
let imageUrls = []; // Store the image URLs
let currentPage = 0;
// Fetch and parse the markdown content
fetch(markdownUrl)
.then(response => response.text())
.then(markdownContent => {
imageUrls = parseImageUrls(markdownContent); // Extract image URLs
imageUrls.reverse(); // Reverse the array so latest images appear first
renderImages(); // Render initial images
updatePageInfo(); // Update pagination info
})
.catch(error => {
console.error("Error fetching markdown:", error);
document.querySelector('.loading').textContent = "Failed to load images.";
});
// Extract image URLs from the markdown content
function parseImageUrls(markdown) {
const regex = /!\[.*?\]\((https?:\/\/[^\s]+)\)/g;
let match;
const urls = [];
while ((match = regex.exec(markdown)) !== null) {
urls.push(match[1]);
}
return urls;
}
// Render images on the page
function renderImages() {
const gallery = document.getElementById("gallery");
const loading = document.querySelector('.loading');
const startIndex = currentPage * imagesPerPage;
const imagesToRender = imageUrls.slice(startIndex, startIndex + imagesPerPage);
// Show loading spinner while images are being fetched
loading.style.display = 'block';
gallery.innerHTML = ''; // Clear previous images
imagesToRender.forEach(url => {
const imgElement = document.createElement("img");
imgElement.src = url;
imgElement.alt = "Image from markdown";
imgElement.onload = () => { imgElement.style.opacity = 1 }; // Ensure image is loaded
imgElement.onerror = () => { imgElement.style.opacity = 0.5 }; // Handle error gracefully
imgElement.addEventListener('click', () => openModal(url));
gallery.appendChild(imgElement);
});
loading.style.display = 'none'; // Hide loading spinner after images are rendered
updatePageInfo(); // Update pagination info
}
// Update pagination info
function updatePageInfo() {
const totalPages = Math.ceil(imageUrls.length / imagesPerPage);
const pageInfo = document.getElementById("pageInfo");
pageInfo.textContent = `Page ${currentPage + 1} of ${totalPages}`;
document.getElementById("prevBtn").disabled = currentPage === 0;
document.getElementById("nextBtn").disabled = currentPage === totalPages - 1;
}
// Open the modal with the clicked image
function openModal(imgSrc) {
const modal = document.getElementById("myModal");
const modalImg = document.getElementById("modalImg");
modalImg.src = imgSrc;
modal.style.display = "flex"; // Show the modal
}
// Close the modal when the user clicks on <span> (x)
document.getElementById("closeModal").addEventListener("click", () => {
document.getElementById("myModal").style.display = "none"; // Hide the modal
});
// Pagination buttons functionality
document.getElementById("prevBtn").addEventListener("click", () => {
if (currentPage > 0) {
currentPage--;
renderImages();
}
});
document.getElementById("nextBtn").addEventListener("click", () => {
if ((currentPage + 1) * imagesPerPage < imageUrls.length) {
currentPage++;
renderImages();
}
});
</script>
</body>
</html>
|