Skydata001 commited on
Commit
ef45822
·
verified ·
1 Parent(s): d12af8e

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +502 -124
index.html CHANGED
@@ -3,137 +3,515 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>أداة إزالة الخلفية</title>
7
- <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/js/all.min.js"></script>
 
 
8
  <style>
9
- @import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap');
10
- body {
11
- font-family: 'Cairo', sans-serif;
12
- background-color: #0d0d1a;
13
- color: #ffffff;
14
- display: flex;
15
- justify-content: center;
16
- align-items: center;
17
- flex-direction: column;
18
- min-height: 100vh;
19
- padding: 20px;
20
- box-sizing: border-box;
21
- }
22
- h1 { color: #6366f1; }
23
- .container {
24
- background: #1e1e2e;
25
- padding: 25px;
26
- border-radius: 15px;
27
- border: 1px solid #333;
28
- text-align: center;
29
- width: 90%;
30
- max-width: 500px;
31
- box-shadow: 0 0 30px rgba(99, 102, 241, 0.2);
32
- }
33
- input[type="file"] { display: none; }
34
- .upload-label {
35
- display: inline-block;
36
- padding: 12px 25px;
37
- background: #6366f1;
38
- color: white;
39
- border-radius: 8px;
40
- cursor: pointer;
41
- transition: 0.3s;
42
- }
43
- .upload-label:hover { background: #4f52c2; }
44
- #submit-btn {
45
- display: none;
46
- margin-top: 15px;
47
- padding: 12px 30px;
48
- background: #28a745;
49
- color: white;
50
- border: none;
51
- border-radius: 8px;
52
- font-size: 16px;
53
- font-family: 'Cairo', sans-serif;
54
- cursor: pointer;
55
- }
56
- #status {
57
- margin-top: 20px;
58
- font-size: 15px;
59
- color: #aaa;
60
- height: 20px;
61
- }
62
- #result-area {
63
- display:none;
64
- margin-top: 25px;
65
- border-top: 1px solid #444;
66
- padding-top: 25px;
67
- }
68
- #result-img { max-width: 100%; border-radius: 8px; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  </style>
70
  </head>
71
  <body>
72
- <div class="container">
73
- <h1><i class="fas fa-magic"></i> أداة إزالة الخلفية</h1>
74
- <p style="color:#bbb; margin-bottom:25px;">ارفع صورتك واحصل عليها بخلفية شفافة.</p>
75
-
76
- <input type="file" id="file-input" accept="image/png, image/jpeg">
77
- <label for="file-input" class="upload-label">
78
- <i class="fas fa-upload"></i> اختر صورة
79
- </label>
80
-
81
- <div id="status"></div>
82
- <button id="submit-btn"><i class="fas fa-rocket"></i> ابدأ المعالجة</button>
83
-
84
- <div id="result-area">
85
- <h3>النتيجة (اضغط مطولاً للحفظ):</h3>
86
- <img id="result-img" alt="الصورة بعد إزالة الخلفية">
87
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
- <script>
91
- const fileInput = document.getElementById('file-input');
92
- const submitBtn = document.getElementById('submit-btn');
93
- const statusEl = document.getElementById('status');
94
- const resultArea = document.getElementById('result-area');
95
- const resultImg = document.getElementById('result-img');
96
-
97
- fileInput.addEventListener('change', () => {
98
- if (fileInput.files.length > 0) {
99
- statusEl.textContent = `تم اختيار: ${fileInput.files[0].name}`;
100
- submitBtn.style.display = 'inline-block';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  resultArea.style.display = 'none';
 
102
  }
103
- });
104
-
105
- submitBtn.addEventListener('click', async () => {
106
- if (fileInput.files.length === 0) return;
107
-
108
- statusEl.innerHTML = '<i class="fas fa-spinner fa-spin"></i> جاري المعالجة...';
109
- submitBtn.disabled = true;
110
-
111
- const formData = new FormData();
112
- formData.append('file', fileInput.files[0]);
113
-
114
- try {
115
- // إرسال الصورة إلى /remove-bg في app.py
116
- const response = await fetch('/remove-bg', {
117
- method: 'POST',
118
- body: formData
119
- });
120
-
121
- if (!response.ok) throw new Error('فشل المعالجة');
122
-
123
- // استقبال الصورة النظيفة
124
- const imageBlob = await response.blob();
125
- const imageUrl = URL.createObjectURL(imageBlob);
126
-
127
- resultImg.src = imageUrl;
128
- resultArea.style.display = 'block';
129
- statusEl.textContent = 'اكتملت المعالجة!';
130
-
131
- } catch (error) {
132
- statusEl.textContent = '⚠️ حدث خطأ. حاول بصورة أخرى.';
133
- } finally {
134
- submitBtn.disabled = false;
135
- }
136
- });
137
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  </body>
139
  </html>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title data-lang-key="pageTitle">SkyData - أداة إزالة الخلفية</title>
7
+ <link rel="icon" href="/favicon.ico" type="image/x-icon">
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">
9
+
10
  <style>
11
+ :root {
12
+ --primary-color: #007bff;
13
+ --primary-hover: #0056b3;
14
+ --glow-color-1: #6366f1;
15
+ --glow-color-2: #ec4899;
16
+ --glow-color-3: #f59e0b;
17
+ --dark-bg: #0d0d1a;
18
+ --bg-surface: #1a1a2e;
19
+ --text-color: #e0e0e0;
20
+ --text-muted: #aaa;
21
+ --border-color: #333;
22
+ --error-color: #EF665B;
23
+ --success-color: #28a745;
24
+ }
25
+ * {
26
+ box-sizing: border-box;
27
+ -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
28
+ tap-highlight-color: rgba(0, 0, 0, 0);
29
+ }
30
+ #app-container {
31
+ width: 100%;
32
+ overflow-x: hidden;
33
+ position: relative;
34
+ transform: translate3d(0, 0, 0);
35
+ min-height: 100vh;
36
+ display: flex;
37
+ flex-direction: column;
38
+ }
39
+ html { }
40
+ body {
41
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
42
+ direction: rtl;
43
+ background-color: var(--dark-bg);
44
+ color: var(--text-color);
45
+ margin: 0; padding: 0;
46
+ }
47
+ body::before {
48
+ content: '';
49
+ position: fixed;
50
+ top: 0; left: 0; right: 0; bottom: 0;
51
+ width: 100%;
52
+ height: 100%;
53
+ background: linear-gradient(
54
+ 135deg,
55
+ rgba(var(--glow-color-1), 0.15),
56
+ rgba(var(--glow-color-2), 0.1),
57
+ rgba(var(--glow-color-3), 0.15)
58
+ );
59
+ background-size: 400% 400%;
60
+ animation: glowingBackground 20s ease infinite;
61
+ z-index: -1;
62
+ filter: blur(50px);
63
+ }
64
+ @keyframes glowingBackground {
65
+ 0% { background-position: 0% 50%; }
66
+ 50% { background-position: 100% 50%; }
67
+ 100% { background-position: 0% 50%; }
68
+ }
69
+ header {
70
+ display: flex; justify-content: space-between; align-items: center;
71
+ padding: 15px 20px;
72
+ background-color: rgba(26, 26, 46, 0.7);
73
+ backdrop-filter: blur(10px);
74
+ border-bottom: 1px solid var(--border-color);
75
+ box-shadow: 0 2px 10px rgba(0,0,0,0.3);
76
+ width: 100%;
77
+ position: sticky;
78
+ top: 0;
79
+ z-index: 100;
80
+ }
81
+ .logo-container { display: flex; align-items: center; }
82
+ .logo-container img { height: 35px; margin-left: 10px; }
83
+ .logo-shine {
84
+ position: relative;
85
+ overflow: hidden;
86
+ }
87
+ .logo-shine::after {
88
+ content: '';
89
+ position: absolute;
90
+ top: 0;
91
+ left: -100%;
92
+ width: 50%;
93
+ height: 100%;
94
+ background: linear-gradient(
95
+ 90deg,
96
+ transparent,
97
+ rgba(255, 255, 255, 0.3),
98
+ transparent
99
+ );
100
+ transform: skewX(-25deg);
101
+ animation: shine-effect 5s infinite linear;
102
+ }
103
+ @keyframes shine-effect {
104
+ 0% { left: -100%; }
105
+ 50% { left: 150%; }
106
+ 100% { left: 150%; }
107
+ }
108
+ main {
109
+ flex-grow: 1;
110
+ display: flex;
111
+ justify-content: center;
112
+ align-items: center;
113
+ padding: 30px 0;
114
+ }
115
+ .main-wrapper {
116
+ max-width: 400px;
117
+ width: 95%;
118
+ }
119
+ .form {
120
+ display: flex;
121
+ flex-direction: column;
122
+ gap: 15px; /* (تم تعديل المسافة) */
123
+ padding: 30px;
124
+ border-radius: 10px;
125
+ position: relative;
126
+ background-color: var(--bg-surface);
127
+ color: var(--text-color);
128
+ border: 1px solid var(--border-color);
129
+ box-shadow: 0 5px 15px rgba(0,0,0,0.5);
130
+ animation: fadeIn 0.5s ease-out;
131
+ }
132
+ .title {
133
+ font-size: 24px;
134
+ font-weight: 600;
135
+ letter-spacing: -1px;
136
+ position: relative;
137
+ display: flex;
138
+ align-items: center;
139
+ color: var(--primary-color);
140
+ margin-bottom: 5px;
141
+ padding-right: 30px;
142
+ }
143
+ .title::before, .title::after {
144
+ position: absolute;
145
+ content: "";
146
+ height: 16px;
147
+ width: 16px;
148
+ border-radius: 50%;
149
+ right: 0px;
150
+ background-color: var(--primary-color);
151
+ }
152
+ .title::after { animation: pulse 1s linear infinite; }
153
+ .message-intro {
154
+ font-size: 14.5px;
155
+ color: var(--text-muted);
156
+ margin-bottom: 10px;
157
+ text-align: right;
158
+ }
159
+ .submit {
160
+ border: none;
161
+ outline: none;
162
+ padding: 14px;
163
+ border-radius: 8px;
164
+ color: #fff;
165
+ font-size: 1.2em;
166
+ font-weight: bold;
167
+ background-color: var(--primary-color);
168
+ cursor: pointer;
169
+ box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
170
+ margin-top: 15px;
171
+ transition: all 0.3s ease;
172
+ display: flex;
173
+ align-items: center;
174
+ justify-content: center;
175
+ text-align: center; /* (للعنصر label) */
176
+ }
177
+ .submit i { margin-left: 10px; }
178
+ [dir="rtl"] .submit i { margin-left: 0; margin-right: 10px; }
179
+ .submit:hover {
180
+ background-color: var(--primary-hover);
181
+ transform: translateY(-1px);
182
+ box-shadow: 0 6px 12px rgba(0, 123, 255, 0.4);
183
+ }
184
+ .submit:disabled { background: #555; cursor: not-allowed; box-shadow: none; }
185
+ .cancel-button {
186
+ display: block;
187
+ width: 100%;
188
+ text-decoration: none;
189
+ border: 1px solid var(--border-color);
190
+ outline: none;
191
+ padding: 14px;
192
+ border-radius: 8px;
193
+ color: var(--text-muted);
194
+ font-size: 1.2em;
195
+ font-weight: bold;
196
+ background-color: transparent;
197
+ cursor: pointer;
198
+ margin-top: 10px;
199
+ transition: all 0.3s ease;
200
+ text-align: center;
201
+ display: flex; /* (لإضافة الأيقونة) */
202
+ align-items: center;
203
+ justify-content: center;
204
+ }
205
+ .cancel-button i { margin-left: 10px; }
206
+ [dir="rtl"] .cancel-button i { margin-left: 0; margin-right: 10px; }
207
+ .cancel-button:hover {
208
+ background-color: var(--border-color);
209
+ color: var(--text-color);
210
+ }
211
+ .cancel-button:disabled { background: #555; cursor: not-allowed; border-color: #555; }
212
+ .loader-spinner {
213
+ border: 4px solid #333;
214
+ border-top: 4px solid var(--primary-color);
215
+ border-radius: 50%;
216
+ width: 20px;
217
+ height: 20px;
218
+ animation: spin 1s linear infinite;
219
+ display: none;
220
+ margin: 15px auto 0; /* (توسيط) */
221
+ }
222
+ #result-area {
223
+ display:none;
224
+ margin-top: 25px;
225
+ border-top: 1px solid var(--border-color);
226
+ padding-top: 25px;
227
+ text-align: center; /* (توسيط النتيجة) */
228
+ }
229
+ #result-img {
230
+ max-width: 100%;
231
+ border-radius: 8px;
232
+ border: 1px solid var(--border-color);
233
+ }
234
+ @keyframes pulse {
235
+ from { transform: scale(0.9); opacity: 1; }
236
+ to { transform: scale(1.8); opacity: 0; }
237
+ }
238
+ @keyframes spin {
239
+ to { transform: rotate(360deg); }
240
+ }
241
+ @keyframes fadeIn {
242
+ from { opacity: 0; transform: translateY(10px); }
243
+ to { opacity: 1; transform: translateY(0); }
244
+ }
245
+ #global-toast {
246
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
247
+ width: 320px;
248
+ max-width: 90%;
249
+ padding: 15px;
250
+ display: none;
251
+ align-items: center;
252
+ gap: 10px;
253
+ border-radius: 8px;
254
+ box-shadow: 0 5px 15px rgba(0,0,0,0.5);
255
+ position: fixed;
256
+ bottom: -100px;
257
+ left: 50%;
258
+ transform: translateX(-50%);
259
+ z-index: 2000;
260
+ transition: opacity 0.3s ease, bottom 0.3s ease;
261
+ opacity: 0;
262
+ }
263
+ #global-toast.show {
264
+ display: flex;
265
+ opacity: 1;
266
+ bottom: 20px;
267
+ }
268
+ #global-toast.success {
269
+ background: #E0F2E9;
270
+ border: 1px solid var(--success-color);
271
+ }
272
+ #global-toast.success .toast-title { color: #155724; }
273
+ #global-toast.success .toast-icon { fill: var(--success-color); }
274
+ #global-toast.error {
275
+ background: #FCE8DB;
276
+ border: 1px solid var(--error-color);
277
+ }
278
+ #global-toast.error .toast-title { color: #71192F; }
279
+ #global-toast.error .toast-icon { fill: var(--error-color); }
280
+ .toast-icon {
281
+ width: 20px;
282
+ height: 20px;
283
+ flex-shrink: 0;
284
+ }
285
+ .toast-title {
286
+ font-weight: 600;
287
+ font-size: 14px;
288
+ width: 100%;
289
+ line-height: 1.4;
290
+ direction: rtl; /* (ضمان الاتجاه داخل الـ Toast) */
291
+ }
292
+ .toast-close-btn {
293
+ background: none;
294
+ border: none;
295
+ color: var(--text-muted);
296
+ cursor: pointer;
297
+ font-size: 1.5em;
298
+ line-height: 1;
299
+ padding: 0 5px;
300
+ margin-left: auto;
301
+ flex-shrink: 0;
302
+ }
303
+ [dir="rtl"] .toast-close-btn {
304
+ margin-left: 0;
305
+ margin-right: auto;
306
+ }
307
+ #global-toast.success .toast-close-btn { color: #155724; }
308
+ #global-toast.error .toast-close-btn { color: #71192F; }
309
+ footer {
310
+ background-color: rgba(26, 26, 46, 0.7);
311
+ backdrop-filter: blur(10px);
312
+ color: #fff;
313
+ padding: 30px 20px;
314
+ text-align: center;
315
+ margin-top: auto;
316
+ border-top: 1px solid var(--border-color);
317
+ width: 100%;
318
+ }
319
+ .footer-links-card {
320
+ margin: 0 auto;
321
+ border: 1px solid var(--border-color);
322
+ background: rgba(0,0,0,0.2);
323
+ padding: 20px;
324
+ border-radius: 12px;
325
+ max-width: 400px;
326
+ box-shadow: 0 0 20px rgba(0,0,0,0.3);
327
+ }
328
+ .footer-links-card a {
329
+ color: var(--text-muted);
330
+ text-decoration: none;
331
+ font-size: 1.1em;
332
+ transition: color 0.2s ease;
333
+ display: block;
334
+ margin: 10px 0;
335
+ }
336
+ .footer-links-card a:hover {
337
+ color: var(--primary-color);
338
+ }
339
+ @media (max-width: 380px) {
340
+ .logo-container img { height: 30px; }
341
+ }
342
  </style>
343
  </head>
344
  <body>
345
+
346
+ <div id="app-container">
347
+
348
+ <header>
349
+ <div class="logo-container">
350
+ <img src="https://i.ibb.co/hJ2nq38z/clouddata.webp" alt="شعار CloudData" class="logo-shine">
351
+ <img src="https://i.ibb.co/v9zLrFg/skydata.webp" alt="شعار Skydata" class="logo-shine">
352
+ </div>
353
+ </header>
354
+
355
+ <main>
356
+ <div class="main-wrapper" id="loginWrapper">
357
+
358
+ <div class="form">
359
+
360
+ <p class="title" dir="rtl">
361
+ <i class="fas fa-magic" style="margin-left: 10px;"></i>
362
+ أداة إزالة الخلفية
363
+ </p>
364
+ <p class="message-intro">
365
+ ارفع صورتك واحصل عليها بخلفية شفافة. (الحد الأقصى: 10 ميجابايت)
366
+ </p>
367
+
368
+ <input type="file" id="file-input" accept="image/png, image/jpeg" style="display: none;">
369
+
370
+ <label for="file-input" class="submit" id="upload-label">
371
+ <i class="fas fa-upload"></i> اختر صورة
372
+ </label>
373
+
374
+ <button id="submit-btn" class="cancel-button" style="display: none;">
375
+ <i class="fas fa-rocket"></i> ابدأ المعالجة
376
+ </button>
377
+
378
+ <div class="loader-spinner" id="loadingSpinner"></div>
379
+
380
+ <div id="result-area">
381
+ <h3 style="color: var(--text-color);">النتيجة (اضغط مطولاً للحفظ):</h3>
382
+ <img id="result-img" alt="الصورة بعد إزالة الخلفية">
383
+ </div>
384
+ </div>
385
+
386
+ </div>
387
+ </main>
388
+
389
+ <footer>
390
+ <div class="footer-links-card">
391
+ <a href="Safety.html">شروط الاستخدام وسياسة الخصوصية</a>
392
+ <a href="aboutus.html">عن Skydata</a>
393
  </div>
394
+ </footer>
395
+
396
+ <div id="global-toast">
397
+ <svg class="toast-icon" viewBox="0 0 24 24" height="24" width="24" xmlns="http://www.w3.org/2000/svg">
398
+ <path d="m13 13h-2v-6h2zm0 4h-2v-2h2zm-1-15c-1.3132 0-2.61358.25866-3.82683.7612-1.21326.50255-2.31565 1.23915-3.24424 2.16773-1.87536 1.87537-2.92893 4.41891-2.92893 7.07107 0 2.6522 1.05357 5.1957 2.92893 7.0711.92859.9286 2.03098 1.6651 3.24424 2.1677 1.21325.5025 2.51363.7612 3.82683.7612 2.6522 0 5.1957-1.0536 7.0711-2.9289 1.8753-1.8754 2.9289-4.4189 2.9289-7.0711 0-1.3132-.2587-2.61358-.7612-3.82683-.5026-1.21326-1.2391-2.31565-2.1677-3.24424-.9286-.92858-2.031-1.66518-3.2443-2.16773-1.2132-.50254-2.5136-.7612-3.8268-.7612z"></path>
399
+ </svg>
400
+ <div class="toast-title" id="toast-title"></div>
401
+ <button class="toast-close-btn" id="toast-close-btn">&times;</button>
402
+ </div>
403
+ </div>
404
+
405
+ <script>
406
+ // --- عناصر الواجهة ---
407
+ const fileInput = document.getElementById('file-input');
408
+ const submitBtn = document.getElementById('submit-btn');
409
+ const uploadLabel = document.getElementById('upload-label'); // (الزر الأخضر)
410
+ const loadingSpinner = document.getElementById('loadingSpinner');
411
+ const resultArea = document.getElementById('result-area');
412
+ const resultImg = document.getElementById('result-img');
413
+
414
+ // --- عناصر الإشعارات (Toast) ---
415
+ const globalToast = document.getElementById('global-toast');
416
+ const toastTitle = document.getElementById('toast-title');
417
+ const toastCloseBtn = document.getElementById('toast-close-btn');
418
+ let toastTimer;
419
 
420
+ // --- دالة إظهار الإشعارات (من login.html) ---
421
+ function showToast(message, type = 'success', duration = 5000) {
422
+ if (toastTimer) clearTimeout(toastTimer);
423
+
424
+ toastTitle.innerHTML = message;
425
+ globalToast.className = '';
426
+ globalToast.classList.add(type);
427
+ globalToast.classList.add('show');
428
+
429
+ if (duration > 0) {
430
+ toastTimer = setTimeout(() => {
431
+ globalToast.classList.remove('show');
432
+ }, duration);
433
+ }
434
+ }
435
+
436
+ // --- دالة إخفاء الإشعارات ---
437
+ toastCloseBtn.addEventListener('click', () => {
438
+ if (toastTimer) clearTimeout(toastTimer);
439
+ globalToast.classList.remove('show');
440
+ });
441
+
442
+
443
+ // --- معالج حدث اختيار الملف (مع التحقق من الحجم) ---
444
+ fileInput.addEventListener('change', () => {
445
+ // إخفاء الـ Toast القديم إذا كان موجوداً
446
+ globalToast.classList.remove('show');
447
+
448
+ if (fileInput.files.length > 0) {
449
+ const file = fileInput.files[0];
450
+ const MAX_SIZE = 10 * 1024 * 1024; // 10 MB
451
+
452
+ // *************************************
453
+ // * 9. التحقق من الحد الأقصى للحجم (10 ميغا)
454
+ // *************************************
455
+ if (file.size > MAX_SIZE) {
456
+ showToast('حجم الملف كبير جداً. الحد الأقصى 10 ميجابايت.', 'error', 0); // (0 = يبقى ولا يختفي)
457
+ fileInput.value = ''; // (إلغاء اختيار الملف)
458
+ submitBtn.style.display = 'none';
459
  resultArea.style.display = 'none';
460
+ return; // (إنهاء الدالة)
461
  }
462
+
463
+ // إذا كان الحجم مقبولاً
464
+ showToast(`تم اختيار: ${file.name}`, 'success', 3000); // (إشعار نجاح)
465
+ submitBtn.style.display = 'block';
466
+ resultArea.style.display = 'none';
467
+ }
468
+ });
469
+
470
+ // --- معالج حدث الضغط على زر "ابدأ المعالجة" ---
471
+ submitBtn.addEventListener('click', async () => {
472
+ if (fileInput.files.length === 0) return;
473
+
474
+ // إخفاء الـ Toast القديم
475
+ globalToast.classList.remove('show');
476
+
477
+ // استخدام مؤشر التحميل بدلاً من النص
478
+ loadingSpinner.style.display = 'block';
479
+ submitBtn.disabled = true;
480
+ uploadLabel.style.pointerEvents = 'none'; // (منع الضغط على زر الاختيار)
481
+ uploadLabel.style.opacity = '0.7';
482
+
483
+ const formData = new FormData();
484
+ formData.append('file', fileInput.files[0]);
485
+
486
+ try {
487
+ // إرسال الصورة إلى /remove-bg في app.py
488
+ const response = await fetch('/remove-bg', {
489
+ method: 'POST',
490
+ body: formData
491
+ });
492
+
493
+ if (!response.ok) throw new Error('فشل المعالجة');
494
+
495
+ // استقبال الصورة النظيفة
496
+ const imageBlob = await response.blob();
497
+ const imageUrl = URL.createObjectURL(imageBlob);
498
+
499
+ resultImg.src = imageUrl;
500
+ resultArea.style.display = 'block';
501
+ showToast('اكتملت المعالجة بنجاح!', 'success', 4000);
502
+
503
+ } catch (error) {
504
+ // استخدام الـ Toast لعرض الخطأ
505
+ showToast('⚠️ حدث خطأ. حاول بصورة أخرى أو تأكد من اتصالك.', 'error', 0);
506
+ } finally {
507
+ // إخفاء مؤشر التحميل وإعادة تفعيل الأزرار
508
+ loadingSpinner.style.display = 'none';
509
+ submitBtn.disabled = false;
510
+ uploadLabel.style.pointerEvents = 'auto';
511
+ uploadLabel.style.opacity = '1';
512
+ }
513
+ });
514
+ </script>
515
+
516
  </body>
517
  </html>