Spaces:
Running
Running
Delete index.html
Browse files- index.html +0 -630
index.html
DELETED
|
@@ -1,630 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="fa" dir="rtl">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8">
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>AI Photoshop Pro</title>
|
| 7 |
-
<link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
| 8 |
-
<style>
|
| 9 |
-
:root {
|
| 10 |
-
--app-font: 'Vazirmatn', sans-serif;
|
| 11 |
-
--app-bg: #F8F9FC;
|
| 12 |
-
--panel-bg: #FFFFFF;
|
| 13 |
-
--panel-border: #EAEFF7;
|
| 14 |
-
--input-bg: #F6F8FB;
|
| 15 |
-
--input-border: #E1E7EF;
|
| 16 |
-
--text-primary: #1A202C;
|
| 17 |
-
--text-secondary: #626F86;
|
| 18 |
-
--text-tertiary: #8A94A6;
|
| 19 |
-
--accent-primary: #4A6CFA;
|
| 20 |
-
--accent-primary-hover: #3553D6;
|
| 21 |
-
--accent-primary-glow: rgba(74, 108, 250, 0.25);
|
| 22 |
-
--accent-secondary: #0FD4A8;
|
| 23 |
-
--danger-color: #e53e3e;
|
| 24 |
-
--danger-color-hover: #c53030;
|
| 25 |
-
--shadow-sm: 0 1px 2px 0 rgba(26, 32, 44, 0.03);
|
| 26 |
-
--shadow-md: 0 4px 6px -1px rgba(26, 32, 44, 0.05), 0 2px 4px -2px rgba(26, 32, 44, 0.04);
|
| 27 |
-
--shadow-lg: 0 10px 15px -3px rgba(26, 32, 44, 0.06), 0 4px 6px -4px rgba(26, 32, 44, 0.05);
|
| 28 |
-
--shadow-xl: 0 20px 25px -5px rgba(26, 32, 44, 0.07), 0 8px 10px -6px rgba(26, 32, 44, 0.05);
|
| 29 |
-
--radius-card: 24px;
|
| 30 |
-
--radius-btn: 14px;
|
| 31 |
-
--radius-input: 12px;
|
| 32 |
-
--transition-smooth: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
@keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
|
| 36 |
-
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
|
| 37 |
-
|
| 38 |
-
body {
|
| 39 |
-
font-family: var(--app-font);
|
| 40 |
-
background-color: var(--app-bg);
|
| 41 |
-
color: var(--text-primary);
|
| 42 |
-
margin: 0;
|
| 43 |
-
padding: 2.5rem 1rem;
|
| 44 |
-
display: flex;
|
| 45 |
-
justify-content: center;
|
| 46 |
-
align-items: flex-start;
|
| 47 |
-
min-height: 100vh;
|
| 48 |
-
}
|
| 49 |
-
.container { max-width: 820px; width: 100%; }
|
| 50 |
-
|
| 51 |
-
header {
|
| 52 |
-
position: relative;
|
| 53 |
-
text-align: center;
|
| 54 |
-
margin-bottom: 2.5rem;
|
| 55 |
-
padding: 2rem 0;
|
| 56 |
-
animation: fadeIn 0.8s 0.1s ease-out backwards;
|
| 57 |
-
overflow: hidden;
|
| 58 |
-
}
|
| 59 |
-
#neural-network-canvas {
|
| 60 |
-
position: absolute;
|
| 61 |
-
top: 0;
|
| 62 |
-
left: 0;
|
| 63 |
-
width: 100%;
|
| 64 |
-
height: 100%;
|
| 65 |
-
z-index: 1;
|
| 66 |
-
}
|
| 67 |
-
h1, .subtitle {
|
| 68 |
-
position: relative;
|
| 69 |
-
z-index: 2;
|
| 70 |
-
}
|
| 71 |
-
|
| 72 |
-
h1 {
|
| 73 |
-
font-size: 2.8rem;
|
| 74 |
-
font-weight: 800;
|
| 75 |
-
margin: 0 0 0.8rem 0;
|
| 76 |
-
background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
|
| 77 |
-
-webkit-background-clip: text;
|
| 78 |
-
-webkit-text-fill-color: transparent;
|
| 79 |
-
letter-spacing: -1px;
|
| 80 |
-
}
|
| 81 |
-
.subtitle { font-size: 1.1rem; color: var(--text-secondary); margin-top: 0; }
|
| 82 |
-
|
| 83 |
-
main, .gallery-section {
|
| 84 |
-
padding: 3rem;
|
| 85 |
-
background-color: var(--panel-bg);
|
| 86 |
-
border-radius: var(--radius-card);
|
| 87 |
-
box-shadow: var(--shadow-xl);
|
| 88 |
-
border: 1px solid var(--panel-border);
|
| 89 |
-
animation: fadeIn 0.8s 0.3s ease-out backwards;
|
| 90 |
-
}
|
| 91 |
-
.gallery-section { margin-top: 3rem; animation-delay: 0.5s; }
|
| 92 |
-
|
| 93 |
-
.form-group { margin-bottom: 2.5rem; }
|
| 94 |
-
.form-group:last-child { margin-bottom: 0; }
|
| 95 |
-
|
| 96 |
-
.form-label {
|
| 97 |
-
display: flex;
|
| 98 |
-
align-items: center;
|
| 99 |
-
gap: 0.75rem;
|
| 100 |
-
font-weight: 700;
|
| 101 |
-
color: var(--text-primary);
|
| 102 |
-
font-size: 1.2em;
|
| 103 |
-
margin-bottom: 1.2rem;
|
| 104 |
-
}
|
| 105 |
-
.form-label svg { width: 24px; height: 24px; color: var(--accent-primary); }
|
| 106 |
-
|
| 107 |
-
#upload-area {
|
| 108 |
-
position: relative; border: 2px dashed var(--input-border); border-radius: var(--radius-input); padding: 2.5rem; text-align: center;
|
| 109 |
-
cursor: pointer; transition: var(--transition-smooth); background-color: var(--input-bg); min-height: 200px; display: flex;
|
| 110 |
-
flex-direction: column; justify-content: center; align-items: center; overflow: hidden;
|
| 111 |
-
}
|
| 112 |
-
#upload-area.drag-over, #upload-area:hover:not(.has-file) { border-color: var(--accent-primary); background-color: #fff; box-shadow: 0 0 15px var(--accent-primary-glow); }
|
| 113 |
-
#upload-area.has-file { border-style: solid; border-color: var(--panel-border); padding: 0; cursor: default; }
|
| 114 |
-
#upload-content { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
|
| 115 |
-
#upload-icon svg { width: 48px; height: 48px; color: var(--accent-primary); stroke-width: 1.5; opacity: 0.8; }
|
| 116 |
-
#upload-area p { margin: 0; color: var(--text-secondary); font-weight: 500; }
|
| 117 |
-
#preview-image-main { display: none; width: 100%; height: 100%; object-fit: contain; position: absolute; top: 0; left: 0; }
|
| 118 |
-
#remove-file-btn-main {
|
| 119 |
-
display: none; position: absolute; top: 12px; right: 12px; background-color: rgba(26, 32, 44, 0.6); color: white; border: none;
|
| 120 |
-
width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 1.2rem; line-height: 1; z-index: 10;
|
| 121 |
-
transition: var(--transition-smooth); padding: 0;
|
| 122 |
-
}
|
| 123 |
-
#remove-file-btn-main:hover { background-color: var(--danger-color); transform: scale(1.1); }
|
| 124 |
-
#upload-area.has-file #upload-content { display: none; }
|
| 125 |
-
#upload-area.has-file #preview-image-main, #upload-area.has-file #remove-file-btn-main { display: block; }
|
| 126 |
-
|
| 127 |
-
textarea { width: 100%; padding: 1rem 1.2rem; border-radius: var(--radius-input); border: 1px solid var(--input-border); background-color: var(--input-bg); color: var(--text-primary); box-shadow: var(--shadow-sm) inset; font-family: var(--app-font); font-size: 1rem; box-sizing: border-box; transition: var(--transition-smooth); min-height: 90px; resize: vertical; }
|
| 128 |
-
textarea:focus { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-primary-glow), var(--shadow-sm) inset; background-color: var(--panel-bg); }
|
| 129 |
-
#submit-btn {
|
| 130 |
-
display: flex; align-items: center; justify-content: center; gap: 0.75rem; width: 100%; padding: 1.1rem;
|
| 131 |
-
font-size: 1.2rem; font-weight: 700; background: linear-gradient(95deg, var(--accent-secondary) 0%, var(--accent-primary) 100%);
|
| 132 |
-
color: #fff; border: none; border-radius: var(--radius-btn); cursor: pointer; transition: all 0.3s ease;
|
| 133 |
-
box-shadow: 0 6px 12px -3px var(--accent-primary-glow), 0 6px 12px -3px var(--accent-secondary-glow); margin-top: 1.5rem;
|
| 134 |
-
}
|
| 135 |
-
#submit-btn svg { width: 24px; height: 24px; margin-left: 4px; filter: drop-shadow(0 0 5px rgba(255,255,255,0.5)); }
|
| 136 |
-
#submit-btn:hover:not(:disabled) { transform: translateY(-5px) scale(1.02); box-shadow: 0 8px 20px -4px var(--accent-primary-glow), 0 8px 20px -4px var(--accent-secondary-glow); }
|
| 137 |
-
#submit-btn:disabled { background: var(--text-tertiary); cursor: not-allowed; box-shadow: none; opacity: 0.7; }
|
| 138 |
-
#submit-btn .spinner { width: 20px; height: 20px; border: 3px solid rgba(255, 255, 255, 0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; display: none; }
|
| 139 |
-
|
| 140 |
-
#result-container { min-height: 350px; position: relative; padding: 1rem; background-color: var(--input-bg); border-radius: var(--radius-card); border: 2px dashed var(--input-border); box-shadow: var(--shadow-sm) inset; transition: var(--transition-smooth); display: flex; align-items: center; justify-content: center; }
|
| 141 |
-
#result-container.loading, #result-container.has-content { border-style: solid; border-color: var(--panel-border); }
|
| 142 |
-
#loading-placeholder { display: none; }
|
| 143 |
-
#result-container.loading #loading-placeholder { display: flex; animation: fadeIn 0.5s; justify-content: center; align-items: center; width: 100%; }
|
| 144 |
-
|
| 145 |
-
.generator-container {
|
| 146 |
-
position: relative;
|
| 147 |
-
width: 400px;
|
| 148 |
-
max-width: 100%;
|
| 149 |
-
height: 300px;
|
| 150 |
-
border: 2px solid #38bdf8;
|
| 151 |
-
border-radius: 20px;
|
| 152 |
-
overflow: hidden;
|
| 153 |
-
box-shadow: 0 0 40px rgba(56, 189, 248, 0.3);
|
| 154 |
-
animation: pulse 5s infinite cubic-bezier(0.4, 0, 0.6, 1);
|
| 155 |
-
background-color: #161b22;
|
| 156 |
-
color: #f0f6fc;
|
| 157 |
-
}
|
| 158 |
-
@keyframes pulse {
|
| 159 |
-
0% { box-shadow: 0 0 40px rgba(56, 189, 248, 0.3); }
|
| 160 |
-
50% { box-shadow: 0 0 60px rgba(56, 189, 248, 0.7); }
|
| 161 |
-
100% { box-shadow: 0 0 40px rgba(56, 189, 248, 0.3); }
|
| 162 |
-
}
|
| 163 |
-
.noise-layer, .sketch-layer, .building-layer {
|
| 164 |
-
position: absolute;
|
| 165 |
-
top: 0;
|
| 166 |
-
left: 0;
|
| 167 |
-
width: 100%;
|
| 168 |
-
height: 100%;
|
| 169 |
-
}
|
| 170 |
-
.noise-layer {
|
| 171 |
-
background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><rect width="100" height="100" fill="none"/><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.5" numOctaves="4" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23noise)" opacity="0.6"/></svg>') repeat;
|
| 172 |
-
opacity: 1;
|
| 173 |
-
animation: fade-noise 7s infinite ease-in-out;
|
| 174 |
-
}
|
| 175 |
-
@keyframes fade-noise {
|
| 176 |
-
0% { opacity: 1; filter: blur(5px); }
|
| 177 |
-
30% { opacity: 0.8; filter: blur(2px); }
|
| 178 |
-
100% { opacity: 0; filter: blur(0px); }
|
| 179 |
-
}
|
| 180 |
-
.sketch-layer {
|
| 181 |
-
filter: grayscale(1) contrast(1.5) blur(3px);
|
| 182 |
-
opacity: 0;
|
| 183 |
-
animation: reveal-sketch 7s infinite ease-in-out;
|
| 184 |
-
}
|
| 185 |
-
@keyframes reveal-sketch {
|
| 186 |
-
0% { opacity: 0; filter: grayscale(1) contrast(1.5) blur(3px); }
|
| 187 |
-
20% { opacity: 1; filter: grayscale(1) contrast(1.2) blur(1px); }
|
| 188 |
-
60% { opacity: 0.5; filter: grayscale(0.5) contrast(1) blur(0px); }
|
| 189 |
-
100% { opacity: 0; }
|
| 190 |
-
}
|
| 191 |
-
.building-layer {
|
| 192 |
-
filter: blur(15px) saturate(0.5) brightness(0.7);
|
| 193 |
-
opacity: 0;
|
| 194 |
-
animation: denoise-color 7s infinite ease-in-out;
|
| 195 |
-
}
|
| 196 |
-
@keyframes denoise-color {
|
| 197 |
-
0% { opacity: 0; filter: blur(15px) saturate(0.5) brightness(0.7); }
|
| 198 |
-
40% { opacity: 0.6; filter: blur(5px) saturate(1) brightness(1); }
|
| 199 |
-
100% { opacity: 1; filter: blur(0px) saturate(1.5) brightness(1.1); }
|
| 200 |
-
}
|
| 201 |
-
.pixel-grid {
|
| 202 |
-
position: absolute;
|
| 203 |
-
top: 0;
|
| 204 |
-
left: 0;
|
| 205 |
-
width: 100%;
|
| 206 |
-
height: 100%;
|
| 207 |
-
background: repeating-linear-gradient(0deg, transparent 0 1px, rgba(255,255,255,0.1) 1px 2px), repeating-linear-gradient(90deg, transparent 0 1px, rgba(255,255,255,0.1) 1px 2px);
|
| 208 |
-
opacity: 1;
|
| 209 |
-
animation: dissolve-grid 7s infinite ease-in-out;
|
| 210 |
-
}
|
| 211 |
-
@keyframes dissolve-grid {
|
| 212 |
-
0% { opacity: 1; }
|
| 213 |
-
70% { opacity: 0.5; }
|
| 214 |
-
100% { opacity: 0; }
|
| 215 |
-
}
|
| 216 |
-
.particles {
|
| 217 |
-
position: absolute;
|
| 218 |
-
top: 0;
|
| 219 |
-
left: 0;
|
| 220 |
-
width: 100%;
|
| 221 |
-
height: 100%;
|
| 222 |
-
background: radial-gradient(circle, rgba(56, 189, 248, 0.2) 0%, transparent 50%), radial-gradient(circle at 30% 70%, rgba(187, 134, 252, 0.2) 0%, transparent 50%), radial-gradient(circle at 70% 30%, rgba(250, 204, 21, 0.2) 0%, transparent 50%);
|
| 223 |
-
animation: flow-particles 7s infinite cubic-bezier(0.4, 0, 0.6, 1);
|
| 224 |
-
}
|
| 225 |
-
@keyframes flow-particles {
|
| 226 |
-
0% { transform: translate(0, 0) scale(1); opacity: 0.5; }
|
| 227 |
-
50% { transform: translate(10px, -15px) scale(1.05); opacity: 0.8; }
|
| 228 |
-
100% { transform: translate(0, 0) scale(1); opacity: 0.5; }
|
| 229 |
-
}
|
| 230 |
-
.text-overlay {
|
| 231 |
-
position: absolute;
|
| 232 |
-
top: 45%;
|
| 233 |
-
left: 50%;
|
| 234 |
-
transform: translate(-50%, -50%);
|
| 235 |
-
font-size: 24px;
|
| 236 |
-
font-weight: 700;
|
| 237 |
-
text-shadow: 0 0 20px rgba(56, 189, 248, 0.8), 0 0 30px rgba(187, 134, 252, 0.5);
|
| 238 |
-
animation: glow-text 7s infinite ease-in-out;
|
| 239 |
-
font-family: var(--app-font);
|
| 240 |
-
}
|
| 241 |
-
@keyframes glow-text {
|
| 242 |
-
0% { opacity: 0.7; text-shadow: 0 0 20px rgba(56, 189, 248, 0.8); }
|
| 243 |
-
50% { opacity: 1; text-shadow: 0 0 30px rgba(56, 189, 248, 1), 0 0 40px rgba(187, 134, 252, 0.7); }
|
| 244 |
-
100% { opacity: 0.7; text-shadow: 0 0 20px rgba(56, 189, 248, 0.8); }
|
| 245 |
-
}
|
| 246 |
-
.progress-bar {
|
| 247 |
-
position: absolute;
|
| 248 |
-
bottom: 0;
|
| 249 |
-
left: 0;
|
| 250 |
-
width: 0%;
|
| 251 |
-
height: 6px;
|
| 252 |
-
background: linear-gradient(to right, #38bdf8, #bb86fc, #facc15);
|
| 253 |
-
animation: progress 7s infinite linear;
|
| 254 |
-
}
|
| 255 |
-
|
| 256 |
-
#result-grid { display: none; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; width: 100%; }
|
| 257 |
-
#result-container.has-content #result-grid { display: grid; }
|
| 258 |
-
#result-grid img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: var(--radius-input); cursor: pointer; transition: var(--transition-smooth); box-shadow: var(--shadow-md); border: 1px solid var(--panel-border); }
|
| 259 |
-
#result-grid img:hover { transform: scale(1.05); box-shadow: var(--shadow-lg); z-index: 10; position: relative; }
|
| 260 |
-
#error-message { color: var(--danger-color); text-align: center; margin-top: 1rem; display: none; font-weight: 500; }
|
| 261 |
-
|
| 262 |
-
.gallery-header { display: flex; justify-content: space-between; align-items: center; }
|
| 263 |
-
#clear-history-btn { background: none; border: 1px solid var(--panel-border); color: var(--text-secondary); padding: 0.5rem 1rem; border-radius: var(--radius-btn); cursor: pointer; display: none; align-items: center; gap: 0.5rem; font-family: var(--app-font); font-weight: 500; transition: all 0.2s; }
|
| 264 |
-
#clear-history-btn:hover { border-color: var(--danger-color); color: var(--danger-color); }
|
| 265 |
-
#clear-history-btn svg { width: 18px; height: 18px; }
|
| 266 |
-
|
| 267 |
-
#history-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; margin-top: 1.5rem; }
|
| 268 |
-
#history-grid:empty::before { content: 'هنوز تصویری خلق نکردهاید. اولین ویرایش شما اینجا ذخیره خواهد شد.'; color: var(--text-secondary); grid-column: 1 / -1; text-align: center; padding: 3rem 1rem; background-color: var(--input-bg); border-radius: var(--radius-card); }
|
| 269 |
-
.history-item { position: relative; background-color: var(--input-bg); border-radius: var(--radius-card); border: 1px solid var(--panel-border); padding: 1rem; transition: var(--transition-smooth); }
|
| 270 |
-
.history-item:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
|
| 271 |
-
.history-item-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
|
| 272 |
-
.history-item-grid img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: var(--radius-input); cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease; border: 1px solid var(--panel-border); }
|
| 273 |
-
.history-item-grid img:hover { transform: scale(1.1); box-shadow: var(--shadow-md); z-index: 5; position: relative; }
|
| 274 |
-
.history-delete-btn { position: absolute; top: 0.75rem; right: 0.75rem; background: none; border: none; cursor: pointer; padding: 0.5rem; border-radius: 50%; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; color: var(--text-tertiary); transition: var(--transition-smooth); z-index: 5; }
|
| 275 |
-
.history-delete-btn:hover { background-color: var(--panel-border); color: var(--danger-color); }
|
| 276 |
-
.history-delete-btn svg { width: 18px; height: 18px; }
|
| 277 |
-
|
| 278 |
-
#lightbox {
|
| 279 |
-
position: fixed;
|
| 280 |
-
inset: 0;
|
| 281 |
-
background-color: rgba(18, 24, 38, 0.6);
|
| 282 |
-
backdrop-filter: blur(10px) saturate(150%);
|
| 283 |
-
display: none; /* Changed back to none for default hidden state */
|
| 284 |
-
align-items: center;
|
| 285 |
-
justify-content: center;
|
| 286 |
-
z-index: 1000;
|
| 287 |
-
opacity: 0;
|
| 288 |
-
transition: opacity 0.3s;
|
| 289 |
-
pointer-events: none;
|
| 290 |
-
}
|
| 291 |
-
#lightbox.visible {
|
| 292 |
-
display: flex; /* Use flex to display when visible */
|
| 293 |
-
opacity: 1;
|
| 294 |
-
pointer-events: auto;
|
| 295 |
-
}
|
| 296 |
-
|
| 297 |
-
#lightbox-content { position: relative; animation: fadeIn 0.3s ease; display: flex; align-items: center; justify-content: center; }
|
| 298 |
-
#lightbox-img { max-width: 85vw; max-height: 80vh; object-fit: contain; border-radius: var(--radius-card); box-shadow: var(--shadow-xl); }
|
| 299 |
-
.lightbox-btn { position: absolute; background-color: rgba(255, 255, 255, 0.1); color: white; border: 1px solid rgba(255,255,255,0.2); width: 44px; height: 44px; border-radius: 50%; cursor: pointer; display: flex; justify-content: center; align-items: center; transition: all 0.2s; text-decoration: none; font-size: 24px; }
|
| 300 |
-
.lightbox-btn:hover { background-color: rgba(255, 255, 255, 0.2); transform: scale(1.1); }
|
| 301 |
-
#lightbox-close { top: -50px; right: 0; }
|
| 302 |
-
#lightbox-download { top: -50px; left: 0; }
|
| 303 |
-
#lightbox-next { right: -60px; top: 50%; transform: translateY(-50%); }
|
| 304 |
-
#lightbox-download svg { width: 22px; height: 22px; }
|
| 305 |
-
#lightbox-download .spinner { width: 20px; height: 20px; border: 3px solid rgba(255, 255, 255, 0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; display: none; }
|
| 306 |
-
|
| 307 |
-
#confirmation-modal {
|
| 308 |
-
position: fixed; inset: 0; background-color: rgba(18, 24, 38, 0.6); backdrop-filter: blur(10px); display: flex;
|
| 309 |
-
align-items: center; justify-content: center; z-index: 2000; opacity: 0; transition: opacity 0.3s; pointer-events: none;
|
| 310 |
-
}
|
| 311 |
-
#confirmation-modal.visible { opacity: 1; pointer-events: auto; }
|
| 312 |
-
.modal-dialog {
|
| 313 |
-
background: var(--panel-bg); color: var(--text-primary); border-radius: var(--radius-card); padding: 2rem;
|
| 314 |
-
width: 90%; max-width: 400px; text-align: center; box-shadow: var(--shadow-xl);
|
| 315 |
-
animation: fadeIn 0.3s ease-out backwards;
|
| 316 |
-
}
|
| 317 |
-
.modal-icon {
|
| 318 |
-
width: 48px; height: 48px; margin: 0 auto 1.5rem; color: var(--danger-color);
|
| 319 |
-
}
|
| 320 |
-
.modal-dialog h3 { font-size: 1.5rem; margin: 0 0 0.75rem; font-weight: 700; }
|
| 321 |
-
.modal-dialog p { font-size: 1rem; color: var(--text-secondary); margin: 0 0 2rem; }
|
| 322 |
-
.modal-buttons { display: flex; gap: 1rem; }
|
| 323 |
-
.modal-btn {
|
| 324 |
-
flex: 1; padding: 0.8rem 1rem; border-radius: var(--radius-btn); border: none; cursor: pointer;
|
| 325 |
-
font-family: var(--app-font); font-weight: 600; font-size: 1rem; transition: var(--transition-smooth);
|
| 326 |
-
}
|
| 327 |
-
.modal-btn.confirm-btn { background-color: var(--danger-color); color: white; }
|
| 328 |
-
.modal-btn.confirm-btn:hover { background-color: var(--danger-color-hover); transform: translateY(-2px); }
|
| 329 |
-
.modal-btn.cancel-btn { background-color: var(--input-bg); color: var(--text-secondary); border: 1px solid var(--input-border); }
|
| 330 |
-
.modal-btn.cancel-btn:hover { background-color: var(--panel-border); color: var(--text-primary); }
|
| 331 |
-
|
| 332 |
-
@media (max-width: 768px) {
|
| 333 |
-
main, .gallery-section { padding: 1.5rem; } h1 { font-size: 2.2rem; } .gallery-section { padding: 1rem; }
|
| 334 |
-
#history-grid { gap: 0.75rem; } .history-item { padding: 0.75rem; }
|
| 335 |
-
#lightbox-next { right: 5px; background-color: rgba(26, 32, 44, 0.5); }
|
| 336 |
-
}
|
| 337 |
-
</style>
|
| 338 |
-
</head>
|
| 339 |
-
<body>
|
| 340 |
-
<div class="container">
|
| 341 |
-
<header>
|
| 342 |
-
<canvas id="neural-network-canvas"></canvas>
|
| 343 |
-
<h1>فتوشاپ هوش مصنوعی ✨</h1>
|
| 344 |
-
<p class="subtitle">تصاویر خود را با قدرت هوش مصنوعی و به زبان ساده ویرایش کنید</p>
|
| 345 |
-
</header>
|
| 346 |
-
|
| 347 |
-
<main>
|
| 348 |
-
<div class="form-group">
|
| 349 |
-
<div class="form-label">
|
| 350 |
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4Z"/></svg>
|
| 351 |
-
۱. تصویر خود را انتخاب کنید
|
| 352 |
-
</div>
|
| 353 |
-
<label id="upload-area" for="file-input">
|
| 354 |
-
<div id="upload-content">
|
| 355 |
-
<div id="upload-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="17 8 12 3 7 8"></polyline><line x1="12" y1="3" x2="12" y2="15"></line></svg></div>
|
| 356 |
-
<p>فایل تصویر را اینجا بکشید یا برای انتخاب کلیک کنید</p>
|
| 357 |
-
</div>
|
| 358 |
-
<img id="preview-image-main" src="" alt="Preview">
|
| 359 |
-
<button type="button" id="remove-file-btn-main" title="حذف تصویر">×</button>
|
| 360 |
-
</label>
|
| 361 |
-
<input type="file" id="file-input" accept="image/*" hidden>
|
| 362 |
-
</div>
|
| 363 |
-
<div class="form-group">
|
| 364 |
-
<label for="prompt-input" class="form-label">
|
| 365 |
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/></svg>
|
| 366 |
-
۲. دستور ویرایش را بنویسید
|
| 367 |
-
</label>
|
| 368 |
-
<textarea id="prompt-input" rows="3" placeholder="مثال: پسزمینه را حذف کن و یک ساحل آفتابی قرار بده"></textarea>
|
| 369 |
-
<button id="submit-btn" disabled>
|
| 370 |
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 3L12 8L17 10L12 12L10 17L8 12L3 10L8 8L10 3z"/></svg>
|
| 371 |
-
<span id="btn-text">ایجاد کن</span>
|
| 372 |
-
<div class="spinner"></div>
|
| 373 |
-
</button>
|
| 374 |
-
<p id="error-message"></p>
|
| 375 |
-
</div>
|
| 376 |
-
<div class="form-group">
|
| 377 |
-
<div class="form-label">
|
| 378 |
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 3L12 8L17 10L12 12L10 17L8 12L3 10L8 8L10 3z"/><path d="M21 14l-1.5 3-3-1.5 3-3 1.5 3z"/><path d="M19.5 2.5l-3 1.5 1.5 3 3-1.5-1.5-3z"/></svg>
|
| 379 |
-
۳. نتیجه را ببینید
|
| 380 |
-
</div>
|
| 381 |
-
<div id="result-container">
|
| 382 |
-
<div id="loading-placeholder">
|
| 383 |
-
<div class="generator-container">
|
| 384 |
-
<div class="noise-layer"></div>
|
| 385 |
-
<div class="sketch-layer"></div>
|
| 386 |
-
<div class="building-layer"></div>
|
| 387 |
-
<div class="pixel-grid"></div>
|
| 388 |
-
<div class="particles"></div>
|
| 389 |
-
<div class="text-overlay">در حال ویرایش تصویر...</div>
|
| 390 |
-
<div class="progress-bar"></div>
|
| 391 |
-
</div>
|
| 392 |
-
</div>
|
| 393 |
-
<div id="result-grid"></div>
|
| 394 |
-
</div>
|
| 395 |
-
</div>
|
| 396 |
-
</main>
|
| 397 |
-
<section class="gallery-section">
|
| 398 |
-
<div class="gallery-header">
|
| 399 |
-
<div class="form-label">
|
| 400 |
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18"/><path d="M9 21V9"/></svg>
|
| 401 |
-
گالری و تاریخچه شما
|
| 402 |
-
</div>
|
| 403 |
-
<button id="clear-history-btn">
|
| 404 |
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>
|
| 405 |
-
<span>پاک کردن همه</span>
|
| 406 |
-
</button>
|
| 407 |
-
</div>
|
| 408 |
-
<div id="history-grid"></div>
|
| 409 |
-
</section>
|
| 410 |
-
</div>
|
| 411 |
-
<div id="lightbox">
|
| 412 |
-
<div id="lightbox-content">
|
| 413 |
-
<img id="lightbox-img" src="">
|
| 414 |
-
<button id="lightbox-close" class="lightbox-btn" title="بستن">×</button>
|
| 415 |
-
<button id="lightbox-download" title="دانلود تصویر" class="lightbox-btn">
|
| 416 |
-
<svg fill="white" viewBox="0 0 24 24"><path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"/></svg>
|
| 417 |
-
<div class="spinner"></div>
|
| 418 |
-
</button>
|
| 419 |
-
<button id="lightbox-next" title="بعدی" class="lightbox-btn">
|
| 420 |
-
<svg fill="white" viewBox="0 0 24 24" width="24" height="24"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6-6-6z"/></svg>
|
| 421 |
-
</button>
|
| 422 |
-
</div>
|
| 423 |
-
</div>
|
| 424 |
-
<div id="confirmation-modal">
|
| 425 |
-
<div class="modal-dialog">
|
| 426 |
-
<div class="modal-icon">
|
| 427 |
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
| 428 |
-
<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/>
|
| 429 |
-
</svg>
|
| 430 |
-
</div>
|
| 431 |
-
<h3>تایید حذف</h3>
|
| 432 |
-
<p id="modal-message-text">آیا از انجام این عمل مطمئن هستید؟</p>
|
| 433 |
-
<div class="modal-buttons">
|
| 434 |
-
<button id="modal-cancel-btn" class="modal-btn cancel-btn">انصراف</button>
|
| 435 |
-
<button id="modal-confirm-btn" class="modal-btn confirm-btn">بله، حذف کن</button>
|
| 436 |
-
</div>
|
| 437 |
-
</div>
|
| 438 |
-
</div>
|
| 439 |
-
|
| 440 |
-
<script>
|
| 441 |
-
// --- START OF APPLICATION LOGIC SCRIPT (MODIFIED FOR IFRAME COMPATIBILITY) ---
|
| 442 |
-
const API_URL = 'https://alfa-editor-worker.onrender.com/api/edit';
|
| 443 |
-
const uploadArea = document.getElementById('upload-area'); const fileInput = document.getElementById('file-input'); const previewImage = document.getElementById('preview-image-main'); const removeFileBtn = document.getElementById('remove-file-btn-main'); const promptInput = document.getElementById('prompt-input'); const submitBtn = document.getElementById('submit-btn'); const resultContainer = document.getElementById('result-container'); const resultGrid = document.getElementById('result-grid'); const errorMessage = document.getElementById('error-message'); const lightbox = document.getElementById('lightbox'); const lightboxImg = document.getElementById('lightbox-img'); const lightboxClose = document.getElementById('lightbox-close'); const lightboxDownload = document.getElementById('lightbox-download'); const lightboxNext = document.getElementById('lightbox-next'); const historyGrid = document.getElementById('history-grid'); const clearHistoryBtn = document.getElementById('clear-history-btn'); const confirmationModal = document.getElementById('confirmation-modal'); const modalMessageText = document.getElementById('modal-message-text'); const modalConfirmBtn = document.getElementById('modal-confirm-btn'); const modalCancelBtn = document.getElementById('modal-cancel-btn');
|
| 444 |
-
let uploadedFile = null; let currentLightboxUrl = null; let currentLightboxGroup = []; let currentLightboxIndex = 0;
|
| 445 |
-
|
| 446 |
-
// --- START OF FIX ---
|
| 447 |
-
// Cache to store blob URLs and prevent re-fetching the same image
|
| 448 |
-
const loadedBlobUrls = new Map();
|
| 449 |
-
|
| 450 |
-
/**
|
| 451 |
-
* Loads an image via fetch, converts it to a blob URL, and sets it as the src of an img element.
|
| 452 |
-
* This helps bypass potential cross-origin/referrer policy issues inside an iframe.
|
| 453 |
-
* @param {HTMLImageElement} imgElement The image element to update.
|
| 454 |
-
* @param {string} imageUrl The original URL of the image to load.
|
| 455 |
-
*/
|
| 456 |
-
const loadImageAsBlob = (imgElement, imageUrl) => {
|
| 457 |
-
if (!imageUrl) return;
|
| 458 |
-
|
| 459 |
-
// Use cached blob URL if it exists
|
| 460 |
-
if (loadedBlobUrls.has(imageUrl)) {
|
| 461 |
-
imgElement.src = loadedBlobUrls.get(imageUrl);
|
| 462 |
-
return;
|
| 463 |
-
}
|
| 464 |
-
|
| 465 |
-
// Optional: Show a placeholder while the image is loading
|
| 466 |
-
imgElement.src = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'; // 1x1 transparent gif
|
| 467 |
-
|
| 468 |
-
fetch(imageUrl)
|
| 469 |
-
.then(response => {
|
| 470 |
-
if (!response.ok) {
|
| 471 |
-
throw new Error(`خطا در دریافت تصویر: ${response.statusText}`);
|
| 472 |
-
}
|
| 473 |
-
return response.blob();
|
| 474 |
-
})
|
| 475 |
-
.then(blob => {
|
| 476 |
-
const objectURL = URL.createObjectURL(blob);
|
| 477 |
-
loadedBlobUrls.set(imageUrl, objectURL); // Cache the new blob URL
|
| 478 |
-
imgElement.src = objectURL;
|
| 479 |
-
})
|
| 480 |
-
.catch(error => {
|
| 481 |
-
console.error('Image loading via blob failed:', error);
|
| 482 |
-
imgElement.alt = 'خطا در بارگذاری تصویر';
|
| 483 |
-
// You can set a broken image placeholder src here if you want
|
| 484 |
-
});
|
| 485 |
-
};
|
| 486 |
-
// --- END OF FIX ---
|
| 487 |
-
|
| 488 |
-
const convertToPNG = (file) => {
|
| 489 |
-
return new Promise((resolve, reject) => {
|
| 490 |
-
const image = new Image();
|
| 491 |
-
const reader = new FileReader();
|
| 492 |
-
image.onload = () => {
|
| 493 |
-
const canvas = document.createElement('canvas');
|
| 494 |
-
canvas.width = image.width;
|
| 495 |
-
canvas.height = image.height;
|
| 496 |
-
const ctx = canvas.getContext('2d');
|
| 497 |
-
ctx.drawImage(image, 0, 0);
|
| 498 |
-
canvas.toBlob((blob) => {
|
| 499 |
-
if (!blob) {
|
| 500 |
-
reject(new Error('تبدیل به PNG ناموفق بود.'));
|
| 501 |
-
return;
|
| 502 |
-
}
|
| 503 |
-
const originalName = file.name.substring(0, file.name.lastIndexOf('.')) || file.name;
|
| 504 |
-
const pngFile = new File([blob], `${originalName}.png`, { type: 'image/png' });
|
| 505 |
-
resolve(pngFile);
|
| 506 |
-
}, 'image/png', 1.0);
|
| 507 |
-
};
|
| 508 |
-
image.onerror = () => reject(new Error('فایل تصویر قابل خواندن نیست.'));
|
| 509 |
-
reader.onload = e => { image.src = e.target.result; };
|
| 510 |
-
reader.onerror = () => reject(new Error('خطا در خواندن فایل.'));
|
| 511 |
-
reader.readAsDataURL(file);
|
| 512 |
-
});
|
| 513 |
-
};
|
| 514 |
-
const handleFile = async (file) => {
|
| 515 |
-
if (!file || !file.type.startsWith('image/')) {
|
| 516 |
-
displayError('لطفا یک فایل تصویری معتبر انتخاب کنید.');
|
| 517 |
-
return;
|
| 518 |
-
}
|
| 519 |
-
let fileToProcess = file;
|
| 520 |
-
if (file.type !== 'image/png' && file.type !== 'image/jpeg') {
|
| 521 |
-
try {
|
| 522 |
-
fileToProcess = await convertToPNG(file);
|
| 523 |
-
} catch (error) {
|
| 524 |
-
console.error('Image conversion failed:', error);
|
| 525 |
-
displayError('خطا در تبدیل فرمت تصویر. لطفا فایل دیگری را امتحان کنید.');
|
| 526 |
-
resetUploader();
|
| 527 |
-
return;
|
| 528 |
-
}
|
| 529 |
-
}
|
| 530 |
-
uploadedFile = fileToProcess;
|
| 531 |
-
const reader = new FileReader();
|
| 532 |
-
reader.onload = (e) => { previewImage.src = e.target.result; };
|
| 533 |
-
reader.readAsDataURL(file);
|
| 534 |
-
uploadArea.classList.add('has-file');
|
| 535 |
-
checkFormState();
|
| 536 |
-
clearResult();
|
| 537 |
-
};
|
| 538 |
-
const showConfirmationModal = (message, onConfirm) => { modalMessageText.textContent = message; confirmationModal.classList.add('visible'); modalConfirmBtn.onclick = () => { onConfirm(); hideConfirmationModal(); }; modalCancelBtn.onclick = () => { hideConfirmationModal(); }; }; const hideConfirmationModal = () => { confirmationModal.classList.remove('visible'); modalConfirmBtn.onclick = null; modalCancelBtn.onclick = null; }; const resetUploader = () => { uploadedFile = null; fileInput.value = ''; previewImage.src = ''; uploadArea.classList.remove('has-file'); checkFormState(); }; const checkFormState = () => { submitBtn.disabled = !uploadedFile || promptInput.value.trim() === ''; }; const setLoading = (isLoading) => { const btnSpinner = submitBtn.querySelector('.spinner'); const btnText = document.getElementById('btn-text'); const btnIcon = submitBtn.querySelector('svg'); if (isLoading) { resultContainer.classList.remove('has-content'); resultContainer.classList.add('loading'); btnSpinner.style.display = 'inline-block'; btnIcon.style.display = 'none'; btnText.textContent = 'در حال پردازش...'; submitBtn.disabled = true; resultGrid.innerHTML = ''; errorMessage.style.display = 'none'; } else { resultContainer.classList.remove('loading'); btnSpinner.style.display = 'none'; btnIcon.style.display = 'inline-block'; btnText.textContent = 'ایجاد کن'; checkFormState(); } };
|
| 539 |
-
const displayResult = (imageUrls) => {
|
| 540 |
-
resultGrid.innerHTML = '';
|
| 541 |
-
imageUrls.forEach((url) => {
|
| 542 |
-
const img = document.createElement('img');
|
| 543 |
-
img.alt = 'تصویر ویرایش شده';
|
| 544 |
-
img.dataset.originalUrl = url; // Store original URL for lightbox and download
|
| 545 |
-
img.addEventListener('click', () => openLightbox(img.dataset.originalUrl, imageUrls));
|
| 546 |
-
resultGrid.appendChild(img);
|
| 547 |
-
loadImageAsBlob(img, url); // MODIFIED: Load image using the new function
|
| 548 |
-
});
|
| 549 |
-
resultContainer.classList.add('has-content');
|
| 550 |
-
};
|
| 551 |
-
const clearResult = () => { resultGrid.innerHTML = ''; errorMessage.style.display = 'none'; resultContainer.classList.remove('has-content'); }; const displayError = (message) => { errorMessage.textContent = message; errorMessage.style.display = 'block'; };
|
| 552 |
-
const updateLightboxImage = () => {
|
| 553 |
-
const newUrl = currentLightboxGroup[currentLightboxIndex];
|
| 554 |
-
currentLightboxUrl = newUrl; // Keep original URL for download functionality
|
| 555 |
-
loadImageAsBlob(lightboxImg, newUrl); // MODIFIED: Load the main lightbox image using the new function
|
| 556 |
-
};
|
| 557 |
-
const openLightbox = (clickedUrl, urlGroup) => {
|
| 558 |
-
currentLightboxGroup = urlGroup;
|
| 559 |
-
currentLightboxIndex = urlGroup.indexOf(clickedUrl);
|
| 560 |
-
updateLightboxImage();
|
| 561 |
-
lightboxNext.style.display = urlGroup.length > 1 ? 'flex' : 'none';
|
| 562 |
-
lightbox.classList.add('visible');
|
| 563 |
-
};
|
| 564 |
-
const closeLightbox = () => { lightbox.classList.remove('visible'); lightboxImg.src = ''; currentLightboxGroup = []; };
|
| 565 |
-
const handleDownload = async () => {
|
| 566 |
-
if (!currentLightboxUrl) return;
|
| 567 |
-
// --- NEW: Send message to parent for download ---
|
| 568 |
-
if (window.parent) {
|
| 569 |
-
window.parent.postMessage({ type: 'DOWNLOAD_REQUEST', url: currentLightboxUrl }, '*');
|
| 570 |
-
} else {
|
| 571 |
-
// Fallback for when not in an iframe
|
| 572 |
-
console.warn("Not in an iframe, attempting direct download.");
|
| 573 |
-
const spinner = lightboxDownload.querySelector('.spinner'); const icon = lightboxDownload.querySelector('svg'); spinner.style.display = 'block'; icon.style.display = 'none'; lightboxDownload.disabled = true; try { const response = await fetch(currentLightboxUrl); if (!response.ok) throw new Error('Network response was not ok.'); const blob = await response.blob(); const objectUrl = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = objectUrl; a.download = `ai-edited-image-${Date.now()}.png`; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(objectUrl); } catch (e) { console.error('Download failed:', e); alert('خطا در دانلود تصویر. لطفا دوباره تلاش کنید.'); } finally { spinner.style.display = 'none'; icon.style.display = 'block'; lightboxDownload.disabled = false; }
|
| 574 |
-
}
|
| 575 |
-
};
|
| 576 |
-
const getHistory = () => JSON.parse(localStorage.getItem('aiPhotoshopHistory') || '[]'); const saveHistory = (history) => { localStorage.setItem('aiPhotoshopHistory', JSON.stringify(history)); renderHistory(); }; const addToHistory = (item) => { let history = getHistory(); history.unshift(item); if (history.length > 15) history.pop(); saveHistory(history); }; const handleClearHistory = () => { showConfirmationModal('آیا از پاک کردن تمام تاریخچه مطمئن هستید؟ این عمل غیرقابل بازگشت است.', () => { saveHistory([]); }); }; const handleDeleteItem = (index) => { showConfirmationModal('آیا از حذف این مورد از تاریخچه مطمئن هستید؟', () => { let history = getHistory(); history.splice(index, 1); saveHistory(history); }); };
|
| 577 |
-
const renderHistory = () => {
|
| 578 |
-
const history = getHistory();
|
| 579 |
-
historyGrid.innerHTML = '';
|
| 580 |
-
clearHistoryBtn.style.display = history.length > 0 ? 'flex' : 'none';
|
| 581 |
-
history.forEach((item, index) => {
|
| 582 |
-
const card = document.createElement('div');
|
| 583 |
-
card.className = 'history-item';
|
| 584 |
-
const deleteBtn = document.createElement('button');
|
| 585 |
-
deleteBtn.className = 'history-delete-btn';
|
| 586 |
-
deleteBtn.title = 'حذف این مورد';
|
| 587 |
-
deleteBtn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>`;
|
| 588 |
-
deleteBtn.onclick = () => handleDeleteItem(index);
|
| 589 |
-
card.appendChild(deleteBtn);
|
| 590 |
-
const imageGrid = document.createElement('div');
|
| 591 |
-
imageGrid.className = 'history-item-grid';
|
| 592 |
-
item.urls.forEach(url => {
|
| 593 |
-
const img = document.createElement('img');
|
| 594 |
-
img.alt = 'تصویر از تاریخچه';
|
| 595 |
-
img.dataset.originalUrl = url; // Store original URL
|
| 596 |
-
img.addEventListener('click', () => openLightbox(img.dataset.originalUrl, item.urls));
|
| 597 |
-
imageGrid.appendChild(img);
|
| 598 |
-
loadImageAsBlob(img, url); // MODIFIED: Load image using the new function
|
| 599 |
-
});
|
| 600 |
-
card.appendChild(imageGrid);
|
| 601 |
-
historyGrid.appendChild(card);
|
| 602 |
-
});
|
| 603 |
-
};
|
| 604 |
-
document.addEventListener('DOMContentLoaded', () => { renderHistory(); checkFormState(); });
|
| 605 |
-
removeFileBtn.addEventListener('click', (e) => { e.preventDefault(); e.stopPropagation(); resetUploader(); }); fileInput.addEventListener('change', (e) => handleFile(e.target.files[0])); ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(e => { uploadArea.addEventListener(e, p => { p.preventDefault(); p.stopPropagation(); }); }); ['dragenter', 'dragover'].forEach(e => { uploadArea.addEventListener(e, () => { if (!uploadArea.classList.contains('has-file')) uploadArea.classList.add('drag-over'); }); }); ['dragleave', 'drop'].forEach(e => { uploadArea.addEventListener(e, () => uploadArea.classList.remove('drag-over')); }); uploadArea.addEventListener('drop', e => { if (!uploadArea.classList.contains('has-file')) handleFile(e.dataTransfer.files[0]); }); promptInput.addEventListener('input', checkFormState);
|
| 606 |
-
submitBtn.addEventListener('click', async () => { if (submitBtn.disabled) return; setLoading(true); const formData = new FormData(); formData.append('image', uploadedFile); formData.append('prompt', promptInput.value.trim()); try { const response = await fetch(API_URL, { method: 'POST', body: formData }); if (!response.ok) { const errorData = await response.json().catch(() => ({ error: `خطای سرور: ${response.statusText}` })); throw new Error(errorData.error || `یک خطای ناشناخته رخ داد.`); } const result = await response.json(); if (result.image_urls && Array.isArray(result.image_urls) && result.image_urls.length > 0) { displayResult(result.image_urls); addToHistory({ prompt: promptInput.value.trim(), urls: result.image_urls }); } else { throw new Error('پاسخ معتبری از سرور دریافت نشد.'); } } catch (error) { displayError(error.message); } finally { setLoading(false); } });
|
| 607 |
-
lightboxClose.addEventListener('click', closeLightbox); lightbox.addEventListener('click', (e) => { if (e.target === lightbox) closeLightbox(); }); lightboxDownload.addEventListener('click', handleDownload); lightboxNext.addEventListener('click', () => { currentLightboxIndex = (currentLightboxIndex + 1) % currentLightboxGroup.length; updateLightboxImage(); }); clearHistoryBtn.addEventListener('click', handleClearHistory);
|
| 608 |
-
</script>
|
| 609 |
-
|
| 610 |
-
<script>
|
| 611 |
-
// --- Header Animation Script (Unchanged) ---
|
| 612 |
-
document.addEventListener('DOMContentLoaded', () => {
|
| 613 |
-
const canvas = document.getElementById('neural-network-canvas');
|
| 614 |
-
const header = canvas.parentElement;
|
| 615 |
-
const ctx = canvas.getContext('2d');
|
| 616 |
-
let particles = [];
|
| 617 |
-
const particleCount = 20; const maxDistance = 100;
|
| 618 |
-
const computedStyles = getComputedStyle(document.documentElement);
|
| 619 |
-
const particleColor = computedStyles.getPropertyValue('--accent-primary').trim();
|
| 620 |
-
const lineColor = computedStyles.getPropertyValue('--text-tertiary').trim();
|
| 621 |
-
function resizeCanvas() { canvas.width = header.clientWidth; canvas.height = header.clientHeight; init(); }
|
| 622 |
-
class Particle { constructor() { this.x = Math.random() * canvas.width; this.y = Math.random() * canvas.height; this.vx = (Math.random() - 0.5) * 0.3; this.vy = (Math.random() - 0.5) * 0.3; this.radius = 1.2; } update() { this.x += this.vx; this.y += this.vy; if (this.x < 0 || this.x > canvas.width) this.vx *= -1; if (this.y < 0 || this.y > canvas.height) this.vy *= -1; } draw() { ctx.beginPath(); ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2); ctx.fillStyle = particleColor; ctx.fill(); } }
|
| 623 |
-
function init() { particles = []; for (let i = 0; i < particleCount; i++) { particles.push(new Particle()); } }
|
| 624 |
-
function connectParticles() { for (let i = 0; i < particles.length; i++) { for (let j = i + 1; j < particles.length; j++) { const dx = particles[i].x - particles[j].x; const dy = particles[i].y - particles[j].y; const distance = Math.sqrt(dx * dx + dy * dy); if (distance < maxDistance) { ctx.beginPath(); ctx.moveTo(particles[i].x, particles[i].y); ctx.lineTo(particles[j].x, particles[j].y); ctx.strokeStyle = lineColor; ctx.lineWidth = 0.2; ctx.globalAlpha = 1 - distance / maxDistance; ctx.stroke(); } } } ctx.globalAlpha = 1; }
|
| 625 |
-
function animate() { ctx.clearRect(0, 0, canvas.width, canvas.height); particles.forEach(particle => { particle.update(); particle.draw(); }); connectParticles(); requestAnimationFrame(animate); }
|
| 626 |
-
window.addEventListener('resize', resizeCanvas); resizeCanvas(); animate();
|
| 627 |
-
});
|
| 628 |
-
</script>
|
| 629 |
-
</body>
|
| 630 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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