sudo-soldier commited on
Commit
999bc8d
·
verified ·
1 Parent(s): 3f0b9e4

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +84 -33
index.html CHANGED
@@ -123,44 +123,95 @@
123
 
124
  <footer class="mt-16 text-center text-white text-opacity-70">
125
  <p>AI&nbsp;<i class="fas fa-heart text-red-400"></i> Stable Diffusion</p>
126
- <p class="mt-2 text-sm">powered by cloudflared workers</p>
127
  </footer>
128
  </div>
129
 
130
  <script>
131
- function downloadImage(format) {
132
- if (!currentImageUrl) {
133
- alert("Please generate an icon first.");
134
- return;
135
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
 
137
- const img = new Image();
138
- img.crossOrigin = "anonymous";
139
- img.src = currentImageUrl;
140
-
141
- img.onload = function () {
142
- const canvas = document.createElement('canvas');
143
- canvas.width = img.width;
144
- canvas.height = img.height;
145
- const ctx = canvas.getContext('2d');
146
- ctx.drawImage(img, 0, 0);
147
-
148
- let mimeType = 'image/png';
149
- if (format === 'jpg') mimeType = 'image/jpeg';
150
- else if (format === 'ico') mimeType = 'image/x-icon';
151
-
152
- canvas.toBlob(function (blob) {
153
- const link = document.createElement('a');
154
- link.href = URL.createObjectURL(blob);
155
- link.download = `icon.${format}`;
156
- document.body.appendChild(link);
157
- link.click();
158
- document.body.removeChild(link);
159
- }, mimeType);
160
- };
161
- }
 
 
 
 
 
 
 
 
 
 
162
  </script>
163
- <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=sudo-soldier/iconic" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
164
  </html>
165
-
166
 
 
123
 
124
  <footer class="mt-16 text-center text-white text-opacity-70">
125
  <p>AI&nbsp;<i class="fas fa-heart text-red-400"></i> Stable Diffusion</p>
126
+ <p class="mt-2 text-sm">powered by Cloudflare Workers</p>
127
  </footer>
128
  </div>
129
 
130
  <script>
131
+ let currentImageUrl = "";
132
+
133
+ document.getElementById("generate-btn").addEventListener("click", function () {
134
+ const prompt = document.getElementById("prompt").value.trim();
135
+
136
+ if (!prompt) {
137
+ alert("Please enter a description for your icon.");
138
+ return;
139
+ }
140
+
141
+ document.getElementById("generate-btn").disabled = true;
142
+ document.getElementById("generate-btn").innerHTML = "Generating... <i class='fas fa-spinner fa-spin'></i>";
143
+
144
+ fetch("https://text-to-image.jessejesse.workers.dev", {
145
+ method: "POST",
146
+ headers: {
147
+ "Content-Type": "application/json"
148
+ },
149
+ body: JSON.stringify({
150
+ prompt: prompt
151
+ })
152
+ })
153
+ .then(response => response.blob())
154
+ .then(blob => {
155
+ const url = URL.createObjectURL(blob);
156
+ currentImageUrl = url;
157
+ document.getElementById("preview-container").innerHTML = `<img src="${url}" class="icon-preview rounded-lg shadow-xl max-w-full">`;
158
+ document.getElementById("download-section").classList.remove("hidden");
159
+ document.getElementById("generate-btn").disabled = false;
160
+ document.getElementById("generate-btn").innerHTML = "<i class='fas fa-magic mr-2'></i> Generate Icon";
161
+ })
162
+ .catch(error => {
163
+ console.error("Error:", error);
164
+ alert("An error occurred while generating the icon. Please try again.");
165
+ document.getElementById("generate-btn").disabled = false;
166
+ document.getElementById("generate-btn").innerHTML = "<i class='fas fa-magic mr-2'></i> Generate Icon";
167
+ });
168
+ });
169
+
170
+ document.getElementById("download-png").addEventListener("click", function () {
171
+ downloadImage("png");
172
+ });
173
+
174
+ document.getElementById("download-jpg").addEventListener("click", function () {
175
+ downloadImage("jpg");
176
+ });
177
 
178
+ document.getElementById("download-ico").addEventListener("click", function () {
179
+ downloadImage("ico");
180
+ });
181
+
182
+ function downloadImage(format) {
183
+ if (!currentImageUrl) {
184
+ alert("Please generate an icon first.");
185
+ return;
186
+ }
187
+
188
+ const img = new Image();
189
+ img.crossOrigin = "anonymous";
190
+ img.src = currentImageUrl;
191
+
192
+ img.onload = function () {
193
+ const canvas = document.createElement('canvas');
194
+ canvas.width = img.width;
195
+ canvas.height = img.height;
196
+ const ctx = canvas.getContext('2d');
197
+ ctx.drawImage(img, 0, 0);
198
+
199
+ let mimeType = 'image/png';
200
+ if (format === 'jpg') mimeType = 'image/jpeg';
201
+ else if (format === 'ico') mimeType = 'image/x-icon';
202
+
203
+ canvas.toBlob(function (blob) {
204
+ const link = document.createElement('a');
205
+ link.href = URL.createObjectURL(blob);
206
+ link.download = `icon.${format}`;
207
+ document.body.appendChild(link);
208
+ link.click();
209
+ document.body.removeChild(link);
210
+ }, mimeType);
211
+ };
212
+ }
213
  </script>
214
+ </body>
215
  </html>
216
+
217