samirerty commited on
Commit
f2c09fd
·
verified ·
1 Parent(s): 11dba48

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +578 -755
index.html CHANGED
@@ -1,764 +1,587 @@
1
  <!DOCTYPE html>
2
  <html lang="fa" dir="rtl">
3
-
4
  <head>
5
- <meta charset="UTF-8">
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
7
- <title>ورود و ثبت نام | نسخه مدرن و رسپانسیو</title>
8
-
9
- <!-- استفاده از فونت وزیر برای ظاهر بهتر فارسی -->
10
- <link href="https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css" rel="stylesheet" type="text/css" />
11
-
12
- <style>
13
- /* تنظیمات پایه و متغیرهای رنگی */
14
- :root {
15
- --bg-gradient-1: #0f172a;
16
- --bg-gradient-2: #1e1b4b;
17
- --bg-gradient-3: #312e81;
18
-
19
- --card-bg: rgba(30, 41, 59, 0.75);
20
- --card-border: rgba(255, 255, 255, 0.1);
21
-
22
- --input-bg: rgba(15, 23, 42, 0.6);
23
- --input-border: rgba(148, 163, 184, 0.2);
24
- --input-focus: #6366f1;
25
-
26
- --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
27
- --text-color: #f8fafc;
28
- --text-muted: #94a3b8;
29
-
30
- --font-main: 'Vazirmatn', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
31
- --radius: 16px;
32
- --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
33
- }
34
-
35
- * {
36
- box-sizing: border-box;
37
- margin: 0;
38
- padding: 0;
39
- -webkit-tap-highlight-color: transparent;
40
- }
41
-
42
- body {
43
- font-family: var(--font-main);
44
- background: linear-gradient(-45deg, var(--bg-gradient-1), var(--bg-gradient-2), var(--bg-gradient-3), #0f172a);
45
- background-size: 400% 400%;
46
- animation: gradientBG 15s ease infinite;
47
- color: var(--text-color);
48
- min-height: 100vh;
49
- display: flex;
50
- justify-content: center;
51
- align-items: center;
52
- padding: 20px;
53
- overflow-x: hidden;
54
- position: relative;
55
- }
56
-
57
- /* لینک هدر */
58
- .header-link {
59
- position: fixed;
60
- top: 20px;
61
- left: 20px;
62
- color: rgba(255, 255, 255, 0.6);
63
- text-decoration: none;
64
- font-size: 0.85rem;
65
- background: rgba(0, 0, 0, 0.3);
66
- backdrop-filter: blur(4px);
67
- padding: 8px 12px;
68
- border-radius: 20px;
69
- z-index: 100;
70
- border: 1px solid rgba(255, 255, 255, 0.05);
71
- transition: var(--transition);
72
- }
73
-
74
- .header-link:hover {
75
- color: #fff;
76
- background: rgba(255, 255, 255, 0.1);
77
- transform: translateY(-2px);
78
- }
79
-
80
- /* انیمیشن پس‌زمینه */
81
- @keyframes gradientBG {
82
- 0% { background-position: 0% 50%; }
83
- 50% { background-position: 100% 50%; }
84
- 100% { background-position: 0% 50%; }
85
- }
86
-
87
- /* کانتینر اصلی - افکت شیشه‌ای */
88
- .container {
89
- width: 100%;
90
- max-width: 420px;
91
- background: var(--card-bg);
92
- border: 1px solid var(--card-border);
93
- border-radius: var(--radius);
94
- padding: 40px 30px;
95
- box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
96
- backdrop-filter: blur(12px);
97
- -webkit-backdrop-filter: blur(12px);
98
- position: relative;
99
- overflow: hidden;
100
- margin: auto;
101
- }
102
-
103
- /* دکوراسیون نورانی پشت کارت */
104
- .container::before {
105
- content: '';
106
- position: absolute;
107
- top: -50%;
108
- left: -50%;
109
- width: 200%;
110
- height: 200%;
111
- background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
112
- pointer-events: none;
113
- z-index: -1;
114
- }
115
-
116
- /* هدر فرم */
117
- .form-header {
118
- text-align: center;
119
- margin-bottom: 30px;
120
- }
121
-
122
- .form-header h2 {
123
- font-size: 1.8rem;
124
- margin-bottom: 8px;
125
- background: linear-gradient(to right, #fff, #cbd5e1);
126
- -webkit-background-clip: text;
127
- -webkit-text-fill-color: transparent;
128
- font-weight: 800;
129
- }
130
-
131
- .form-header p {
132
- color: var(--text-muted);
133
- font-size: 0.95rem;
134
- }
135
-
136
- /* ورودی‌ها */
137
- .input-group {
138
- margin-bottom: 20px;
139
- position: relative;
140
- }
141
-
142
- .input-group label {
143
- display: block;
144
- margin-bottom: 8px;
145
- color: var(--text-muted);
146
- font-size: 0.85rem;
147
- font-weight: 500;
148
- }
149
-
150
- .input-wrapper {
151
- position: relative;
152
- display: flex;
153
- align-items: center;
154
- }
155
-
156
- .icon {
157
- width: 20px;
158
- height: 20px;
159
- fill: currentColor;
160
- transition: var(--transition);
161
- }
162
-
163
- .icon-left {
164
- position: absolute;
165
- right: 14px;
166
- color: var(--text-muted);
167
- pointer-events: none;
168
- }
169
-
170
- .input-wrapper input {
171
- width: 100%;
172
- padding: 14px 45px 14px 14px;
173
- background: var(--input-bg);
174
- border: 1px solid var(--input-border);
175
- border-radius: var(--radius);
176
- color: var(--text-color);
177
- font-family: var(--font-main);
178
- font-size: 1rem;
179
- transition: var(--transition);
180
- }
181
-
182
- .input-wrapper input:focus {
183
- border-color: var(--input-focus);
184
- box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
185
- outline: none;
186
- background: rgba(15, 23, 42, 0.8);
187
- }
188
-
189
- .input-wrapper:focus-within .icon-left {
190
- color: var(--input-focus);
191
- transform: scale(1.1);
192
- }
193
-
194
- .toggle-password {
195
- position: absolute;
196
- left: 14px;
197
- cursor: pointer;
198
- color: var(--text-muted);
199
- background: none;
200
- border: none;
201
- padding: 0;
202
- display: flex;
203
- align-items: center;
204
- transition: var(--transition);
205
- }
206
-
207
- .toggle-password:hover {
208
- color: #fff;
209
- }
210
-
211
- /* کپچا */
212
- .captcha-container {
213
- display: flex;
214
- align-items: center;
215
- gap: 10px;
216
- margin-bottom: 25px;
217
- flex-wrap: wrap;
218
- }
219
-
220
- canvas {
221
- background: rgba(255, 255, 255, 0.9);
222
- border-radius: 8px;
223
- cursor: pointer;
224
- box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
225
- transition: transform 0.2s;
226
- width: 100px;
227
- height: 42px;
228
- flex-shrink: 0;
229
- }
230
-
231
- canvas:active {
232
- transform: scale(0.98);
233
- }
234
-
235
- .refresh-btn {
236
- background: rgba(255, 255, 255, 0.1);
237
- border: none;
238
- color: var(--text-color);
239
- cursor: pointer;
240
- padding: 8px;
241
- border-radius: 8px;
242
- display: flex;
243
- align-items: center;
244
- justify-content: center;
245
- transition: var(--transition);
246
- flex-shrink: 0;
247
- }
248
-
249
- .refresh-btn:hover {
250
- background: rgba(255, 255, 255, 0.2);
251
- transform: rotate(180deg);
252
- }
253
-
254
- .captcha-container input {
255
- flex-grow: 1;
256
- padding: 12px;
257
- border-radius: var(--radius);
258
- border: 1px solid var(--input-border);
259
- background: var(--input-bg);
260
- color: white;
261
- text-align: center;
262
- font-family: monospace;
263
- font-size: 1.1rem;
264
- letter-spacing: 2px;
265
- min-width: 80px;
266
- }
267
-
268
- /* دکمه ارسال */
269
- .submit-btn {
270
- width: 100%;
271
- padding: 14px;
272
- background: var(--primary-gradient);
273
- color: white;
274
- border: none;
275
- border-radius: var(--radius);
276
- font-family: var(--font-main);
277
- font-size: 1rem;
278
- font-weight: 700;
279
- cursor: pointer;
280
- transition: var(--transition);
281
- display: flex;
282
- justify-content: center;
283
- align-items: center;
284
- gap: 10px;
285
- box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
286
- position: relative;
287
- overflow: hidden;
288
- }
289
-
290
- .submit-btn:hover {
291
- transform: translateY(-2px);
292
- box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
293
- }
294
-
295
- .submit-btn:active {
296
- transform: translateY(0);
297
- }
298
-
299
- .submit-btn:disabled {
300
- opacity: 0.7;
301
- cursor: not-allowed;
302
- transform: none;
303
- }
304
-
305
- /* تغییر حالت */
306
- .switch-mode {
307
- text-align: center;
308
- margin-top: 25px;
309
- font-size: 0.9rem;
310
- color: var(--text-muted);
311
- }
312
-
313
- .switch-mode button {
314
- background: none;
315
- border: none;
316
- color: #818cf8;
317
- cursor: pointer;
318
- font-family: var(--font-main);
319
- font-weight: 700;
320
- padding: 0 5px;
321
- position: relative;
322
- transition: var(--transition);
323
- }
324
-
325
- .switch-mode button::after {
326
- content: '';
327
- position: absolute;
328
- width: 0;
329
- height: 2px;
330
- bottom: -2px;
331
- right: 0;
332
- background-color: #818cf8;
333
- transition: width 0.3s;
334
- }
335
-
336
- .switch-mode button:hover::after {
337
- width: 100%;
338
- }
339
-
340
- /* مدیریت نمایش فرم‌ها (انیمیشن) */
341
- .form-wrapper {
342
- transition: opacity 0.4s ease, transform 0.4s ease;
343
- }
344
-
345
- .hidden {
346
- display: none;
347
- opacity: 0;
348
- transform: translateY(10px);
349
- }
350
-
351
- .fade-in {
352
- animation: fadeIn 0.5s forwards;
353
- }
354
-
355
- @keyframes fadeIn {
356
- from {
357
- opacity: 0;
358
- transform: translateY(10px);
359
- }
360
-
361
- to {
362
- opacity: 1;
363
- transform: translateY(0);
364
- }
365
- }
366
-
367
- /* Toast بهبود یافته */
368
- .toast-container {
369
- position: fixed;
370
- bottom: 30px;
371
- left: 50%;
372
- transform: translateX(-50%);
373
- z-index: 1000;
374
- display: flex;
375
- flex-direction: column;
376
- align-items: center;
377
- gap: 10px;
378
- width: 90%;
379
- max-width: 350px;
380
- pointer-events: none; /* اجازه کلیک روی فضای خالی */
381
- }
382
-
383
- .toast {
384
- background: rgba(30, 41, 59, 0.95);
385
- border: 1px solid rgba(255, 255, 255, 0.1);
386
- backdrop-filter: blur(10px);
387
- padding: 14px 20px;
388
- border-radius: 12px;
389
- box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
390
- color: var(--text-color);
391
- font-size: 0.9rem;
392
- display: flex;
393
- align-items: center;
394
- gap: 12px;
395
- width: 100%;
396
- animation: toastUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
397
- pointer-events: auto;
398
- }
399
-
400
- .toast.success {
401
- border-right: 4px solid #22c55e;
402
- }
403
-
404
- .toast.error {
405
- border-right: 4px solid #ef4444;
406
- }
407
-
408
- @keyframes toastUp {
409
- from {
410
- transform: translateY(50px);
411
- opacity: 0;
412
- }
413
-
414
- to {
415
- transform: translateY(0);
416
- opacity: 1;
417
- }
418
- }
419
-
420
- /* --- بخش رسپانسیو (Responsive) --- */
421
- @media (max-width: 480px) {
422
- .container {
423
- padding: 30px 20px;
424
- }
425
-
426
- .form-header h2 {
427
- font-size: 1.5rem;
428
- }
429
-
430
- .input-group label {
431
- font-size: 0.8rem;
432
- }
433
-
434
- /* بهینه‌سازی کپچا برای موبایل */
435
- .captcha-container {
436
- justify-content: space-between;
437
- gap: 8px;
438
- }
439
-
440
- canvas {
441
- width: 90px;
442
- height: 38px;
443
- }
444
-
445
- .captcha-container input {
446
- flex: 1;
447
- font-size: 1rem;
448
- }
449
-
450
- .header-link {
451
- font-size: 0.75rem;
452
- padding: 6px 10px;
453
- }
454
- }
455
-
456
- @media (max-width: 360px) {
457
- .container {
458
- padding: 25px 15px;
459
- }
460
-
461
- .submit-btn {
462
- font-size: 0.9rem;
463
- }
464
-
465
- /* اگر صفحه خیلی کوچک باشد، ورودی کپچا تمام عرض شود */
466
- .captcha-container {
467
- flex-direction: column;
468
- align-items: stretch;
469
- }
470
-
471
- .captcha-container > div {
472
- display: flex;
473
- justify-content: space-between;
474
- width: 100%;
475
- }
476
-
477
- canvas {
478
- width: 100%;
479
- }
480
- }
481
- </style>
482
  </head>
483
-
484
  <body>
485
 
486
- <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="header-link">
487
- Built with anycoder
488
- </a>
489
-
490
- <div class="container">
491
- <!-- فرم ورود -->
492
- <div id="login-form" class="form-wrapper fade-in">
493
- <div class="form-header">
494
- <h2>خوش آمدید</h2>
495
- <p>برای ادامه وارد حساب خود شوید</p>
496
- </div>
497
-
498
- <form onsubmit="handleLogin(event)">
499
- <div class="input-group">
500
- <label>نام کاربری</label>
501
- <div class="input-wrapper">
502
- <svg class="icon icon-left" viewBox="0 0 24 24">
503
- <path
504
- d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" />
505
- </svg>
506
- <input type="text" id="login-username" placeholder="نام کاربری" autocomplete="off">
507
- </div>
508
- </div>
509
-
510
- <div class="input-group">
511
- <label>رمز عبور</label>
512
- <div class="input-wrapper">
513
- <svg class="icon icon-left" viewBox="0 0 24 24">
514
- <path
515
- d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z" />
516
- </svg>
517
- <input type="password" id="login-password" placeholder="رمز عبور">
518
- <button type="button" class="toggle-password" onclick="togglePassword('login-password', this)">
519
- <svg class="icon" viewBox="0 0 24 24"><path d="M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78l3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z"/></svg>
520
- </button>
521
- </div>
522
- </div>
523
-
524
- <div class="captcha-container">
525
- <canvas id="captchaCanvas" width="100" height="42" title="کلیک برای تغییر"></canvas>
526
- <button type="button" class="refresh-btn" onclick="drawCaptcha()">
527
- <svg class="icon" viewBox="0 0 24 24"><path d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"/></svg>
528
- </button>
529
- <input type="text" id="login-captcha" placeholder="کد امنیتی" maxlength="5">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
530
  </div>
531
-
532
- <button type="submit" class="submit-btn">
533
- <span>ورود به حساب</span>
534
- <svg class="icon" viewBox="0 0 24 24"><path d="M11 7L9.6 8.4l2.6 2.6H2v2h10.2l-2.6 2.6L11 17l5-5-5-5zm9 12h-8v2h8c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2h-8v2h8v14z"/></svg>
535
- </button>
536
-
537
- <div class="switch-mode">
538
- حساب کاربری ندارید؟
539
- <button type="button" onclick="switchForm('register')">ثبت نام کنید</button>
540
- </div>
541
- </form>
542
  </div>
543
 
544
- <!-- فرم ثبت نام -->
545
- <div id="register-form" class="form-wrapper hidden">
546
- <div class="form-header">
547
- <h2>ایجاد حساب</h2>
548
- <p>به جمع ما بپیوندید</p>
549
- </div>
550
-
551
- <form onsubmit="handleRegister(event)">
552
- <div class="input-group">
553
- <label>نام کاربری</label>
554
- <div class="input-wrapper">
555
- <svg class="icon icon-left" viewBox="0 0 24 24">
556
- <path
557
- d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" />
558
- </svg>
559
- <input type="text" id="reg-username" placeholder="نام کاربری" autocomplete="off">
560
- </div>
561
- </div>
562
-
563
- <div class="input-group">
564
- <label>رمز عبور</label>
565
- <div class="input-wrapper">
566
- <svg class="icon icon-left" viewBox="0 0 24 24">
567
- <path
568
- d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z" />
569
- </svg>
570
- <input type="password" id="reg-password" placeholder="رمز عبور">
571
- <button type="button" class="toggle-password" onclick="togglePassword('reg-password', this)">
572
- <svg class="icon" viewBox="0 0 24 24"><path d="M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78l3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z"/></svg>
573
- </button>
574
- </div>
575
- </div>
576
-
577
- <div class="input-group">
578
- <label>تکرار رمز عبور</label>
579
- <div class="input-wrapper">
580
- <svg class="icon icon-left" viewBox="0 0 24 24">
581
- <path
582
- d="M12 1L3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5l-9-4zm-2 16l-4-4 1.41-1.41L10 14.17l6.59-6.59L18 9l-8 8z" />
583
- </svg>
584
- <input type="password" id="reg-confirm-password" placeholder="تکرار رمز عبور">
585
- </div>
586
- </div>
587
-
588
- <div class="captcha-container">
589
- <canvas id="captchaCanvasReg" width="100" height="42" title="کلیک برای تغییر"></canvas>
590
- <button type="button" class="refresh-btn" onclick="drawCaptcha(true)">
591
- <svg class="icon" viewBox="0 0 24 24"><path d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"/></svg>
592
- </button>
593
- <input type="text" id="reg-captcha" placeholder="کد امنیتی" maxlength="5">
594
- </div>
595
-
596
- <button type="submit" class="submit-btn">
597
- <span>ثبت نام رایگان</span>
598
- <svg class="icon" viewBox="0 0 24 24"><path d="M15 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm-9-2V7H4v3H1v2h3v3h2v-3h3v-2H6zm9 4c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>
599
- </button>
600
-
601
- <div class="switch-mode">
602
- قبلاً ثبت نام کرده‌اید؟
603
- <button type="button" onclick="switchForm('login')">وارد شوید</button>
604
- </div>
605
- </form>
606
- </div>
607
- </div>
608
-
609
- <div class="toast-container" id="toastContainer"></div>
610
-
611
- <script>
612
- let currentCaptcha = '';
613
- let currentCaptchaReg = '';
614
-
615
- window.onload = function() {
616
- drawCaptcha();
617
- drawCaptcha(true);
618
- document.getElementById('captchaCanvas').addEventListener('click', () => drawCaptcha());
619
- document.getElementById('captchaCanvasReg').addEventListener('click', () => drawCaptcha(true));
620
- };
621
-
622
- function switchForm(type) {
623
- const login = document.getElementById('login-form');
624
- const reg = document.getElementById('register-form');
625
- const activeForm = type === 'register' ? reg : login;
626
- const inactiveForm = type === 'register' ? login : reg;
627
-
628
- // انیمیشن خروجی
629
- inactiveForm.style.opacity = '0';
630
- inactiveForm.style.transform = 'translateY(-10px)';
631
-
632
- setTimeout(() => {
633
- inactiveForm.classList.add('hidden');
634
- document.querySelectorAll('input').forEach(i => i.value = '');
635
-
636
- // انیمیشن ورودی
637
- inactiveForm.classList.remove('fade-in'); // ریست کردن کلاس انیمیشن
638
- activeForm.classList.remove('hidden');
639
- activeForm.style.opacity = '0';
640
- activeForm.style.transform = 'translateY(10px)';
641
-
642
- // Force reflow
643
- void activeForm.offsetWidth;
644
-
645
- activeForm.classList.add('fade-in');
646
- activeForm.style.opacity = '1';
647
- activeForm.style.transform = 'translateY(0)';
648
-
649
- // مجددا کپچا رسم شود
650
- if(type === 'login') drawCaptcha();
651
- else drawCaptcha(true);
652
-
653
- }, 300);
654
- }
655
-
656
- function togglePassword(id, btn) {
657
- const input = document.getElementById(id);
658
- const isPassword = input.type === 'password';
659
-
660
- input.type = isPassword ? 'text' : 'password';
661
-
662
- // تغییر آیکون با چرخش
663
- btn.style.transform = isPassword ? 'rotate(0deg)' : 'rotate(360deg)';
664
- btn.style.transition = 'transform 0.5s ease';
665
-
666
- if (isPassword) {
667
- // چشم باز
668
- btn.innerHTML = '<svg class="icon" viewBox="0 0 24 24"><path d="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"/></svg>';
669
- } else {
670
- // چشم بسته
671
- btn.innerHTML = '<svg class="icon" viewBox="0 0 24 24"><path d="M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78l3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z"/></svg>';
672
- }
673
- }
674
-
675
- function drawCaptcha(isReg = false) {
676
- const cvs = document.getElementById(isReg ? 'captchaCanvasReg' : 'captchaCanvas');
677
- const ctx = cvs.getContext('2d');
678
- ctx.clearRect(0, 0, cvs.width, cvs.height);
679
-
680
- // پس زمینه روشن‌تر با گرادیانت ملایم
681
- const grd = ctx.createLinearGradient(0, 0, cvs.width, cvs.height);
682
- grd.addColorStop(0, "#f1f5f9");
683
- grd.addColorStop(1, "#e2e8f0");
684
- ctx.fillStyle = grd;
685
- ctx.fillRect(0, 0, cvs.width, cvs.height);
686
-
687
- const chars = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ';
688
- let txt = '';
689
- const colors = ['#ef4444', '#3b82f6', '#10b981', '#f59e0b', '#8b5cf6'];
690
-
691
- for(let i=0; i<5; i++) {
692
- txt += chars[Math.floor(Math.random()*chars.length)];
693
- }
694
-
695
- if(isReg) currentCaptchaReg = txt; else currentCaptcha = txt;
696
-
697
- ctx.font = 'bold 26px Courier New';
698
- ctx.textBaseline = 'middle';
699
-
700
- for(let i=0; i<5; i++) {
701
- ctx.save();
702
- ctx.translate(15 + i*17, 22);
703
- ctx.rotate((Math.random()-0.5)*0.5);
704
- ctx.fillStyle = colors[Math.floor(Math.random() * colors.length)];
705
- ctx.fillText(txt[i], 0, 0);
706
-
707
- // سایه برای حروف
708
- ctx.shadowColor = "rgba(0,0,0,0.1)";
709
- ctx.shadowBlur = 2;
710
- ctx.shadowOffsetX = 1;
711
- ctx.shadowOffsetY = 1;
712
-
713
- ctx.restore();
714
- }
715
-
716
- // خطوط نویز
717
- for(let i=0; i<7; i++) {
718
- ctx.strokeStyle = 'rgba(0,0,0,0.05)';
719
- ctx.lineWidth = 2;
720
- ctx.beginPath();
721
- ctx.moveTo(Math.random()*100, Math.random()*42);
722
- ctx.lineTo(Math.random()*100, Math.random()*42);
723
- ctx.stroke();
724
- }
725
- }
726
-
727
- function handleLogin(e) {
728
- e.preventDefault();
729
- const u = document.getElementById('login-username').value;
730
- const p = document.getElementById('login-password').value;
731
- const c = document.getElementById('login-captcha').value.toUpperCase();
732
-
733
- if(!u || !p) return showToast('لطفاً همه فیلدها را پر کنید', 'error');
734
- if(c !== currentCaptcha) return showToast('کد امنیتی اشتباه است', 'error');
735
-
736
- const btn = e.target.querySelector('.submit-btn');
737
- const originalContent = btn.innerHTML;
738
- btn.disabled = true;
739
- btn.innerHTML = '<span>در حال بررسی...</span>';
740
- btn.style.opacity = '0.8';
741
-
742
- setTimeout(() => {
743
- btn.disabled = false;
744
- btn.innerHTML = originalContent;
745
- btn.style.opacity = '1';
746
- showToast('ورود با موفقیت انجام شد!', 'success');
747
- }, 1500);
748
- }
749
-
750
- function handleRegister(e) {
751
- e.preventDefault();
752
- const u = document.getElementById('reg-username').value;
753
- const p = document.getElementById('reg-password').value;
754
- const cp = document.getElementById('reg-confirm-password').value;
755
- const c = document.getElementById('reg-captcha').value.toUpperCase();
756
-
757
- if(!u || !p || !cp) return showToast('لطفاً همه فیلدها را پر کنید', 'error');
758
- if(p.length < 6) return showToast('رمز عبور باید حداقل ۶ کاراکتر باشد', 'error');
759
- if(p !== cp) return showToast('تکرار رمز عبور مطابقت ندارد', 'error');
760
- if(c !== currentCaptchaReg) return showToast('کد امنیتی اشتباه است', 'error');
761
-
762
- const btn = e.target.querySelector('.submit-btn');
763
- const originalContent = btn.innerHTML;
764
- btn
 
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>ورود به چت روم | Chat Room Login</title>
7
+ <!-- استفاده از FontAwesome برای آیکون‌ها -->
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+
10
+ <style>
11
+ /* تنظیمات کلی و متغیرهای رنگی */
12
+ :root {
13
+ --bg-color: #0f172a;
14
+ --card-bg: rgba(30, 41, 59, 0.6);
15
+ --primary: #6366f1; /* رنگ اصلی بنفش-آبی */
16
+ --primary-hover: #4f46e5;
17
+ --text-main: #f8fafc;
18
+ --text-muted: #94a3b8;
19
+ --border-color: rgba(148, 163, 184, 0.2);
20
+ --error: #ef4444;
21
+ --success: #10b981;
22
+ --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
23
+ }
24
+
25
+ * {
26
+ box-sizing: border-box;
27
+ margin: 0;
28
+ padding: 0;
29
+ outline: none;
30
+ }
31
+
32
+ body {
33
+ font-family: var(--font-family);
34
+ background-color: var(--bg-color);
35
+ background-image:
36
+ radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%),
37
+ radial-gradient(at 50% 0%, hsla(225,39%,30%,1) 0, transparent 50%),
38
+ radial-gradient(at 100% 0%, hsla(339,49%,30%,1) 0, transparent 50%);
39
+ color: var(--text-main);
40
+ height: 100vh;
41
+ display: flex;
42
+ flex-direction: column;
43
+ justify-content: center;
44
+ align-items: center;
45
+ overflow: hidden;
46
+ }
47
+
48
+ /* هدر و لینک anycoder */
49
+ header {
50
+ position: absolute;
51
+ top: 20px;
52
+ width: 100%;
53
+ text-align: center;
54
+ z-index: 10;
55
+ }
56
+
57
+ .anycoder-link {
58
+ color: var(--text-muted);
59
+ text-decoration: none;
60
+ font-size: 0.9rem;
61
+ transition: color 0.3s ease;
62
+ }
63
+
64
+ .anycoder-link:hover {
65
+ color: var(--primary);
66
+ text-shadow: 0 0 8px var(--primary);
67
+ }
68
+
69
+ /* کانتینر اصلی کارت */
70
+ .container {
71
+ width: 100%;
72
+ max-width: 420px;
73
+ padding: 20px;
74
+ perspective: 1000px;
75
+ }
76
+
77
+ .card {
78
+ background: var(--card-bg);
79
+ backdrop-filter: blur(12px);
80
+ -webkit-backdrop-filter: blur(12px);
81
+ border: 1px solid var(--border-color);
82
+ border-radius: 20px;
83
+ padding: 40px 30px;
84
+ box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
85
+ animation: fadeIn 0.8s ease-out;
86
+ position: relative;
87
+ overflow: hidden;
88
+ }
89
+
90
+ @keyframes fadeIn {
91
+ from { opacity: 0; transform: translateY(20px); }
92
+ to { opacity: 1; transform: translateY(0); }
93
+ }
94
+
95
+ /* تب‌های سوئیچ */
96
+ .tabs {
97
+ display: flex;
98
+ justify-content: center;
99
+ margin-bottom: 30px;
100
+ position: relative;
101
+ border-bottom: 1px solid var(--border-color);
102
+ }
103
+
104
+ .tab-btn {
105
+ background: transparent;
106
+ border: none;
107
+ color: var(--text-muted);
108
+ font-family: inherit;
109
+ font-size: 1rem;
110
+ padding: 10px 20px;
111
+ cursor: pointer;
112
+ transition: all 0.3s ease;
113
+ position: relative;
114
+ z-index: 1;
115
+ }
116
+
117
+ .tab-btn.active {
118
+ color: var(--text-main);
119
+ font-weight: bold;
120
+ }
121
+
122
+ .tab-btn.active::after {
123
+ content: '';
124
+ position: absolute;
125
+ bottom: -1px;
126
+ left: 0;
127
+ width: 100%;
128
+ height: 3px;
129
+ background: var(--primary);
130
+ border-radius: 3px 3px 0 0;
131
+ box-shadow: 0 -2px 10px var(--primary);
132
+ }
133
+
134
+ /* فرم‌ها */
135
+ .form-wrapper {
136
+ position: relative;
137
+ min-height: 320px; /* ارتفاع ثابت برای جلوگیری از پرش */
138
+ }
139
+
140
+ .form-content {
141
+ position: absolute;
142
+ top: 0;
143
+ left: 0;
144
+ width: 100%;
145
+ transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
146
+ opacity: 0;
147
+ visibility: hidden;
148
+ transform: translateX(50px);
149
+ }
150
+
151
+ .form-content.active {
152
+ opacity: 1;
153
+ visibility: visible;
154
+ transform: translateX(0);
155
+ position: relative;
156
+ }
157
+
158
+ /* استایل ورودی‌ها */
159
+ .input-group {
160
+ position: relative;
161
+ margin-bottom: 20px;
162
+ }
163
+
164
+ .input-group i {
165
+ position: absolute;
166
+ top: 50%;
167
+ right: 15px;
168
+ transform: translateY(-50%);
169
+ color: var(--text-muted);
170
+ transition: color 0.3s;
171
+ }
172
+
173
+ .form-input {
174
+ width: 100%;
175
+ background: rgba(15, 23, 42, 0.6);
176
+ border: 1px solid var(--border-color);
177
+ border-radius: 12px;
178
+ padding: 12px 45px 12px 15px;
179
+ color: var(--text-main);
180
+ font-size: 0.95rem;
181
+ transition: all 0.3s ease;
182
+ }
183
+
184
+ .form-input:focus {
185
+ border-color: var(--primary);
186
+ box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
187
+ }
188
+
189
+ .form-input:focus + i {
190
+ color: var(--primary);
191
+ }
192
+
193
+ /* دکمه نمایش رمز عبور */
194
+ .toggle-password {
195
+ position: absolute;
196
+ left: 15px;
197
+ right: auto !important;
198
+ cursor: pointer;
199
+ }
200
+
201
+ /* بخش کپچا */
202
+ .captcha-area {
203
+ display: flex;
204
+ align-items: center;
205
+ gap: 10px;
206
+ margin-bottom: 20px;
207
+ background: rgba(255, 255, 255, 0.05);
208
+ padding: 10px;
209
+ border-radius: 12px;
210
+ }
211
+
212
+ #captchaCanvas {
213
+ background: #fff;
214
+ border-radius: 8px;
215
+ cursor: pointer;
216
+ }
217
+
218
+ .captcha-input {
219
+ flex: 1;
220
+ background: transparent;
221
+ border: none;
222
+ border-bottom: 1px solid var(--border-color);
223
+ color: var(--text-main);
224
+ padding: 5px;
225
+ text-align: center;
226
+ font-family: monospace;
227
+ font-size: 1.1rem;
228
+ letter-spacing: 2px;
229
+ }
230
+
231
+ .captcha-input:focus {
232
+ border-bottom-color: var(--primary);
233
+ }
234
+
235
+ /* دکمه اصلی */
236
+ .submit-btn {
237
+ width: 100%;
238
+ padding: 14px;
239
+ background: linear-gradient(135deg, var(--primary), #818cf8);
240
+ color: white;
241
+ border: none;
242
+ border-radius: 12px;
243
+ font-size: 1rem;
244
+ font-weight: bold;
245
+ cursor: pointer;
246
+ transition: transform 0.2s, box-shadow 0.2s;
247
+ font-family: inherit;
248
+ display: flex;
249
+ justify-content: center;
250
+ align-items: center;
251
+ gap: 10px;
252
+ }
253
+
254
+ .submit-btn:hover {
255
+ transform: translateY(-2px);
256
+ box-shadow: 0 10px 20px -10px var(--primary);
257
+ }
258
+
259
+ .submit-btn:active {
260
+ transform: translateY(0);
261
+ }
262
+
263
+ /* سیستم Toast Notification */
264
+ .toast-container {
265
+ position: fixed;
266
+ top: 20px;
267
+ left: 50%;
268
+ transform: translateX(-50%);
269
+ z-index: 1000;
270
+ display: flex;
271
+ flex-direction: column;
272
+ gap: 10px;
273
+ }
274
+
275
+ .toast {
276
+ min-width: 300px;
277
+ padding: 16px;
278
+ border-radius: 10px;
279
+ color: white;
280
+ font-size: 0.9rem;
281
+ display: flex;
282
+ align-items: center;
283
+ gap: 12px;
284
+ box-shadow: 0 10px 30px rgba(0,0,0,0.3);
285
+ animation: slideDown 0.4s ease forwards;
286
+ backdrop-filter: blur(5px);
287
+ }
288
+
289
+ .toast.success { background: rgba(16, 185, 129, 0.9); border-right: 4px solid #059669; }
290
+ .toast.error { background: rgba(239, 68, 68, 0.9); border-right: 4px solid #dc2626; }
291
+ .toast.info { background: rgba(59, 130, 246, 0.9); border-right: 4px solid #2563eb; }
292
+
293
+ @keyframes slideDown {
294
+ from { opacity: 0; transform: translateY(-20px); }
295
+ to { opacity: 1; transform: translateY(0); }
296
+ }
297
+
298
+ @keyframes fadeOut {
299
+ to { opacity: 0; transform: translateY(-20px); }
300
+ }
301
+
302
+ /* ریسپانسیو */
303
+ @media (max-width: 480px) {
304
+ .card {
305
+ padding: 30px 20px;
306
+ width: 95%;
307
+ }
308
+ .container {
309
+ padding: 10px;
310
+ }
311
+ }
312
+ </style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313
  </head>
 
314
  <body>
315
 
316
+ <!-- هدر شامل لینک مورد نظر -->
317
+ <header>
318
+ <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="anycoder-link">
319
+ Built with anycoder <i class="fas fa-code"></i>
320
+ </a>
321
+ </header>
322
+
323
+ <!-- کانتینر اصلی -->
324
+ <div class="container">
325
+ <div class="card">
326
+
327
+ <!-- تب‌های تغییر وضعیت -->
328
+ <div class="tabs">
329
+ <button class="tab-btn active" onclick="switchTab('login')">ورود</button>
330
+ <button class="tab-btn" onclick="switchTab('register')">ثبت‌نام</button>
331
+ </div>
332
+
333
+ <div class="form-wrapper">
334
+ <!-- فرم ورود -->
335
+ <form id="loginForm" class="form-content active" novalidate onsubmit="handleLogin(event)">
336
+ <div class="input-group">
337
+ <input type="text" class="form-input" placeholder="نام کاربری" required>
338
+ <i class="fas fa-user"></i>
339
+ </div>
340
+ <div class="input-group">
341
+ <input type="password" class="form-input" placeholder="رمز عبور" required>
342
+ <i class="fas fa-lock"></i>
343
+ <i class="fas fa-eye toggle-password" onclick="togglePassword(this)"></i>
344
+ </div>
345
+
346
+ <div class="captcha-area">
347
+ <canvas id="loginCaptcha" width="100" height="40" onclick="generateCaptcha('loginCaptcha')"></canvas>
348
+ <input type="text" class="captcha-input" placeholder="کد تصویر" maxlength="5">
349
+ <i class="fas fa-sync-alt" onclick="generateCaptcha('loginCaptcha')" style="cursor:pointer; color:var(--primary)"></i>
350
+ </div>
351
+
352
+ <button type="submit" class="submit-btn">
353
+ <span>ورود به حساب</span>
354
+ <i class="fas fa-arrow-left"></i>
355
+ </button>
356
+ </form>
357
+
358
+ <!-- فرم ثبت‌نام -->
359
+ <form id="registerForm" class="form-content" novalidate onsubmit="handleRegister(event)">
360
+ <div class="input-group">
361
+ <input type="text" class="form-input" placeholder="نام کاربری جدید" required>
362
+ <i class="fas fa-user-plus"></i>
363
+ </div>
364
+ <div class="input-group">
365
+ <input type="password" class="form-input" id="regPass" placeholder="رمز عبور" required>
366
+ <i class="fas fa-lock"></i>
367
+ <i class="fas fa-eye toggle-password" onclick="togglePassword(this)"></i>
368
+ </div>
369
+ <div class="input-group">
370
+ <input type="password" class="form-input" placeholder="تکرار رمز عبور" required>
371
+ <i class="fas fa-check-double"></i>
372
+ </div>
373
+
374
+ <div class="captcha-area">
375
+ <canvas id="regCaptcha" width="100" height="40" onclick="generateCaptcha('regCaptcha')"></canvas>
376
+ <input type="text" class="captcha-input" placeholder="کد تصویر" maxlength="5">
377
+ <i class="fas fa-sync-alt" onclick="generateCaptcha('regCaptcha')" style="cursor:pointer; color:var(--primary)"></i>
378
+ </div>
379
+
380
+ <button type="submit" class="submit-btn">
381
+ <span>ساخت حساب کاربری</span>
382
+ <i class="fas fa-user-check"></i>
383
+ </button>
384
+ </form>
385
+ </div>
386
  </div>
 
 
 
 
 
 
 
 
 
 
 
387
  </div>
388
 
389
+ <!-- کانتینر پیام‌ها -->
390
+ <div class="toast-container" id="toastContainer"></div>
391
+
392
+ <script>
393
+ // --- مدیریت تب‌ها ---
394
+ function switchTab(tab) {
395
+ const loginForm = document.getElementById('loginForm');
396
+ const registerForm = document.getElementById('registerForm');
397
+ const btns = document.querySelectorAll('.tab-btn');
398
+
399
+ if (tab === 'login') {
400
+ loginForm.classList.add('active');
401
+ registerForm.classList.remove('active');
402
+ btns[0].classList.add('active');
403
+ btns[1].classList.remove('active');
404
+ generateCaptcha('loginCaptcha'); // رفرش کپچا برای امنیت
405
+ } else {
406
+ loginForm.classList.remove('active');
407
+ registerForm.classList.add('active');
408
+ btns[0].classList.remove('active');
409
+ btns[1].classList.add('active');
410
+ generateCaptcha('regCaptcha'); // رفرش کپچا برای امنیت
411
+ }
412
+ }
413
+
414
+ // --- مدیریت نمایش/مخفی کردن رمز عبور ---
415
+ function togglePassword(icon) {
416
+ const input = icon.previousElementSibling.previousElementSibling;
417
+ if (input.type === 'password') {
418
+ input.type = 'text';
419
+ icon.classList.remove('fa-eye');
420
+ icon.classList.add('fa-eye-slash');
421
+ } else {
422
+ input.type = 'password';
423
+ icon.classList.remove('fa-eye-slash');
424
+ icon.classList.add('fa-eye');
425
+ }
426
+ }
427
+
428
+ // --- سیستم تولید کپچا (بدون نیاز به سرور) ---
429
+ const captchaCodes = {};
430
+
431
+ function generateCaptcha(canvasId) {
432
+ const canvas = document.getElementById(canvasId);
433
+ const ctx = canvas.getContext('2d');
434
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
435
+
436
+ // پس‌زمینه نویز
437
+ ctx.fillStyle = '#f1f5f9';
438
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
439
+
440
+ // تولید کد رندوم 5 کاراکتری
441
+ const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
442
+ let code = '';
443
+ for (let i = 0; i < 5; i++) {
444
+ code += chars[Math.floor(Math.random() * chars.length)];
445
+ }
446
+ captchaCodes[canvasId] = code;
447
+
448
+ // رسم متن
449
+ ctx.font = 'bold 24px monospace';
450
+ ctx.textBaseline = 'middle';
451
+ for (let i = 0; i < code.length; i++) {
452
+ ctx.save();
453
+ // چرخش و موقعیت تصادفی برای هر حرف
454
+ const x = 15 + i * 18;
455
+ const y = 20 + (Math.random() - 0.5) * 10;
456
+ const angle = (Math.random() - 0.5) * 0.4;
457
+
458
+ ctx.translate(x, y);
459
+ ctx.rotate(angle);
460
+ ctx.fillStyle = `rgb(${Math.random()*100}, ${Math.random()*100}, ${Math.random()*150})`;
461
+ ctx.fillText(code[i], 0, 0);
462
+ ctx.restore();
463
+ }
464
+
465
+ // اضافه کردن خطوط نویز
466
+ for (let i = 0; i < 5; i++) {
467
+ ctx.strokeStyle = `rgba(0,0,0,0.2)`;
468
+ ctx.beginPath();
469
+ ctx.moveTo(Math.random() * canvas.width, Math.random() * canvas.height);
470
+ ctx.lineTo(Math.random() * canvas.width, Math.random() * canvas.height);
471
+ ctx.stroke();
472
+ }
473
+ }
474
+
475
+ // --- سیستم نمایش پیام (Toast) ---
476
+ function showToast(message, type = 'info') {
477
+ const container = document.getElementById('toastContainer');
478
+ const toast = document.createElement('div');
479
+ toast.className = `toast ${type}`;
480
+
481
+ let icon = 'fa-info-circle';
482
+ if (type === 'success') icon = 'fa-check-circle';
483
+ if (type === 'error') icon = 'fa-exclamation-circle';
484
+
485
+ toast.innerHTML = `<i class="fas ${icon}"></i> <span>${message}</span>`;
486
+
487
+ container.appendChild(toast);
488
+
489
+ // حذف خودکار بعد از 3 ثانیه
490
+ setTimeout(() => {
491
+ toast.style.animation = 'fadeOut 0.4s ease forwards';
492
+ toast.addEventListener('animationend', () => {
493
+ toast.remove();
494
+ });
495
+ }, 3000);
496
+ }
497
+
498
+ // --- منطق فرم ورود ---
499
+ function handleLogin(e) {
500
+ e.preventDefault();
501
+ const inputs = e.target.querySelectorAll('input');
502
+ const username = inputs[0].value.trim();
503
+ const password = inputs[1].value.trim();
504
+ const captchaInput = inputs[2].value.trim();
505
+ const canvasId = 'loginCaptcha';
506
+
507
+ // اعتبارسنجی
508
+ if (!username || !password) {
509
+ showToast('لطفا تمام فیلدها را پر کنید', 'error');
510
+ return;
511
+ }
512
+ if (captchaInput.toLowerCase() !== captchaCodes[canvasId].toLowerCase()) {
513
+ showToast('کد تصویر اشتباه است', 'error');
514
+ generateCaptcha(canvasId);
515
+ inputs[2].value = '';
516
+ return;
517
+ }
518
+
519
+ // شبیه‌سازی ارسال به سرور
520
+ const btn = e.target.querySelector('button');
521
+ const originalText = btn.innerHTML;
522
+ btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> بررسی...';
523
+ btn.disabled = true;
524
+
525
+ setTimeout(() => {
526
+ btn.innerHTML = originalText;
527
+ btn.disabled = false;
528
+ showToast('خوش آمدید! ورود موفقیت آمیز بود.', 'success');
529
+ // اینجا می‌توان کاربر را به صفحه چت ردایرکت کرد
530
+ }, 1500);
531
+ }
532
+
533
+ // --- منطق فرم ثبت‌نام ---
534
+ function handleRegister(e) {
535
+ e.preventDefault();
536
+ const inputs = e.target.querySelectorAll('input');
537
+ const username = inputs[0].value.trim();
538
+ const pass = inputs[1].value.trim();
539
+ const confirmPass = inputs[2].value.trim();
540
+ const captchaInput = inputs[3].value.trim();
541
+ const canvasId = 'regCaptcha';
542
+
543
+ // اعتبارسنجی
544
+ if (!username || !pass || !confirmPass) {
545
+ showToast('لطفا تمام فیلدها را پر کنید', 'error');
546
+ return;
547
+ }
548
+ if (pass.length < 4) {
549
+ showToast('رمز عبور باید حداقل ۴ کاراکتر باشد', 'error');
550
+ return;
551
+ }
552
+ if (pass !== confirmPass) {
553
+ showToast('رمز عبور و تکرار آن مطابقت ندارند', 'error');
554
+ return;
555
+ }
556
+ if (captchaInput.toLowerCase() !== captchaCodes[canvasId].toLowerCase()) {
557
+ showToast('کد تصویر اشتباه است', 'error');
558
+ generateCaptcha(canvasId);
559
+ inputs[3].value = '';
560
+ return;
561
+ }
562
+
563
+ // شبیه‌سازی ثبت‌نام
564
+ const btn = e.target.querySelector('button');
565
+ const originalText = btn.innerHTML;
566
+ btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> در حال ثبت...';
567
+ btn.disabled = true;
568
+
569
+ setTimeout(() => {
570
+ btn.innerHTML = originalText;
571
+ btn.disabled = false;
572
+ showToast('حساب کاربری با موفقیت ساخته شد!', 'success');
573
+ // پاک کردن فرم و رفتن به تب ورود
574
+ e.target.reset();
575
+ switchTab('login');
576
+ }, 1500);
577
+ }
578
+
579
+ // مقداردهی اولیه کپچاها
580
+ window.onload = function() {
581
+ generateCaptcha('loginCaptcha');
582
+ generateCaptcha('regCaptcha');
583
+ };
584
+
585
+ </script>
586
+ </body>
587
+ </html>