Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- index.html +202 -318
index.html
CHANGED
|
@@ -4,138 +4,99 @@
|
|
| 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>ورود و ثبت نام | س
|
| 8 |
-
|
| 9 |
-
<!-- ایمپورت فونت وزیرمتن -->
|
| 10 |
-
<link href="https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css" rel="stylesheet"
|
| 11 |
-
type="text/css" />
|
| 12 |
-
|
| 13 |
-
<!-- ایمپورت کتابخانه آیکونها -->
|
| 14 |
-
<script src="https://unpkg.com/@phosphor-icons/web"></script>
|
| 15 |
|
| 16 |
<style>
|
| 17 |
-
/* تنظیمات متغیرها
|
| 18 |
:root {
|
| 19 |
-
--bg-color: #
|
| 20 |
-
--card-bg:
|
| 21 |
-
--input-bg:
|
| 22 |
--primary-color: #6366f1;
|
| 23 |
--primary-hover: #4f46e5;
|
| 24 |
-
--text-color: #
|
| 25 |
--text-muted: #94a3b8;
|
| 26 |
-
--border-color: #
|
| 27 |
--error-color: #ef4444;
|
| 28 |
--success-color: #22c55e;
|
| 29 |
-
--font-
|
| 30 |
-
--
|
| 31 |
-
--radius: 16px;
|
| 32 |
}
|
| 33 |
|
| 34 |
* {
|
| 35 |
box-sizing: border-box;
|
| 36 |
margin: 0;
|
| 37 |
padding: 0;
|
| 38 |
-
|
| 39 |
-
-webkit-tap-highlight-color: transparent; /* حذف هایلایت آبی در موبایل */
|
| 40 |
}
|
| 41 |
|
| 42 |
body {
|
| 43 |
-
font-family: var(--font-
|
| 44 |
background-color: var(--bg-color);
|
| 45 |
-
/* پسزمینه گرادینت متحرک */
|
| 46 |
-
background-image:
|
| 47 |
-
radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 1) 0, transparent 50%),
|
| 48 |
-
radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%),
|
| 49 |
-
radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 1) 0, transparent 50%);
|
| 50 |
-
background-size: 150% 150%;
|
| 51 |
-
animation: gradientBG 15s ease infinite;
|
| 52 |
color: var(--text-color);
|
| 53 |
min-height: 100vh;
|
| 54 |
display: flex;
|
| 55 |
justify-content: center;
|
| 56 |
align-items: center;
|
| 57 |
-
|
| 58 |
-
padding: clamp(15px, 4vw, 40px);
|
| 59 |
-
overflow-x: hidden;
|
| 60 |
-
}
|
| 61 |
-
|
| 62 |
-
@keyframes gradientBG {
|
| 63 |
-
0% { background-position: 0% 50%; }
|
| 64 |
-
50% { background-position: 100% 50%; }
|
| 65 |
-
100% { background-position: 0% 50%; }
|
| 66 |
}
|
| 67 |
|
| 68 |
/* لینک هدر */
|
| 69 |
.header-link {
|
| 70 |
position: fixed;
|
| 71 |
-
top:
|
| 72 |
-
left:
|
| 73 |
color: var(--text-muted);
|
| 74 |
text-decoration: none;
|
| 75 |
-
font-size: 0.
|
| 76 |
-
|
|
|
|
|
|
|
| 77 |
z-index: 100;
|
| 78 |
-
background: rgba(15, 23, 42, 0.5);
|
| 79 |
-
padding: 5px 10px;
|
| 80 |
-
border-radius: 20px;
|
| 81 |
-
backdrop-filter: blur(4px);
|
| 82 |
}
|
| 83 |
|
| 84 |
.header-link:hover {
|
| 85 |
color: var(--primary-color);
|
| 86 |
-
background: rgba(15, 23, 42, 0.8);
|
| 87 |
}
|
| 88 |
|
| 89 |
-
/* کانتینر اصلی
|
| 90 |
.container {
|
| 91 |
width: 100%;
|
| 92 |
-
max-width:
|
| 93 |
background: var(--card-bg);
|
| 94 |
-
|
| 95 |
-
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
/* پدینگ سیال برای رسپانسیو بودن */
|
| 99 |
-
padding: clamp(25px, 6vw, 40px);
|
| 100 |
-
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
|
| 101 |
-
position: relative;
|
| 102 |
-
overflow: hidden;
|
| 103 |
-
margin: auto;
|
| 104 |
}
|
| 105 |
|
| 106 |
/* هدر فرم */
|
| 107 |
.form-header {
|
| 108 |
text-align: center;
|
| 109 |
-
margin-bottom:
|
| 110 |
}
|
| 111 |
|
| 112 |
.form-header h2 {
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
margin-bottom: 8px;
|
| 117 |
-
background: linear-gradient(to right, #818cf8, #c084fc);
|
| 118 |
-
-webkit-background-clip: text;
|
| 119 |
-
-webkit-text-fill-color: transparent;
|
| 120 |
}
|
| 121 |
|
| 122 |
.form-header p {
|
| 123 |
color: var(--text-muted);
|
| 124 |
-
font-size:
|
| 125 |
}
|
| 126 |
|
| 127 |
/* ورودیها */
|
| 128 |
.input-group {
|
| 129 |
-
margin-bottom:
|
| 130 |
-
position: relative;
|
| 131 |
}
|
| 132 |
|
| 133 |
.input-group label {
|
| 134 |
display: block;
|
| 135 |
-
margin-bottom:
|
| 136 |
color: var(--text-muted);
|
| 137 |
-
font-size: 0.
|
| 138 |
-
transition: var(--transition);
|
| 139 |
}
|
| 140 |
|
| 141 |
.input-wrapper {
|
|
@@ -144,63 +105,65 @@
|
|
| 144 |
align-items: center;
|
| 145 |
}
|
| 146 |
|
| 147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
position: absolute;
|
| 149 |
-
right:
|
| 150 |
color: var(--text-muted);
|
| 151 |
-
font-size: 1.2rem;
|
| 152 |
pointer-events: none;
|
| 153 |
}
|
| 154 |
|
| 155 |
.input-wrapper input {
|
| 156 |
width: 100%;
|
| 157 |
-
|
| 158 |
-
padding: 14px 45px 14px 15px;
|
| 159 |
background: var(--input-bg);
|
| 160 |
border: 1px solid var(--border-color);
|
| 161 |
border-radius: var(--radius);
|
| 162 |
color: var(--text-color);
|
| 163 |
-
font-family: var(--font-
|
| 164 |
-
font-size:
|
| 165 |
-
transition: var(--transition);
|
| 166 |
}
|
| 167 |
|
| 168 |
.input-wrapper input:focus {
|
| 169 |
border-color: var(--primary-color);
|
| 170 |
-
|
| 171 |
}
|
| 172 |
|
| 173 |
.toggle-password {
|
| 174 |
position: absolute;
|
| 175 |
-
left:
|
| 176 |
cursor: pointer;
|
| 177 |
color: var(--text-muted);
|
| 178 |
-
|
| 179 |
-
|
|
|
|
|
|
|
|
|
|
| 180 |
}
|
| 181 |
|
| 182 |
.toggle-password:hover {
|
| 183 |
color: var(--text-color);
|
| 184 |
}
|
| 185 |
|
| 186 |
-
/*
|
| 187 |
.captcha-container {
|
| 188 |
display: flex;
|
| 189 |
align-items: center;
|
| 190 |
-
gap:
|
| 191 |
-
margin-bottom:
|
| 192 |
-
|
| 193 |
-
padding: 10px;
|
| 194 |
-
border-radius: var(--radius);
|
| 195 |
-
flex-wrap: wrap; /* اجازه به خط رفتن در صفحات کوچک */
|
| 196 |
-
justify-content: center;
|
| 197 |
}
|
| 198 |
|
| 199 |
-
canvas
|
| 200 |
-
background
|
| 201 |
-
border-radius:
|
| 202 |
cursor: pointer;
|
| 203 |
-
flex-shrink: 0; /* جلوگیری از کوچک شدن بیش از حد */
|
| 204 |
}
|
| 205 |
|
| 206 |
.refresh-btn {
|
|
@@ -208,65 +171,54 @@
|
|
| 208 |
border: none;
|
| 209 |
color: var(--primary-color);
|
| 210 |
cursor: pointer;
|
| 211 |
-
font-size: 1.2rem;
|
| 212 |
-
transition: var(--transition);
|
| 213 |
padding: 5px;
|
| 214 |
display: flex;
|
| 215 |
align-items: center;
|
| 216 |
-
justify-content: center;
|
| 217 |
-
}
|
| 218 |
-
|
| 219 |
-
.refresh-btn:hover {
|
| 220 |
-
transform: rotate(180deg);
|
| 221 |
}
|
| 222 |
|
| 223 |
.captcha-container input {
|
| 224 |
-
/* ورودی کپچا باید منعطف باشد */
|
| 225 |
flex-grow: 1;
|
| 226 |
-
min-width: 100px; /* حداقل عرض */
|
| 227 |
padding: 10px;
|
| 228 |
-
border-radius:
|
| 229 |
border: 1px solid var(--border-color);
|
| 230 |
background: var(--input-bg);
|
| 231 |
color: white;
|
| 232 |
text-align: center;
|
|
|
|
| 233 |
}
|
| 234 |
|
| 235 |
/* دکمه ارسال */
|
| 236 |
.submit-btn {
|
| 237 |
width: 100%;
|
| 238 |
-
padding:
|
| 239 |
background: var(--primary-color);
|
| 240 |
color: white;
|
| 241 |
border: none;
|
| 242 |
border-radius: var(--radius);
|
| 243 |
-
font-family: var(--font-
|
| 244 |
font-size: 1rem;
|
| 245 |
-
font-weight:
|
| 246 |
cursor: pointer;
|
| 247 |
-
transition:
|
| 248 |
display: flex;
|
| 249 |
justify-content: center;
|
| 250 |
align-items: center;
|
| 251 |
gap: 8px;
|
| 252 |
-
/* بهبود عملکرد کلیک در موبایل */
|
| 253 |
-
touch-action: manipulation;
|
| 254 |
}
|
| 255 |
|
| 256 |
.submit-btn:hover {
|
| 257 |
background: var(--primary-hover);
|
| 258 |
-
transform: translateY(-2px);
|
| 259 |
-
box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
|
| 260 |
}
|
| 261 |
|
| 262 |
-
.submit-btn:
|
| 263 |
-
|
|
|
|
| 264 |
}
|
| 265 |
|
| 266 |
-
/*
|
| 267 |
.switch-mode {
|
| 268 |
text-align: center;
|
| 269 |
-
margin-top:
|
| 270 |
font-size: 0.9rem;
|
| 271 |
color: var(--text-muted);
|
| 272 |
}
|
|
@@ -276,61 +228,42 @@
|
|
| 276 |
border: none;
|
| 277 |
color: var(--primary-color);
|
| 278 |
cursor: pointer;
|
| 279 |
-
font-family: var(--font-
|
| 280 |
-
font-weight:
|
| 281 |
padding: 0 5px;
|
| 282 |
-
transition: var(--transition);
|
| 283 |
-
}
|
| 284 |
-
|
| 285 |
-
.switch-mode button:hover {
|
| 286 |
-
text-decoration: underline;
|
| 287 |
}
|
| 288 |
|
| 289 |
/* کلاسهای کمکی */
|
| 290 |
.hidden {
|
| 291 |
-
display: none;
|
| 292 |
-
}
|
| 293 |
-
|
| 294 |
-
.fade-in {
|
| 295 |
-
animation: fadeIn 0.4s ease-in-out;
|
| 296 |
}
|
| 297 |
|
| 298 |
-
|
| 299 |
-
from { opacity: 0; transform: translateY(10px); }
|
| 300 |
-
to { opacity: 1; transform: translateY(0); }
|
| 301 |
-
}
|
| 302 |
-
|
| 303 |
-
/* اعلانها (Toast) - رسپانسیو */
|
| 304 |
.toast-container {
|
| 305 |
position: fixed;
|
| 306 |
bottom: 20px;
|
|
|
|
| 307 |
right: 20px;
|
| 308 |
-
left: 20px; /* جلوگیری از خروج از کادر در موبایل */
|
| 309 |
z-index: 1000;
|
| 310 |
display: flex;
|
| 311 |
flex-direction: column;
|
|
|
|
| 312 |
gap: 10px;
|
| 313 |
-
align-items: flex-end; /* راستچین */
|
| 314 |
-
pointer-events: none; /* کلیک روی فضای خالی مسدود نشود */
|
| 315 |
}
|
| 316 |
|
| 317 |
.toast {
|
| 318 |
background: var(--card-bg);
|
| 319 |
border-right: 4px solid var(--primary-color);
|
| 320 |
-
padding:
|
| 321 |
-
border-radius:
|
| 322 |
-
box-shadow: 0
|
| 323 |
color: var(--text-color);
|
| 324 |
font-size: 0.9rem;
|
| 325 |
display: flex;
|
| 326 |
align-items: center;
|
| 327 |
gap: 10px;
|
| 328 |
-
width:
|
| 329 |
-
max-width: 350px; /* محدودیت عرض */
|
| 330 |
animation: slideIn 0.3s ease;
|
| 331 |
-
backdrop-filter: blur(10px);
|
| 332 |
-
pointer-events: auto;
|
| 333 |
-
margin-bottom: 10px;
|
| 334 |
}
|
| 335 |
|
| 336 |
.toast.success { border-color: var(--success-color); }
|
|
@@ -341,65 +274,70 @@
|
|
| 341 |
to { transform: translateX(0); opacity: 1; }
|
| 342 |
}
|
| 343 |
|
| 344 |
-
/* تنظیمات خاص برای موبایلهای خیلی کوچک */
|
| 345 |
@media (max-width: 360px) {
|
| 346 |
-
.
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
}
|
| 351 |
</style>
|
| 352 |
</head>
|
| 353 |
|
| 354 |
<body>
|
| 355 |
|
| 356 |
-
<!-- لینک هدر الزامی -->
|
| 357 |
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="header-link">
|
| 358 |
Built with anycoder
|
| 359 |
</a>
|
| 360 |
|
| 361 |
<div class="container">
|
| 362 |
<!-- فرم ورود -->
|
| 363 |
-
<div id="login-form"
|
| 364 |
<div class="form-header">
|
| 365 |
<h2>خوش آمدید</h2>
|
| 366 |
-
<p>
|
| 367 |
</div>
|
| 368 |
|
| 369 |
<form onsubmit="handleLogin(event)">
|
| 370 |
<div class="input-group">
|
| 371 |
-
<label
|
| 372 |
<div class="input-wrapper">
|
| 373 |
-
<
|
| 374 |
-
<
|
|
|
|
| 375 |
</div>
|
| 376 |
</div>
|
| 377 |
|
| 378 |
<div class="input-group">
|
| 379 |
-
<label
|
| 380 |
<div class="input-wrapper">
|
| 381 |
-
<
|
| 382 |
-
<
|
| 383 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
| 384 |
</div>
|
| 385 |
</div>
|
| 386 |
|
| 387 |
<div class="captcha-container">
|
| 388 |
-
<canvas id="captchaCanvas" width="
|
| 389 |
<button type="button" class="refresh-btn" onclick="drawCaptcha()">
|
| 390 |
-
|
|
|
|
| 391 |
</button>
|
| 392 |
-
<input type="text" id="login-captcha" placeholder="کد
|
| 393 |
</div>
|
| 394 |
|
| 395 |
<button type="submit" class="submit-btn">
|
| 396 |
-
<span>ورود
|
| 397 |
-
<
|
|
|
|
| 398 |
</button>
|
| 399 |
|
| 400 |
<div class="switch-mode">
|
| 401 |
-
حساب
|
| 402 |
-
<button type="button" onclick="switchForm('register')">ثبت نام
|
| 403 |
</div>
|
| 404 |
</form>
|
| 405 |
</div>
|
|
@@ -407,247 +345,193 @@
|
|
| 407 |
<!-- فرم ثبت نام -->
|
| 408 |
<div id="register-form" class="hidden">
|
| 409 |
<div class="form-header">
|
| 410 |
-
<h2>
|
| 411 |
-
<p>ا
|
| 412 |
</div>
|
| 413 |
|
| 414 |
<form onsubmit="handleRegister(event)">
|
| 415 |
<div class="input-group">
|
| 416 |
-
<label
|
| 417 |
<div class="input-wrapper">
|
| 418 |
-
<
|
| 419 |
-
<input type="text" id="reg-username" placeholder="
|
| 420 |
</div>
|
| 421 |
</div>
|
| 422 |
|
| 423 |
<div class="input-group">
|
| 424 |
-
<label
|
| 425 |
<div class="input-wrapper">
|
| 426 |
-
<
|
| 427 |
-
<input type="password" id="reg-password" placeholder="رمز عبور
|
| 428 |
-
<
|
|
|
|
|
|
|
| 429 |
</div>
|
| 430 |
</div>
|
| 431 |
|
| 432 |
<div class="input-group">
|
| 433 |
-
<label
|
| 434 |
<div class="input-wrapper">
|
| 435 |
-
<
|
| 436 |
<input type="password" id="reg-confirm-password" placeholder="تکرار رمز عبور">
|
| 437 |
</div>
|
| 438 |
</div>
|
| 439 |
|
| 440 |
<div class="captcha-container">
|
| 441 |
-
<canvas id="captchaCanvasReg" width="
|
| 442 |
<button type="button" class="refresh-btn" onclick="drawCaptcha(true)">
|
| 443 |
-
|
| 444 |
</button>
|
| 445 |
-
<input type="text" id="reg-captcha" placeholder="کد
|
| 446 |
</div>
|
| 447 |
|
| 448 |
<button type="submit" class="submit-btn">
|
| 449 |
<span>ثبت نام</span>
|
| 450 |
-
<
|
| 451 |
</button>
|
| 452 |
|
| 453 |
<div class="switch-mode">
|
| 454 |
-
|
| 455 |
-
<button type="button" onclick="switchForm('login')">و
|
| 456 |
</div>
|
| 457 |
</form>
|
| 458 |
</div>
|
| 459 |
</div>
|
| 460 |
|
| 461 |
-
<!-- کانتینر پیامها -->
|
| 462 |
<div class="toast-container" id="toastContainer"></div>
|
| 463 |
|
| 464 |
<script>
|
| 465 |
-
// متغیرهای سراسری
|
| 466 |
let currentCaptcha = '';
|
| 467 |
let currentCaptchaReg = '';
|
| 468 |
|
| 469 |
window.onload = function() {
|
| 470 |
drawCaptcha();
|
| 471 |
drawCaptcha(true);
|
| 472 |
-
|
| 473 |
document.getElementById('captchaCanvas').addEventListener('click', () => drawCaptcha());
|
| 474 |
document.getElementById('captchaCanvasReg').addEventListener('click', () => drawCaptcha(true));
|
| 475 |
};
|
| 476 |
|
| 477 |
-
function switchForm(
|
| 478 |
-
const
|
| 479 |
-
const
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
registerForm.classList.remove('hidden');
|
| 486 |
-
registerForm.classList.add('fade-in');
|
| 487 |
-
drawCaptcha(true);
|
| 488 |
} else {
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
loginForm.classList.add('fade-in');
|
| 492 |
-
drawCaptcha();
|
| 493 |
}
|
| 494 |
}
|
| 495 |
|
| 496 |
-
function togglePassword(
|
| 497 |
-
const input = document.getElementById(
|
|
|
|
|
|
|
| 498 |
if (input.type === 'password') {
|
| 499 |
input.type = 'text';
|
| 500 |
-
icon
|
| 501 |
-
icon.
|
| 502 |
} else {
|
| 503 |
input.type = 'password';
|
| 504 |
-
|
| 505 |
-
icon.
|
| 506 |
}
|
| 507 |
}
|
| 508 |
|
| 509 |
-
function drawCaptcha(
|
| 510 |
-
const
|
| 511 |
-
const
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
ctx.clearRect(0, 0, width, height);
|
| 517 |
-
ctx.fillStyle = '#e2e8f0';
|
| 518 |
-
ctx.fillRect(0, 0, width, height);
|
| 519 |
|
| 520 |
-
const chars = '
|
| 521 |
-
let
|
| 522 |
-
for
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
if (isRegister) currentCaptchaReg = captchaText;
|
| 527 |
-
else currentCaptcha = captchaText;
|
| 528 |
-
|
| 529 |
-
// نویز
|
| 530 |
-
for (let i = 0; i < 7; i++) {
|
| 531 |
-
ctx.strokeStyle = `rgba(${Math.random()*255},${Math.random()*255},${Math.random()*255},0.5)`;
|
| 532 |
-
ctx.lineWidth = Math.random() * 2;
|
| 533 |
-
ctx.beginPath();
|
| 534 |
-
ctx.moveTo(Math.random() * width, Math.random() * height);
|
| 535 |
-
ctx.lineTo(Math.random() * width, Math.random() * height);
|
| 536 |
-
ctx.stroke();
|
| 537 |
-
}
|
| 538 |
|
| 539 |
-
|
| 540 |
-
ctx.font = 'bold 24px Vazirmatn';
|
| 541 |
ctx.textBaseline = 'middle';
|
| 542 |
-
|
| 543 |
-
for (let i = 0; i < captchaText.length; i++) {
|
| 544 |
ctx.save();
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
ctx.translate(x, y);
|
| 550 |
-
ctx.rotate(angle);
|
| 551 |
-
ctx.fillStyle = `rgb(${Math.random()*100},${Math.random()*100},${Math.random()*150})`;
|
| 552 |
-
ctx.fillText(captchaText[i], 0, 0);
|
| 553 |
ctx.restore();
|
| 554 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 555 |
}
|
| 556 |
|
| 557 |
function handleLogin(e) {
|
| 558 |
e.preventDefault();
|
| 559 |
-
const
|
| 560 |
-
const
|
| 561 |
-
const
|
| 562 |
|
| 563 |
-
if
|
| 564 |
-
|
| 565 |
-
return;
|
| 566 |
-
}
|
| 567 |
-
|
| 568 |
-
if (captchaInput !== currentCaptcha) {
|
| 569 |
-
showToast('کد امنیتی اشتباه است.', 'error');
|
| 570 |
-
drawCaptcha();
|
| 571 |
-
document.getElementById('login-captcha').value = '';
|
| 572 |
-
return;
|
| 573 |
-
}
|
| 574 |
|
| 575 |
const btn = e.target.querySelector('.submit-btn');
|
| 576 |
-
const originalText = btn.innerHTML;
|
| 577 |
-
btn.innerHTML = '<i class="ph ph-spinner ph-spin"></i> در حال پردازش...';
|
| 578 |
btn.disabled = true;
|
| 579 |
-
|
|
|
|
| 580 |
setTimeout(() => {
|
| 581 |
-
btn.innerHTML = originalText;
|
| 582 |
btn.disabled = false;
|
| 583 |
-
|
| 584 |
-
|
|
|
|
| 585 |
}
|
| 586 |
|
| 587 |
function handleRegister(e) {
|
| 588 |
e.preventDefault();
|
| 589 |
-
const
|
| 590 |
-
const
|
| 591 |
-
const
|
| 592 |
-
const
|
| 593 |
-
|
| 594 |
-
if (!username || !password || !confirmPassword) {
|
| 595 |
-
showToast('لطفاً تمام فیلدها را پر کنید.', 'error');
|
| 596 |
-
return;
|
| 597 |
-
}
|
| 598 |
|
| 599 |
-
if
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
if (password !== confirmPassword) {
|
| 605 |
-
showToast('رمز عبور و تکرار آن مطابقت ندارند.', 'error');
|
| 606 |
-
return;
|
| 607 |
-
}
|
| 608 |
-
|
| 609 |
-
if (captchaInput !== currentCaptchaReg) {
|
| 610 |
-
showToast('کد امنیتی اشتباه اس��.', 'error');
|
| 611 |
-
drawCaptcha(true);
|
| 612 |
-
document.getElementById('reg-captcha').value = '';
|
| 613 |
-
return;
|
| 614 |
-
}
|
| 615 |
|
| 616 |
const btn = e.target.querySelector('.submit-btn');
|
| 617 |
-
const originalText = btn.innerHTML;
|
| 618 |
-
btn.innerHTML = '<i class="ph ph-spinner ph-spin"></i> در حال ثبت...';
|
| 619 |
btn.disabled = true;
|
| 620 |
-
|
|
|
|
| 621 |
setTimeout(() => {
|
| 622 |
-
btn.innerHTML = originalText;
|
| 623 |
btn.disabled = false;
|
| 624 |
-
|
|
|
|
| 625 |
switchForm('login');
|
| 626 |
-
},
|
| 627 |
}
|
| 628 |
|
| 629 |
-
function showToast(
|
| 630 |
-
const
|
| 631 |
-
const
|
| 632 |
-
|
|
|
|
|
|
|
|
|
|
| 633 |
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
toast.innerHTML = `
|
| 637 |
-
<i class="ph ${iconClass}" style="font-size: 1.2rem;"></i>
|
| 638 |
-
<span>${message}</span>
|
| 639 |
-
`;
|
| 640 |
-
|
| 641 |
-
container.appendChild(toast);
|
| 642 |
-
|
| 643 |
setTimeout(() => {
|
| 644 |
-
|
| 645 |
-
setTimeout(() =>
|
| 646 |
-
toast.remove();
|
| 647 |
-
}, 300);
|
| 648 |
}, 3000);
|
| 649 |
}
|
| 650 |
</script>
|
| 651 |
</body>
|
| 652 |
-
|
| 653 |
</html>
|
|
|
|
| 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 |
<style>
|
| 10 |
+
/* تنظیمات پایه و متغیرها */
|
| 11 |
:root {
|
| 12 |
+
--bg-color: #1e293b;
|
| 13 |
+
--card-bg: #334155;
|
| 14 |
+
--input-bg: #0f172a;
|
| 15 |
--primary-color: #6366f1;
|
| 16 |
--primary-hover: #4f46e5;
|
| 17 |
+
--text-color: #f1f5f9;
|
| 18 |
--text-muted: #94a3b8;
|
| 19 |
+
--border-color: #475569;
|
| 20 |
--error-color: #ef4444;
|
| 21 |
--success-color: #22c55e;
|
| 22 |
+
--font-main: 'Tahoma', 'Segoe UI', sans-serif; /* فونت سیستم برای سرعت بالا */
|
| 23 |
+
--radius: 12px;
|
|
|
|
| 24 |
}
|
| 25 |
|
| 26 |
* {
|
| 27 |
box-sizing: border-box;
|
| 28 |
margin: 0;
|
| 29 |
padding: 0;
|
| 30 |
+
-webkit-tap-highlight-color: transparent;
|
|
|
|
| 31 |
}
|
| 32 |
|
| 33 |
body {
|
| 34 |
+
font-family: var(--font-main);
|
| 35 |
background-color: var(--bg-color);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
color: var(--text-color);
|
| 37 |
min-height: 100vh;
|
| 38 |
display: flex;
|
| 39 |
justify-content: center;
|
| 40 |
align-items: center;
|
| 41 |
+
padding: 20px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
}
|
| 43 |
|
| 44 |
/* لینک هدر */
|
| 45 |
.header-link {
|
| 46 |
position: fixed;
|
| 47 |
+
top: 15px;
|
| 48 |
+
left: 15px;
|
| 49 |
color: var(--text-muted);
|
| 50 |
text-decoration: none;
|
| 51 |
+
font-size: 0.8rem;
|
| 52 |
+
background: rgba(0, 0, 0, 0.2);
|
| 53 |
+
padding: 4px 8px;
|
| 54 |
+
border-radius: 4px;
|
| 55 |
z-index: 100;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
}
|
| 57 |
|
| 58 |
.header-link:hover {
|
| 59 |
color: var(--primary-color);
|
|
|
|
| 60 |
}
|
| 61 |
|
| 62 |
+
/* کانتینر اصلی */
|
| 63 |
.container {
|
| 64 |
width: 100%;
|
| 65 |
+
max-width: 400px;
|
| 66 |
background: var(--card-bg);
|
| 67 |
+
border: 1px solid var(--border-color);
|
| 68 |
+
border-radius: var(--radius);
|
| 69 |
+
padding: 30px 20px;
|
| 70 |
+
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
}
|
| 72 |
|
| 73 |
/* هدر فرم */
|
| 74 |
.form-header {
|
| 75 |
text-align: center;
|
| 76 |
+
margin-bottom: 25px;
|
| 77 |
}
|
| 78 |
|
| 79 |
.form-header h2 {
|
| 80 |
+
font-size: 1.5rem;
|
| 81 |
+
color: var(--text-color);
|
| 82 |
+
margin-bottom: 5px;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
}
|
| 84 |
|
| 85 |
.form-header p {
|
| 86 |
color: var(--text-muted);
|
| 87 |
+
font-size: 0.9rem;
|
| 88 |
}
|
| 89 |
|
| 90 |
/* ورودیها */
|
| 91 |
.input-group {
|
| 92 |
+
margin-bottom: 15px;
|
|
|
|
| 93 |
}
|
| 94 |
|
| 95 |
.input-group label {
|
| 96 |
display: block;
|
| 97 |
+
margin-bottom: 6px;
|
| 98 |
color: var(--text-muted);
|
| 99 |
+
font-size: 0.85rem;
|
|
|
|
| 100 |
}
|
| 101 |
|
| 102 |
.input-wrapper {
|
|
|
|
| 105 |
align-items: center;
|
| 106 |
}
|
| 107 |
|
| 108 |
+
/* آیکونهای SVG داخلی */
|
| 109 |
+
.icon {
|
| 110 |
+
width: 20px;
|
| 111 |
+
height: 20px;
|
| 112 |
+
fill: currentColor;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
.icon-left {
|
| 116 |
position: absolute;
|
| 117 |
+
right: 12px;
|
| 118 |
color: var(--text-muted);
|
|
|
|
| 119 |
pointer-events: none;
|
| 120 |
}
|
| 121 |
|
| 122 |
.input-wrapper input {
|
| 123 |
width: 100%;
|
| 124 |
+
padding: 12px 40px 12px 12px;
|
|
|
|
| 125 |
background: var(--input-bg);
|
| 126 |
border: 1px solid var(--border-color);
|
| 127 |
border-radius: var(--radius);
|
| 128 |
color: var(--text-color);
|
| 129 |
+
font-family: var(--font-main);
|
| 130 |
+
font-size: 0.95rem;
|
|
|
|
| 131 |
}
|
| 132 |
|
| 133 |
.input-wrapper input:focus {
|
| 134 |
border-color: var(--primary-color);
|
| 135 |
+
outline: none;
|
| 136 |
}
|
| 137 |
|
| 138 |
.toggle-password {
|
| 139 |
position: absolute;
|
| 140 |
+
left: 12px;
|
| 141 |
cursor: pointer;
|
| 142 |
color: var(--text-muted);
|
| 143 |
+
background: none;
|
| 144 |
+
border: none;
|
| 145 |
+
padding: 0;
|
| 146 |
+
display: flex;
|
| 147 |
+
align-items: center;
|
| 148 |
}
|
| 149 |
|
| 150 |
.toggle-password:hover {
|
| 151 |
color: var(--text-color);
|
| 152 |
}
|
| 153 |
|
| 154 |
+
/* کپچا */
|
| 155 |
.captcha-container {
|
| 156 |
display: flex;
|
| 157 |
align-items: center;
|
| 158 |
+
gap: 8px;
|
| 159 |
+
margin-bottom: 20px;
|
| 160 |
+
flex-wrap: wrap;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
}
|
| 162 |
|
| 163 |
+
canvas {
|
| 164 |
+
background: #fff;
|
| 165 |
+
border-radius: 6px;
|
| 166 |
cursor: pointer;
|
|
|
|
| 167 |
}
|
| 168 |
|
| 169 |
.refresh-btn {
|
|
|
|
| 171 |
border: none;
|
| 172 |
color: var(--primary-color);
|
| 173 |
cursor: pointer;
|
|
|
|
|
|
|
| 174 |
padding: 5px;
|
| 175 |
display: flex;
|
| 176 |
align-items: center;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
}
|
| 178 |
|
| 179 |
.captcha-container input {
|
|
|
|
| 180 |
flex-grow: 1;
|
|
|
|
| 181 |
padding: 10px;
|
| 182 |
+
border-radius: 6px;
|
| 183 |
border: 1px solid var(--border-color);
|
| 184 |
background: var(--input-bg);
|
| 185 |
color: white;
|
| 186 |
text-align: center;
|
| 187 |
+
min-width: 80px;
|
| 188 |
}
|
| 189 |
|
| 190 |
/* دکمه ارسال */
|
| 191 |
.submit-btn {
|
| 192 |
width: 100%;
|
| 193 |
+
padding: 12px;
|
| 194 |
background: var(--primary-color);
|
| 195 |
color: white;
|
| 196 |
border: none;
|
| 197 |
border-radius: var(--radius);
|
| 198 |
+
font-family: var(--font-main);
|
| 199 |
font-size: 1rem;
|
| 200 |
+
font-weight: bold;
|
| 201 |
cursor: pointer;
|
| 202 |
+
transition: background 0.2s;
|
| 203 |
display: flex;
|
| 204 |
justify-content: center;
|
| 205 |
align-items: center;
|
| 206 |
gap: 8px;
|
|
|
|
|
|
|
| 207 |
}
|
| 208 |
|
| 209 |
.submit-btn:hover {
|
| 210 |
background: var(--primary-hover);
|
|
|
|
|
|
|
| 211 |
}
|
| 212 |
|
| 213 |
+
.submit-btn:disabled {
|
| 214 |
+
opacity: 0.7;
|
| 215 |
+
cursor: not-allowed;
|
| 216 |
}
|
| 217 |
|
| 218 |
+
/* تغییر حالت */
|
| 219 |
.switch-mode {
|
| 220 |
text-align: center;
|
| 221 |
+
margin-top: 15px;
|
| 222 |
font-size: 0.9rem;
|
| 223 |
color: var(--text-muted);
|
| 224 |
}
|
|
|
|
| 228 |
border: none;
|
| 229 |
color: var(--primary-color);
|
| 230 |
cursor: pointer;
|
| 231 |
+
font-family: var(--font-main);
|
| 232 |
+
font-weight: bold;
|
| 233 |
padding: 0 5px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
}
|
| 235 |
|
| 236 |
/* کلاسهای کمکی */
|
| 237 |
.hidden {
|
| 238 |
+
display: none !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
}
|
| 240 |
|
| 241 |
+
/* Toast (پیامها) */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
.toast-container {
|
| 243 |
position: fixed;
|
| 244 |
bottom: 20px;
|
| 245 |
+
left: 20px;
|
| 246 |
right: 20px;
|
|
|
|
| 247 |
z-index: 1000;
|
| 248 |
display: flex;
|
| 249 |
flex-direction: column;
|
| 250 |
+
align-items: flex-end;
|
| 251 |
gap: 10px;
|
|
|
|
|
|
|
| 252 |
}
|
| 253 |
|
| 254 |
.toast {
|
| 255 |
background: var(--card-bg);
|
| 256 |
border-right: 4px solid var(--primary-color);
|
| 257 |
+
padding: 12px 15px;
|
| 258 |
+
border-radius: 4px;
|
| 259 |
+
box-shadow: 0 4px 6px rgba(0,0,0,0.3);
|
| 260 |
color: var(--text-color);
|
| 261 |
font-size: 0.9rem;
|
| 262 |
display: flex;
|
| 263 |
align-items: center;
|
| 264 |
gap: 10px;
|
| 265 |
+
max-width: 300px;
|
|
|
|
| 266 |
animation: slideIn 0.3s ease;
|
|
|
|
|
|
|
|
|
|
| 267 |
}
|
| 268 |
|
| 269 |
.toast.success { border-color: var(--success-color); }
|
|
|
|
| 274 |
to { transform: translateX(0); opacity: 1; }
|
| 275 |
}
|
| 276 |
|
|
|
|
| 277 |
@media (max-width: 360px) {
|
| 278 |
+
.captcha-container input {
|
| 279 |
+
width: 100%;
|
| 280 |
+
flex-basis: 100%;
|
| 281 |
+
}
|
| 282 |
}
|
| 283 |
</style>
|
| 284 |
</head>
|
| 285 |
|
| 286 |
<body>
|
| 287 |
|
|
|
|
| 288 |
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="header-link">
|
| 289 |
Built with anycoder
|
| 290 |
</a>
|
| 291 |
|
| 292 |
<div class="container">
|
| 293 |
<!-- فرم ورود -->
|
| 294 |
+
<div id="login-form">
|
| 295 |
<div class="form-header">
|
| 296 |
<h2>خوش آمدید</h2>
|
| 297 |
+
<p>وارد حساب کاربری شوید</p>
|
| 298 |
</div>
|
| 299 |
|
| 300 |
<form onsubmit="handleLogin(event)">
|
| 301 |
<div class="input-group">
|
| 302 |
+
<label>نام کاربری</label>
|
| 303 |
<div class="input-wrapper">
|
| 304 |
+
<!-- SVG Icon: User -->
|
| 305 |
+
<svg class="icon icon-left" viewBox="0 0 24 24"><path 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"/></svg>
|
| 306 |
+
<input type="text" id="login-username" placeholder="نام کاربری" autocomplete="off">
|
| 307 |
</div>
|
| 308 |
</div>
|
| 309 |
|
| 310 |
<div class="input-group">
|
| 311 |
+
<label>رمز عبور</label>
|
| 312 |
<div class="input-wrapper">
|
| 313 |
+
<!-- SVG Icon: Lock -->
|
| 314 |
+
<svg class="icon icon-left" viewBox="0 0 24 24"><path 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"/></svg>
|
| 315 |
+
<input type="password" id="login-password" placeholder="رمز عبور">
|
| 316 |
+
<button type="button" class="toggle-password" onclick="togglePassword('login-password', this)">
|
| 317 |
+
<!-- SVG Icon: Eye Slash -->
|
| 318 |
+
<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>
|
| 319 |
+
</button>
|
| 320 |
</div>
|
| 321 |
</div>
|
| 322 |
|
| 323 |
<div class="captcha-container">
|
| 324 |
+
<canvas id="captchaCanvas" width="100" height="40" title="تغییر کد"></canvas>
|
| 325 |
<button type="button" class="refresh-btn" onclick="drawCaptcha()">
|
| 326 |
+
<!-- SVG Icon: Refresh -->
|
| 327 |
+
<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>
|
| 328 |
</button>
|
| 329 |
+
<input type="text" id="login-captcha" placeholder="کد">
|
| 330 |
</div>
|
| 331 |
|
| 332 |
<button type="submit" class="submit-btn">
|
| 333 |
+
<span>ورود</span>
|
| 334 |
+
<!-- SVG Icon: Sign In -->
|
| 335 |
+
<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>
|
| 336 |
</button>
|
| 337 |
|
| 338 |
<div class="switch-mode">
|
| 339 |
+
حساب ندارید؟
|
| 340 |
+
<button type="button" onclick="switchForm('register')">ثبت نام</button>
|
| 341 |
</div>
|
| 342 |
</form>
|
| 343 |
</div>
|
|
|
|
| 345 |
<!-- فرم ثبت نام -->
|
| 346 |
<div id="register-form" class="hidden">
|
| 347 |
<div class="form-header">
|
| 348 |
+
<h2>ثبت نام</h2>
|
| 349 |
+
<p>ایجاد حساب جدید</p>
|
| 350 |
</div>
|
| 351 |
|
| 352 |
<form onsubmit="handleRegister(event)">
|
| 353 |
<div class="input-group">
|
| 354 |
+
<label>نام کاربری</label>
|
| 355 |
<div class="input-wrapper">
|
| 356 |
+
<svg class="icon icon-left" viewBox="0 0 24 24"><path 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"/></svg>
|
| 357 |
+
<input type="text" id="reg-username" placeholder="نام کاربری" autocomplete="off">
|
| 358 |
</div>
|
| 359 |
</div>
|
| 360 |
|
| 361 |
<div class="input-group">
|
| 362 |
+
<label>رمز عبور</label>
|
| 363 |
<div class="input-wrapper">
|
| 364 |
+
<svg class="icon icon-left" viewBox="0 0 24 24"><path 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"/></svg>
|
| 365 |
+
<input type="password" id="reg-password" placeholder="رمز عبور">
|
| 366 |
+
<button type="button" class="toggle-password" onclick="togglePassword('reg-password', this)">
|
| 367 |
+
<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>
|
| 368 |
+
</button>
|
| 369 |
</div>
|
| 370 |
</div>
|
| 371 |
|
| 372 |
<div class="input-group">
|
| 373 |
+
<label>تکرار رمز</label>
|
| 374 |
<div class="input-wrapper">
|
| 375 |
+
<svg class="icon icon-left" viewBox="0 0 24 24"><path 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"/></svg>
|
| 376 |
<input type="password" id="reg-confirm-password" placeholder="تکرار رمز عبور">
|
| 377 |
</div>
|
| 378 |
</div>
|
| 379 |
|
| 380 |
<div class="captcha-container">
|
| 381 |
+
<canvas id="captchaCanvasReg" width="100" height="40" title="تغییر کد"></canvas>
|
| 382 |
<button type="button" class="refresh-btn" onclick="drawCaptcha(true)">
|
| 383 |
+
<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>
|
| 384 |
</button>
|
| 385 |
+
<input type="text" id="reg-captcha" placeholder="کد">
|
| 386 |
</div>
|
| 387 |
|
| 388 |
<button type="submit" class="submit-btn">
|
| 389 |
<span>ثبت نام</span>
|
| 390 |
+
<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>
|
| 391 |
</button>
|
| 392 |
|
| 393 |
<div class="switch-mode">
|
| 394 |
+
حساب دارید؟
|
| 395 |
+
<button type="button" onclick="switchForm('login')">ورود</button>
|
| 396 |
</div>
|
| 397 |
</form>
|
| 398 |
</div>
|
| 399 |
</div>
|
| 400 |
|
|
|
|
| 401 |
<div class="toast-container" id="toastContainer"></div>
|
| 402 |
|
| 403 |
<script>
|
|
|
|
| 404 |
let currentCaptcha = '';
|
| 405 |
let currentCaptchaReg = '';
|
| 406 |
|
| 407 |
window.onload = function() {
|
| 408 |
drawCaptcha();
|
| 409 |
drawCaptcha(true);
|
|
|
|
| 410 |
document.getElementById('captchaCanvas').addEventListener('click', () => drawCaptcha());
|
| 411 |
document.getElementById('captchaCanvasReg').addEventListener('click', () => drawCaptcha(true));
|
| 412 |
};
|
| 413 |
|
| 414 |
+
function switchForm(type) {
|
| 415 |
+
const login = document.getElementById('login-form');
|
| 416 |
+
const reg = document.getElementById('register-form');
|
| 417 |
+
document.querySelectorAll('input').forEach(i => i.value = '');
|
| 418 |
+
|
| 419 |
+
if (type === 'register') {
|
| 420 |
+
login.classList.add('hidden');
|
| 421 |
+
reg.classList.remove('hidden');
|
|
|
|
|
|
|
|
|
|
| 422 |
} else {
|
| 423 |
+
reg.classList.add('hidden');
|
| 424 |
+
login.classList.remove('hidden');
|
|
|
|
|
|
|
| 425 |
}
|
| 426 |
}
|
| 427 |
|
| 428 |
+
function togglePassword(id, btn) {
|
| 429 |
+
const input = document.getElementById(id);
|
| 430 |
+
const isEyeSlash = btn.innerHTML.includes('M12 7c2.76'); // Check path content roughly
|
| 431 |
+
|
| 432 |
if (input.type === 'password') {
|
| 433 |
input.type = 'text';
|
| 434 |
+
// Change to Eye Open icon (simple path)
|
| 435 |
+
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>';
|
| 436 |
} else {
|
| 437 |
input.type = 'password';
|
| 438 |
+
// Change back to Eye Slash
|
| 439 |
+
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>';
|
| 440 |
}
|
| 441 |
}
|
| 442 |
|
| 443 |
+
function drawCaptcha(isReg = false) {
|
| 444 |
+
const cvs = document.getElementById(isReg ? 'captchaCanvasReg' : 'captchaCanvas');
|
| 445 |
+
const ctx = cvs.getContext('2d');
|
| 446 |
+
ctx.clearRect(0, 0, cvs.width, cvs.height);
|
| 447 |
+
ctx.fillStyle = '#cbd5e1';
|
| 448 |
+
ctx.fillRect(0, 0, cvs.width, cvs.height);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 449 |
|
| 450 |
+
const chars = '0123456789ABCDEFGHJKLMNPQRSTUVWXYZ';
|
| 451 |
+
let txt = '';
|
| 452 |
+
for(let i=0; i<5; i++) txt += chars[Math.floor(Math.random()*chars.length)];
|
| 453 |
+
|
| 454 |
+
if(isReg) currentCaptchaReg = txt; else currentCaptcha = txt;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 455 |
|
| 456 |
+
ctx.font = 'bold 24px monospace';
|
|
|
|
| 457 |
ctx.textBaseline = 'middle';
|
| 458 |
+
for(let i=0; i<5; i++) {
|
|
|
|
| 459 |
ctx.save();
|
| 460 |
+
ctx.translate(15 + i*16, 20);
|
| 461 |
+
ctx.rotate((Math.random()-0.5)*0.4);
|
| 462 |
+
ctx.fillStyle = '#1e293b';
|
| 463 |
+
ctx.fillText(txt[i], 0, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 464 |
ctx.restore();
|
| 465 |
}
|
| 466 |
+
// Noise
|
| 467 |
+
for(let i=0; i<5; i++) {
|
| 468 |
+
ctx.strokeStyle = '#94a3b8';
|
| 469 |
+
ctx.beginPath();
|
| 470 |
+
ctx.moveTo(Math.random()*100, Math.random()*40);
|
| 471 |
+
ctx.lineTo(Math.random()*100, Math.random()*40);
|
| 472 |
+
ctx.stroke();
|
| 473 |
+
}
|
| 474 |
}
|
| 475 |
|
| 476 |
function handleLogin(e) {
|
| 477 |
e.preventDefault();
|
| 478 |
+
const u = document.getElementById('login-username').value;
|
| 479 |
+
const p = document.getElementById('login-password').value;
|
| 480 |
+
const c = document.getElementById('login-captcha').value;
|
| 481 |
|
| 482 |
+
if(!u || !p) return showToast('فیلدها الزامی است', 'error');
|
| 483 |
+
if(c !== currentCaptcha) return showToast('کد اشتباه است', 'error');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 484 |
|
| 485 |
const btn = e.target.querySelector('.submit-btn');
|
|
|
|
|
|
|
| 486 |
btn.disabled = true;
|
| 487 |
+
btn.innerHTML = 'در حال پردازش...';
|
| 488 |
+
|
| 489 |
setTimeout(() => {
|
|
|
|
| 490 |
btn.disabled = false;
|
| 491 |
+
btn.innerHTML = '<span>ورود</span><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>';
|
| 492 |
+
showToast('خوش آمدید!', 'success');
|
| 493 |
+
}, 1000);
|
| 494 |
}
|
| 495 |
|
| 496 |
function handleRegister(e) {
|
| 497 |
e.preventDefault();
|
| 498 |
+
const u = document.getElementById('reg-username').value;
|
| 499 |
+
const p = document.getElementById('reg-password').value;
|
| 500 |
+
const cp = document.getElementById('reg-confirm-password').value;
|
| 501 |
+
const c = document.getElementById('reg-captcha').value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 502 |
|
| 503 |
+
if(!u || !p || !cp) return showToast('فیلدها الزامی است', 'error');
|
| 504 |
+
if(p.length < 6) return showToast('رمز کوتاه است', 'error');
|
| 505 |
+
if(p !== cp) return showToast('تکرار مغایرت دارد', 'error');
|
| 506 |
+
if(c !== currentCaptchaReg) return showToast('کد اشتباه است', 'error');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 507 |
|
| 508 |
const btn = e.target.querySelector('.submit-btn');
|
|
|
|
|
|
|
| 509 |
btn.disabled = true;
|
| 510 |
+
btn.innerHTML = 'در حال ثبت...';
|
| 511 |
+
|
| 512 |
setTimeout(() => {
|
|
|
|
| 513 |
btn.disabled = false;
|
| 514 |
+
btn.innerHTML = '<span>ثبت نام</span><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>';
|
| 515 |
+
showToast('ثبت نام موفق!', 'success');
|
| 516 |
switchForm('login');
|
| 517 |
+
}, 1000);
|
| 518 |
}
|
| 519 |
|
| 520 |
+
function showToast(msg, type) {
|
| 521 |
+
const con = document.getElementById('toastContainer');
|
| 522 |
+
const t = document.createElement('div');
|
| 523 |
+
t.className = `toast ${type}`;
|
| 524 |
+
const icon = type === 'success'
|
| 525 |
+
? '<svg class="icon" style="fill:#22c55e" viewBox="0 0 24 24"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/></svg>'
|
| 526 |
+
: '<svg class="icon" style="fill:#ef4444" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"/></svg>';
|
| 527 |
|
| 528 |
+
t.innerHTML = `${icon}<span>${msg}</span>`;
|
| 529 |
+
con.appendChild(t);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 530 |
setTimeout(() => {
|
| 531 |
+
t.style.opacity = '0';
|
| 532 |
+
setTimeout(() => t.remove(), 300);
|
|
|
|
|
|
|
| 533 |
}, 3000);
|
| 534 |
}
|
| 535 |
</script>
|
| 536 |
</body>
|
|
|
|
| 537 |
</html>
|