Spaces:
Running
Running
Update index.html
Browse files- index.html +17 -71
index.html
CHANGED
|
@@ -2,10 +2,9 @@
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8" />
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
| 6 |
<title>DALL·E Mini - 4 Image Generator</title>
|
| 7 |
-
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet"/>
|
| 8 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
|
| 9 |
<style>
|
| 10 |
:root {
|
| 11 |
--bg-color: #121212;
|
|
@@ -14,6 +13,10 @@
|
|
| 14 |
--accent-color: #4ade80;
|
| 15 |
}
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
body {
|
| 18 |
margin: 0;
|
| 19 |
background: var(--bg-color);
|
|
@@ -75,45 +78,16 @@
|
|
| 75 |
|
| 76 |
#gallery {
|
| 77 |
display: grid;
|
| 78 |
-
grid-template-columns: repeat(auto-fit, minmax(
|
| 79 |
-
gap:
|
| 80 |
margin-top: 2rem;
|
| 81 |
}
|
| 82 |
|
| 83 |
-
|
| 84 |
-
background: var(--card-color);
|
| 85 |
-
border-radius: 10px;
|
| 86 |
-
padding: 1rem;
|
| 87 |
-
text-align: center;
|
| 88 |
-
}
|
| 89 |
-
|
| 90 |
-
.image-card img {
|
| 91 |
width: 100%;
|
| 92 |
-
|
| 93 |
-
border-radius: 8px;
|
| 94 |
object-fit: cover;
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
.image-card button {
|
| 98 |
-
margin-top: 0.8rem;
|
| 99 |
-
width: 100%;
|
| 100 |
-
background: #3b82f6;
|
| 101 |
-
color: white;
|
| 102 |
-
}
|
| 103 |
-
|
| 104 |
-
.image-card button:hover {
|
| 105 |
-
background: #2563eb;
|
| 106 |
-
}
|
| 107 |
-
|
| 108 |
-
#screenshot {
|
| 109 |
-
display: none;
|
| 110 |
-
margin: 2rem auto;
|
| 111 |
-
background: #3b82f6;
|
| 112 |
-
color: white;
|
| 113 |
-
}
|
| 114 |
-
|
| 115 |
-
#screenshot:hover {
|
| 116 |
-
background: #2563eb;
|
| 117 |
}
|
| 118 |
|
| 119 |
.loader {
|
|
@@ -145,7 +119,7 @@
|
|
| 145 |
<body>
|
| 146 |
<div class="container">
|
| 147 |
<h1>DALL·E Mini by <a href="https://www.craiyon.com/" target="_blank">Craiyon</a></h1>
|
| 148 |
-
<p>Generate 4 AI images
|
| 149 |
|
| 150 |
<div class="input-area">
|
| 151 |
<input id="prompt" type="text" placeholder="E.g. astronaut riding a unicorn in space" />
|
|
@@ -154,7 +128,6 @@
|
|
| 154 |
|
| 155 |
<div id="gallery"></div>
|
| 156 |
<div class="loader" id="loader"></div>
|
| 157 |
-
<button id="screenshot" onclick="captureScreenshot()">Download All as Screenshot</button>
|
| 158 |
|
| 159 |
<footer>
|
| 160 |
Built by <a href="https://twitter.com/borisdayma" target="_blank">Boris Dayma</a> • Powered by <a href="https://www.craiyon.com/" target="_blank">Craiyon</a>
|
|
@@ -166,11 +139,9 @@
|
|
| 166 |
const prompt = document.getElementById("prompt").value.trim();
|
| 167 |
const gallery = document.getElementById("gallery");
|
| 168 |
const loader = document.getElementById("loader");
|
| 169 |
-
const screenshotBtn = document.getElementById("screenshot");
|
| 170 |
|
| 171 |
gallery.innerHTML = "";
|
| 172 |
loader.textContent = "Generating images... Please wait.";
|
| 173 |
-
screenshotBtn.style.display = "none";
|
| 174 |
|
| 175 |
if (!prompt) {
|
| 176 |
loader.textContent = "Please enter a prompt.";
|
|
@@ -185,17 +156,13 @@
|
|
| 185 |
});
|
| 186 |
|
| 187 |
const data = await res.json();
|
| 188 |
-
const images = (data.images || []).slice(0, 4);
|
| 189 |
|
| 190 |
if (images.length > 0) {
|
| 191 |
-
gallery.innerHTML = images.map((img,
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
</div>
|
| 196 |
-
`).join("");
|
| 197 |
-
|
| 198 |
-
screenshotBtn.style.display = "block";
|
| 199 |
loader.textContent = "";
|
| 200 |
} else {
|
| 201 |
loader.textContent = "No images returned. Try a different prompt.";
|
|
@@ -204,27 +171,6 @@
|
|
| 204 |
loader.textContent = "Error: Server busy or unreachable. Try again later.";
|
| 205 |
}
|
| 206 |
}
|
| 207 |
-
|
| 208 |
-
function downloadImage(base64, filename) {
|
| 209 |
-
const a = document.createElement("a");
|
| 210 |
-
a.href = "data:image/png;base64," + base64;
|
| 211 |
-
a.download = filename;
|
| 212 |
-
document.body.appendChild(a);
|
| 213 |
-
a.click();
|
| 214 |
-
document.body.removeChild(a);
|
| 215 |
-
}
|
| 216 |
-
|
| 217 |
-
function captureScreenshot() {
|
| 218 |
-
html2canvas(document.getElementById("gallery")).then(canvas => {
|
| 219 |
-
const image = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
|
| 220 |
-
const a = document.createElement("a");
|
| 221 |
-
const now = new Date();
|
| 222 |
-
const filename = `dallemini_${now.toISOString().replace(/[:T]/g, "-").split(".")[0]}.png`;
|
| 223 |
-
a.setAttribute("download", filename);
|
| 224 |
-
a.setAttribute("href", image);
|
| 225 |
-
a.click();
|
| 226 |
-
});
|
| 227 |
-
}
|
| 228 |
</script>
|
| 229 |
</body>
|
| 230 |
</html>
|
|
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8" />
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
<title>DALL·E Mini - 4 Image Generator</title>
|
| 7 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet" />
|
|
|
|
| 8 |
<style>
|
| 9 |
:root {
|
| 10 |
--bg-color: #121212;
|
|
|
|
| 13 |
--accent-color: #4ade80;
|
| 14 |
}
|
| 15 |
|
| 16 |
+
* {
|
| 17 |
+
box-sizing: border-box;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
body {
|
| 21 |
margin: 0;
|
| 22 |
background: var(--bg-color);
|
|
|
|
| 78 |
|
| 79 |
#gallery {
|
| 80 |
display: grid;
|
| 81 |
+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
| 82 |
+
gap: 1rem;
|
| 83 |
margin-top: 2rem;
|
| 84 |
}
|
| 85 |
|
| 86 |
+
#gallery img {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
width: 100%;
|
| 88 |
+
border-radius: 10px;
|
|
|
|
| 89 |
object-fit: cover;
|
| 90 |
+
cursor: pointer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
}
|
| 92 |
|
| 93 |
.loader {
|
|
|
|
| 119 |
<body>
|
| 120 |
<div class="container">
|
| 121 |
<h1>DALL·E Mini by <a href="https://www.craiyon.com/" target="_blank">Craiyon</a></h1>
|
| 122 |
+
<p>Generate 4 AI images instantly</p>
|
| 123 |
|
| 124 |
<div class="input-area">
|
| 125 |
<input id="prompt" type="text" placeholder="E.g. astronaut riding a unicorn in space" />
|
|
|
|
| 128 |
|
| 129 |
<div id="gallery"></div>
|
| 130 |
<div class="loader" id="loader"></div>
|
|
|
|
| 131 |
|
| 132 |
<footer>
|
| 133 |
Built by <a href="https://twitter.com/borisdayma" target="_blank">Boris Dayma</a> • Powered by <a href="https://www.craiyon.com/" target="_blank">Craiyon</a>
|
|
|
|
| 139 |
const prompt = document.getElementById("prompt").value.trim();
|
| 140 |
const gallery = document.getElementById("gallery");
|
| 141 |
const loader = document.getElementById("loader");
|
|
|
|
| 142 |
|
| 143 |
gallery.innerHTML = "";
|
| 144 |
loader.textContent = "Generating images... Please wait.";
|
|
|
|
| 145 |
|
| 146 |
if (!prompt) {
|
| 147 |
loader.textContent = "Please enter a prompt.";
|
|
|
|
| 156 |
});
|
| 157 |
|
| 158 |
const data = await res.json();
|
| 159 |
+
const images = (data.images || []).slice(0, 4); // Limit to 4 images
|
| 160 |
|
| 161 |
if (images.length > 0) {
|
| 162 |
+
gallery.innerHTML = images.map((img, index) => {
|
| 163 |
+
const imgSrc = `data:image/png;base64,${img}`;
|
| 164 |
+
return `<a href="${imgSrc}" download="image_${index + 1}.png"><img src="${imgSrc}" alt="Generated Image" /></a>`;
|
| 165 |
+
}).join("");
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
loader.textContent = "";
|
| 167 |
} else {
|
| 168 |
loader.textContent = "No images returned. Try a different prompt.";
|
|
|
|
| 171 |
loader.textContent = "Error: Server busy or unreachable. Try again later.";
|
| 172 |
}
|
| 173 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
</script>
|
| 175 |
</body>
|
| 176 |
</html>
|