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