Update index.html
Browse files- index.html +544 -680
index.html
CHANGED
|
@@ -1,705 +1,569 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="fa" dir="rtl">
|
| 3 |
<head>
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
left: -100%;
|
| 284 |
-
width: 100%;
|
| 285 |
-
height: 100%;
|
| 286 |
-
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
|
| 287 |
-
transition: left 0.5s;
|
| 288 |
-
}
|
| 289 |
-
|
| 290 |
-
.btn:hover::before {
|
| 291 |
-
left: 100%;
|
| 292 |
-
}
|
| 293 |
-
|
| 294 |
-
.btn-generate {
|
| 295 |
-
background: var(--primary-gradient);
|
| 296 |
-
box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
|
| 297 |
-
}
|
| 298 |
-
|
| 299 |
-
.btn-read {
|
| 300 |
-
background: var(--secondary-gradient);
|
| 301 |
-
box-shadow: 0 8px 20px rgba(245, 87, 108, 0.4);
|
| 302 |
-
}
|
| 303 |
-
|
| 304 |
-
.btn:hover:not(:disabled) {
|
| 305 |
-
transform: translateY(-3px);
|
| 306 |
-
box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
|
| 307 |
-
}
|
| 308 |
-
|
| 309 |
-
.btn:disabled {
|
| 310 |
-
opacity: 0.6;
|
| 311 |
-
cursor: not-allowed;
|
| 312 |
-
transform: none !important;
|
| 313 |
-
}
|
| 314 |
-
|
| 315 |
-
.result-container {
|
| 316 |
-
margin-top: 20px;
|
| 317 |
-
padding: 20px;
|
| 318 |
-
background: rgba(255, 255, 255, 0.05);
|
| 319 |
-
border-radius: 12px;
|
| 320 |
-
border: 1px solid var(--border-color);
|
| 321 |
-
min-height: 120px;
|
| 322 |
-
display: flex;
|
| 323 |
-
align-items: center;
|
| 324 |
-
justify-content: center;
|
| 325 |
-
text-align: center;
|
| 326 |
-
position: relative;
|
| 327 |
-
overflow: hidden;
|
| 328 |
-
}
|
| 329 |
-
|
| 330 |
-
.loader {
|
| 331 |
-
width: 40px;
|
| 332 |
-
height: 40px;
|
| 333 |
-
border: 4px solid rgba(255, 255, 255, 0.1);
|
| 334 |
-
border-top: 4px solid #667eea;
|
| 335 |
-
border-radius: 50%;
|
| 336 |
-
animation: spin 1s linear infinite;
|
| 337 |
-
display: none;
|
| 338 |
-
}
|
| 339 |
-
|
| 340 |
-
@keyframes spin {
|
| 341 |
-
0% { transform: rotate(0deg); }
|
| 342 |
-
100% { transform: rotate(360deg); }
|
| 343 |
-
}
|
| 344 |
-
|
| 345 |
-
.qr-result img {
|
| 346 |
-
max-width: 100%;
|
| 347 |
-
height: auto;
|
| 348 |
-
border-radius: 8px;
|
| 349 |
-
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
|
| 350 |
-
animation: zoomIn 0.5s ease-out;
|
| 351 |
-
}
|
| 352 |
-
|
| 353 |
-
@keyframes zoomIn {
|
| 354 |
-
from {
|
| 355 |
-
opacity: 0;
|
| 356 |
-
transform: scale(0.8);
|
| 357 |
-
}
|
| 358 |
-
to {
|
| 359 |
-
opacity: 1;
|
| 360 |
-
transform: scale(1);
|
| 361 |
-
}
|
| 362 |
-
}
|
| 363 |
-
|
| 364 |
-
.text-result {
|
| 365 |
-
word-wrap: break-word;
|
| 366 |
-
line-height: 1.6;
|
| 367 |
-
font-size: 1rem;
|
| 368 |
-
}
|
| 369 |
-
|
| 370 |
-
/* انیمیشنهای ورود */
|
| 371 |
-
@keyframes slideDown {
|
| 372 |
-
from {
|
| 373 |
-
opacity: 0;
|
| 374 |
-
transform: translateY(-50px);
|
| 375 |
-
}
|
| 376 |
-
to {
|
| 377 |
-
opacity: 1;
|
| 378 |
-
transform: translateY(0);
|
| 379 |
-
}
|
| 380 |
-
}
|
| 381 |
-
|
| 382 |
-
@keyframes slideUp {
|
| 383 |
-
from {
|
| 384 |
-
opacity: 0;
|
| 385 |
-
transform: translateY(50px);
|
| 386 |
-
}
|
| 387 |
-
to {
|
| 388 |
-
opacity: 1;
|
| 389 |
-
transform: translateY(0);
|
| 390 |
-
}
|
| 391 |
-
}
|
| 392 |
-
|
| 393 |
-
/* Responsive Design */
|
| 394 |
-
@media (max-width: 768px) {
|
| 395 |
-
.app-container {
|
| 396 |
-
flex-direction: column;
|
| 397 |
-
gap: 20px;
|
| 398 |
-
}
|
| 399 |
-
|
| 400 |
-
.card {
|
| 401 |
-
min-width: 100%;
|
| 402 |
-
padding: 25px;
|
| 403 |
-
}
|
| 404 |
-
|
| 405 |
-
body {
|
| 406 |
-
padding: 15px;
|
| 407 |
-
}
|
| 408 |
-
}
|
| 409 |
-
|
| 410 |
-
@media (max-width: 480px) {
|
| 411 |
-
.main-title {
|
| 412 |
-
font-size: 2rem;
|
| 413 |
-
}
|
| 414 |
-
|
| 415 |
-
.card {
|
| 416 |
-
padding: 20px;
|
| 417 |
-
}
|
| 418 |
-
}
|
| 419 |
-
</style>
|
| 420 |
</head>
|
| 421 |
<body>
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
|
|
|
| 425 |
</header>
|
| 426 |
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
| 433 |
-
<rect x="3" y="3" width="7" height="7"/>
|
| 434 |
-
<rect x="14" y="3" width="7" height="7"/>
|
| 435 |
-
<rect x="14" y="14" width="7" height="7"/>
|
| 436 |
-
<rect x="3" y="14" width="7" height="7"/>
|
| 437 |
-
</svg>
|
| 438 |
-
</div>
|
| 439 |
-
<h2 class="card-title">ساخت QR Code</h2>
|
| 440 |
-
<p class="card-subtitle">متن خود را به کد QR تبدیل کنید</p>
|
| 441 |
-
</div>
|
| 442 |
-
|
| 443 |
-
<div class="form-group">
|
| 444 |
-
<label class="form-label" for="text-input">متن یا لینک خود را وارد کنید:</label>
|
| 445 |
-
<textarea id="text-input" class="form-input" rows="4" placeholder="مثال: https://google.com یا سلام دنیا">سلام دنیا</textarea>
|
| 446 |
-
</div>
|
| 447 |
-
|
| 448 |
-
<button id="generate-btn" class="btn btn-generate">
|
| 449 |
-
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
| 450 |
-
<path d="M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2v0z"/>
|
| 451 |
-
<path d="M12 8l4 4-4 4"/>
|
| 452 |
-
<path d="M8 12h7"/>
|
| 453 |
-
</svg>
|
| 454 |
-
<span>ساخت QR Code</span>
|
| 455 |
-
</button>
|
| 456 |
-
|
| 457 |
-
<div class="result-container">
|
| 458 |
-
<div id="generate-loader" class="loader"></div>
|
| 459 |
-
<div id="qr-code-display" class="qr-result"></div>
|
| 460 |
-
</div>
|
| 461 |
-
</div>
|
| 462 |
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
<
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
</svg>
|
| 486 |
-
<span>انتخاب تصویر</span>
|
| 487 |
-
</label>
|
| 488 |
-
</div>
|
| 489 |
-
<p id="file-name" class="file-name"></p>
|
| 490 |
-
</div>
|
| 491 |
-
|
| 492 |
-
<button id="read-btn" class="btn btn-read">
|
| 493 |
-
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
| 494 |
-
<circle cx="11" cy="11" r="8"/>
|
| 495 |
-
<path d="m21 21-4.35-4.35"/>
|
| 496 |
-
</svg>
|
| 497 |
-
<span>خواندن QR Code</span>
|
| 498 |
-
</button>
|
| 499 |
-
|
| 500 |
-
<div class="result-container">
|
| 501 |
-
<div id="read-loader" class="loader"></div>
|
| 502 |
-
<p id="decoded-text" class="text-result">نتیجه در اینجا نمایش داده میشود</p>
|
| 503 |
-
</div>
|
| 504 |
</div>
|
| 505 |
-
</div>
|
| 506 |
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
const decodedText = document.getElementById('decoded-text');
|
| 517 |
-
const generateLoader = document.getElementById('generate-loader');
|
| 518 |
-
const readLoader = document.getElementById('read-loader');
|
| 519 |
-
const fileNameDisplay = document.getElementById('file-name');
|
| 520 |
-
|
| 521 |
-
// نمایش نام فایل انتخاب شده
|
| 522 |
-
fileInput.addEventListener('change', () => {
|
| 523 |
-
if (fileInput.files.length > 0) {
|
| 524 |
-
fileNameDisplay.textContent = `فایل انتخاب شده: ${fileInput.files[0].name}`;
|
| 525 |
-
fileNameDisplay.style.color = '#4ade80';
|
| 526 |
-
} else {
|
| 527 |
-
fileNameDisplay.textContent = '';
|
| 528 |
-
}
|
| 529 |
-
});
|
| 530 |
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 560 |
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
|
|
|
|
|
|
| 568 |
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 603 |
});
|
| 604 |
|
| 605 |
-
|
| 606 |
-
readBtn.addEventListener('click', async () => {
|
| 607 |
-
const file = fileInput.files[0];
|
| 608 |
-
if (!file) {
|
| 609 |
-
fileInput.click();
|
| 610 |
-
return;
|
| 611 |
-
}
|
| 612 |
|
| 613 |
-
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
| 620 |
-
|
| 621 |
-
const uploadResponse = await fetch(`${SPACE_URL}/gradio_api/upload`, {
|
| 622 |
-
method: 'POST',
|
| 623 |
-
body: formData
|
| 624 |
-
});
|
| 625 |
-
if (!uploadResponse.ok) throw new Error(`خطا در آپلود فایل: ${uploadResponse.statusText}`);
|
| 626 |
-
|
| 627 |
-
const uploadResult = await uploadResponse.json();
|
| 628 |
-
const serverFilePath = uploadResult[0];
|
| 629 |
-
|
| 630 |
-
const fileDataObject = {
|
| 631 |
-
path: serverFilePath,
|
| 632 |
-
url: `${SPACE_URL}/gradio_api/file=${serverFilePath}`,
|
| 633 |
-
orig_name: file.name,
|
| 634 |
-
};
|
| 635 |
-
|
| 636 |
-
const sessionHash = generateSessionHash();
|
| 637 |
-
const joinResponse = await fetch(`${SPACE_URL}/gradio_api/queue/join`, {
|
| 638 |
-
method: 'POST',
|
| 639 |
-
headers: { 'Content-Type': 'application/json' },
|
| 640 |
-
body: JSON.stringify({ fn_index: 1, data: [fileDataObject], session_hash: sessionHash })
|
| 641 |
-
});
|
| 642 |
-
if (!joinResponse.ok) throw new Error(`خطا در ارسال به صف: ${joinResponse.statusText}`);
|
| 643 |
-
|
| 644 |
-
listenForData(
|
| 645 |
-
sessionHash,
|
| 646 |
-
(result) => {
|
| 647 |
-
decodedText.innerHTML = `<strong style="color: #4ade80;">متن خوانده شده:</strong><br><br>${result[0]}`;
|
| 648 |
-
},
|
| 649 |
-
(error) => {
|
| 650 |
-
decodedText.innerHTML = `<p style="color: #ef4444;">خطا در خواندن: ${error}</p>`;
|
| 651 |
-
}
|
| 652 |
-
);
|
| 653 |
-
} catch (error) {
|
| 654 |
-
decodedText.innerHTML = `<p style="color: #ef4444;">خطا: ${error.message}</p>`;
|
| 655 |
-
} finally {
|
| 656 |
-
readLoader.style.display = 'none';
|
| 657 |
-
readBtn.disabled = false;
|
| 658 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 659 |
});
|
|
|
|
| 660 |
|
| 661 |
-
|
| 662 |
-
const
|
| 663 |
-
|
| 664 |
-
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
|
| 665 |
-
fileLabel.addEventListener(eventName, preventDefaults, false);
|
| 666 |
-
});
|
| 667 |
|
| 668 |
-
|
| 669 |
-
|
| 670 |
-
|
| 671 |
-
|
|
|
|
| 672 |
|
| 673 |
-
|
| 674 |
-
|
|
|
|
|
|
|
|
|
|
| 675 |
});
|
| 676 |
-
|
| 677 |
-
|
| 678 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 679 |
});
|
| 680 |
-
|
| 681 |
-
|
| 682 |
-
|
| 683 |
-
|
| 684 |
-
}
|
| 685 |
-
|
| 686 |
-
function unhighlight(e) {
|
| 687 |
-
fileLabel.style.borderColor = 'rgba(255, 255, 255, 0.3)';
|
| 688 |
-
fileLabel.style.backgroundColor = 'rgba(255, 255, 255, 0.05)';
|
| 689 |
-
}
|
| 690 |
-
|
| 691 |
-
fileLabel.addEventListener('drop', handleDrop, false);
|
| 692 |
-
|
| 693 |
-
function handleDrop(e) {
|
| 694 |
-
const dt = e.dataTransfer;
|
| 695 |
-
const files = dt.files;
|
| 696 |
-
|
| 697 |
-
if (files.length > 0) {
|
| 698 |
-
fileInput.files = files;
|
| 699 |
-
fileNameDisplay.textContent = `فایل انتخاب شده: ${files[0].name}`;
|
| 700 |
-
fileNameDisplay.style.color = '#4ade80';
|
| 701 |
-
}
|
| 702 |
-
}
|
| 703 |
-
</script>
|
| 704 |
</body>
|
| 705 |
</html>
|
|
|
|
| 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" />
|
| 6 |
+
<title>استودیوی QR | ساخت و خواندن QR Code</title>
|
| 7 |
+
|
| 8 |
+
<!-- فونت فارسی -->
|
| 9 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css" />
|
| 10 |
+
|
| 11 |
+
<style>
|
| 12 |
+
:root{
|
| 13 |
+
--bg-1:#0b0f17;
|
| 14 |
+
--bg-2:#0a0d14;
|
| 15 |
+
--grid:#ffffff12;
|
| 16 |
+
--text:#eaf2ff;
|
| 17 |
+
--muted:#9aa7b7;
|
| 18 |
+
--accent:#06b6d4; /* فیروزهای */
|
| 19 |
+
--accent-2:#7c3aed; /* بنفش */
|
| 20 |
+
--card-bg:rgba(255,255,255,0.06);
|
| 21 |
+
--card-stroke:rgba(255,255,255,0.12);
|
| 22 |
+
--input-bg:rgba(255,255,255,0.08);
|
| 23 |
+
--shadow:0 20px 70px rgba(0,0,0,.45);
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
*{box-sizing:border-box}
|
| 27 |
+
html,body{height:100%}
|
| 28 |
+
body{
|
| 29 |
+
margin:0;
|
| 30 |
+
font-family:"Vazirmatn", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
|
| 31 |
+
color:var(--text);
|
| 32 |
+
background:
|
| 33 |
+
radial-gradient(1000px 600px at 90% -10%, #3b82f633 0%, transparent 50%),
|
| 34 |
+
radial-gradient(900px 500px at -10% 110%, #a855f733 0%, transparent 55%),
|
| 35 |
+
linear-gradient(180deg, var(--bg-1), var(--bg-2));
|
| 36 |
+
position:relative;
|
| 37 |
+
-webkit-font-smoothing:antialiased;
|
| 38 |
+
-moz-osx-font-smoothing:grayscale;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/* الگوی ظریف شبکهای شبیه ماتریس QR */
|
| 42 |
+
body::before{
|
| 43 |
+
content:"";
|
| 44 |
+
position:fixed;
|
| 45 |
+
inset:0;
|
| 46 |
+
pointer-events:none;
|
| 47 |
+
background:
|
| 48 |
+
repeating-linear-gradient(0deg, var(--grid) 0 1px, transparent 1px 22px),
|
| 49 |
+
repeating-linear-gradient(90deg, var(--grid) 0 1px, transparent 1px 22px);
|
| 50 |
+
mask-image: radial-gradient(80% 80% at 50% 50%, black 55%, transparent 100%);
|
| 51 |
+
opacity:.5;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
.shell{
|
| 55 |
+
max-width:1200px;
|
| 56 |
+
margin-inline:auto;
|
| 57 |
+
padding:28px 18px 40px;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
.hero{
|
| 61 |
+
text-align:center;
|
| 62 |
+
margin-bottom:16px;
|
| 63 |
+
}
|
| 64 |
+
.title{
|
| 65 |
+
margin:0 0 8px 0;
|
| 66 |
+
font-weight:800;
|
| 67 |
+
font-size:clamp(22px, 5vw, 34px);
|
| 68 |
+
letter-spacing:-.3px;
|
| 69 |
+
background:linear-gradient(90deg, var(--accent), var(--accent-2));
|
| 70 |
+
-webkit-background-clip:text;
|
| 71 |
+
background-clip:text;
|
| 72 |
+
color:transparent;
|
| 73 |
+
filter:drop-shadow(0 6px 24px rgba(124,58,237,.25));
|
| 74 |
+
}
|
| 75 |
+
.subtitle{
|
| 76 |
+
margin:0 auto;
|
| 77 |
+
max-width:680px;
|
| 78 |
+
color:var(--muted);
|
| 79 |
+
font-weight:400;
|
| 80 |
+
line-height:1.8;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
/* ناوبری بین دو پنل (مخصوص موبایل) */
|
| 84 |
+
.nav-pills{
|
| 85 |
+
display:flex;
|
| 86 |
+
justify-content:center;
|
| 87 |
+
gap:10px;
|
| 88 |
+
margin:18px auto 10px;
|
| 89 |
+
padding:6px;
|
| 90 |
+
width:fit-content;
|
| 91 |
+
background:linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.05));
|
| 92 |
+
border:1px solid var(--card-stroke);
|
| 93 |
+
border-radius:999px;
|
| 94 |
+
backdrop-filter:blur(10px) saturate(140%);
|
| 95 |
+
-webkit-backdrop-filter:blur(10px) saturate(140%);
|
| 96 |
+
box-shadow:0 10px 30px rgba(0,0,0,.25);
|
| 97 |
+
}
|
| 98 |
+
.pill{
|
| 99 |
+
border:0;
|
| 100 |
+
color:var(--text);
|
| 101 |
+
background:transparent;
|
| 102 |
+
padding:10px 16px;
|
| 103 |
+
border-radius:999px;
|
| 104 |
+
font-weight:700;
|
| 105 |
+
cursor:pointer;
|
| 106 |
+
transition:all .25s ease;
|
| 107 |
+
font-size:.98rem;
|
| 108 |
+
}
|
| 109 |
+
.pill:hover{color:#fff; transform:translateY(-1px)}
|
| 110 |
+
.pill.active{
|
| 111 |
+
background:linear-gradient(90deg, var(--accent), var(--accent-2));
|
| 112 |
+
box-shadow:0 6px 18px rgba(6,182,212,.35);
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
/* محفظهی اسکرول افقی (موبایل) */
|
| 116 |
+
.carousel{
|
| 117 |
+
display:flex;
|
| 118 |
+
overflow-x:auto;
|
| 119 |
+
gap:16px;
|
| 120 |
+
scroll-snap-type:x mandatory;
|
| 121 |
+
scroll-behavior:smooth;
|
| 122 |
+
padding:8px 10px;
|
| 123 |
+
-webkit-overflow-scrolling:touch;
|
| 124 |
+
border-radius:16px;
|
| 125 |
+
}
|
| 126 |
+
/* جهت اسکرول LTR تا رفتار اسکرول اینترویویو دقیق باشه */
|
| 127 |
+
.carousel[dir="ltr"]{direction:ltr}
|
| 128 |
+
|
| 129 |
+
/* کارت/پنلها */
|
| 130 |
+
.panel{
|
| 131 |
+
position:relative;
|
| 132 |
+
scroll-snap-align:start;
|
| 133 |
+
min-width:calc(100vw - 40px); /* هر بار یک پنل کامل در موبایل */
|
| 134 |
+
background:linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.06));
|
| 135 |
+
border:1px solid var(--card-stroke);
|
| 136 |
+
border-radius:18px;
|
| 137 |
+
padding:22px 18px;
|
| 138 |
+
box-shadow:var(--shadow);
|
| 139 |
+
backdrop-filter:blur(12px) saturate(150%);
|
| 140 |
+
-webkit-backdrop-filter:blur(12px) saturate(150%);
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
/* تزئین گوشهها شبیه فایندر QR */
|
| 144 |
+
.panel .qr-corner{
|
| 145 |
+
position:absolute;
|
| 146 |
+
width:34px; height:34px; border-radius:8px;
|
| 147 |
+
border:3px solid var(--accent);
|
| 148 |
+
opacity:.7; pointer-events:none;
|
| 149 |
+
box-shadow:0 0 0 3px rgba(6,182,212,.12) inset, 0 0 24px rgba(6,182,212,.15);
|
| 150 |
+
}
|
| 151 |
+
.panel .qr-corner::after{
|
| 152 |
+
content:""; position:absolute; inset:6px;
|
| 153 |
+
border-radius:4px; border:3px solid var(--accent-2); opacity:.9;
|
| 154 |
+
}
|
| 155 |
+
.panel .qr-corner.tl{top:12px; right:12px}
|
| 156 |
+
.panel .qr-corner.tr{top:12px; left:12px}
|
| 157 |
+
.panel .qr-corner.bl{bottom:12px; right:12px}
|
| 158 |
+
.panel .qr-corner.br{bottom:12px; left:12px}
|
| 159 |
+
|
| 160 |
+
.panel h2{
|
| 161 |
+
margin:4px 0 14px 0;
|
| 162 |
+
font-weight:800;
|
| 163 |
+
font-size:1.25rem;
|
| 164 |
+
display:flex; align-items:center; gap:10px;
|
| 165 |
+
color:#fff;
|
| 166 |
+
}
|
| 167 |
+
.hint{
|
| 168 |
+
color:var(--muted);
|
| 169 |
+
font-size:.88rem;
|
| 170 |
+
margin:-4px 0 16px 0;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
.group{display:flex; flex-direction:column; gap:8px; margin-bottom:14px}
|
| 174 |
+
label{color:var(--muted); font-size:.92rem}
|
| 175 |
+
|
| 176 |
+
textarea{
|
| 177 |
+
width:100%;
|
| 178 |
+
min-height:110px;
|
| 179 |
+
resize:vertical;
|
| 180 |
+
padding:12px 14px;
|
| 181 |
+
color:var(--text);
|
| 182 |
+
background:var(--input-bg);
|
| 183 |
+
border:1px solid var(--card-stroke);
|
| 184 |
+
border-radius:12px;
|
| 185 |
+
outline:none;
|
| 186 |
+
transition:border-color .25s, box-shadow .25s;
|
| 187 |
+
}
|
| 188 |
+
textarea::placeholder{color:#98a3b3}
|
| 189 |
+
textarea:focus{
|
| 190 |
+
border-color: color-mix(in oklab, var(--accent) 65%, #fff 15%);
|
| 191 |
+
box-shadow:0 0 0 6px rgba(6,182,212,.15);
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
/* ورودی فایل شیک */
|
| 195 |
+
.file-wrap{position:relative}
|
| 196 |
+
input[type="file"]{display:none}
|
| 197 |
+
.file-label{
|
| 198 |
+
display:flex; align-items:center; justify-content:center; gap:10px;
|
| 199 |
+
width:100%;
|
| 200 |
+
padding:14px 16px;
|
| 201 |
+
background:var(--input-bg);
|
| 202 |
+
border:1px dashed color-mix(in oklab, var(--accent) 60%, #000 15%);
|
| 203 |
+
color:var(--text);
|
| 204 |
+
border-radius:12px;
|
| 205 |
+
cursor:pointer;
|
| 206 |
+
transition:all .25s ease;
|
| 207 |
+
}
|
| 208 |
+
.file-label:hover{
|
| 209 |
+
border-color:var(--accent);
|
| 210 |
+
box-shadow:0 0 0 6px rgba(124,58,237,.14);
|
| 211 |
+
transform:translateY(-1px);
|
| 212 |
+
}
|
| 213 |
+
#file-name{
|
| 214 |
+
min-height:1.2em; margin:8px 6px 0 0; font-size:.86rem; color:var(--muted);
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
.actions{
|
| 218 |
+
display:flex; gap:10px; flex-wrap:wrap;
|
| 219 |
+
}
|
| 220 |
+
button{
|
| 221 |
+
padding:12px 16px;
|
| 222 |
+
border-radius:12px;
|
| 223 |
+
border:0; cursor:pointer;
|
| 224 |
+
color:#fff; font-weight:800; font-size:1rem;
|
| 225 |
+
background:linear-gradient(90deg, var(--accent), var(--accent-2));
|
| 226 |
+
box-shadow:0 10px 26px rgba(6,182,212,.25);
|
| 227 |
+
transition:transform .2s ease, box-shadow .25s ease, opacity .25s ease;
|
| 228 |
+
display:flex; align-items:center; gap:10px;
|
| 229 |
+
}
|
| 230 |
+
button:hover:not(:disabled){
|
| 231 |
+
transform:translateY(-2px);
|
| 232 |
+
box-shadow:0 14px 34px rgba(124,58,237,.28);
|
| 233 |
+
}
|
| 234 |
+
button:disabled{opacity:.6; cursor:not-allowed}
|
| 235 |
+
|
| 236 |
+
.result{
|
| 237 |
+
margin-top:12px;
|
| 238 |
+
padding:18px;
|
| 239 |
+
background:linear-gradient(180deg, rgba(20,20,28,.35), rgba(20,20,28,.15));
|
| 240 |
+
border:1px solid var(--card-stroke);
|
| 241 |
+
border-radius:14px;
|
| 242 |
+
min-height:120px;
|
| 243 |
+
display:grid;
|
| 244 |
+
place-items:center;
|
| 245 |
+
text-align:center;
|
| 246 |
+
color:#eaf2ff;
|
| 247 |
+
}
|
| 248 |
+
#qr-code-display img{
|
| 249 |
+
max-width:100%; height:auto; border-radius:10px;
|
| 250 |
+
border:2px solid #fff; box-shadow:0 8px 30px rgba(0,0,0,.4);
|
| 251 |
+
animation:fade .5s ease;
|
| 252 |
+
}
|
| 253 |
+
@keyframes fade{from{opacity:0; transform:scale(.96)} to{opacity:1; transform:scale(1)}}
|
| 254 |
+
|
| 255 |
+
.loader{
|
| 256 |
+
width:32px; height:32px; border-radius:50%;
|
| 257 |
+
border:3px solid rgba(255,255,255,.15);
|
| 258 |
+
border-top-color: color-mix(in oklab, var(--accent) 70%, #fff 10%);
|
| 259 |
+
animation:spin 1s linear infinite; display:none;
|
| 260 |
+
}
|
| 261 |
+
@keyframes spin{to{transform:rotate(360deg)}}
|
| 262 |
+
|
| 263 |
+
.muted{color:var(--muted)}
|
| 264 |
+
.divider{
|
| 265 |
+
height:1px; background:var(--card-stroke);
|
| 266 |
+
margin:4px 0 12px 0; opacity:.7;
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
/* دسکتاپ: نمایش دو ستونه و بدون اسکرول افقی */
|
| 270 |
+
@media (min-width: 980px){
|
| 271 |
+
.carousel{
|
| 272 |
+
overflow:visible;
|
| 273 |
+
display:grid;
|
| 274 |
+
grid-template-columns:1fr 1fr;
|
| 275 |
+
gap:22px;
|
| 276 |
+
padding-inline:0;
|
| 277 |
+
}
|
| 278 |
+
.panel{min-width:auto}
|
| 279 |
+
.nav-pills{display:none}
|
| 280 |
+
.hero{margin-bottom:18px}
|
| 281 |
+
}
|
| 282 |
+
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 283 |
</head>
|
| 284 |
<body>
|
| 285 |
+
<div class="shell">
|
| 286 |
+
<header class="hero">
|
| 287 |
+
<h1 class="title">استودیوی QR</h1>
|
| 288 |
+
<p class="subtitle">ساخت سریع QR Code از متن یا لینک، و خواندن متن از تصویر QR — طراحی مدرن، سبک و مینیمال با تمرکز روی تجربه موبایل</p>
|
| 289 |
</header>
|
| 290 |
|
| 291 |
+
<!-- ناوبری سریع بین پنلها (روی موبایل) -->
|
| 292 |
+
<div class="nav-pills" role="tablist" aria-label="جابهجایی بین پنلها">
|
| 293 |
+
<button class="pill active" data-target="panel-generate">ساخت</button>
|
| 294 |
+
<button class="pill" data-target="panel-read">خواندن</button>
|
| 295 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
|
| 297 |
+
<!-- پنلها: اسکرول افقی روی موبایل، دو ستونه روی دسکتاپ -->
|
| 298 |
+
<div class="carousel" id="carousel" dir="ltr">
|
| 299 |
+
<!-- پنل ساخت -->
|
| 300 |
+
<section class="panel" id="panel-generate" dir="rtl">
|
| 301 |
+
<span class="qr-corner tl"></span>
|
| 302 |
+
<span class="qr-corner tr"></span>
|
| 303 |
+
<span class="qr-corner bl"></span>
|
| 304 |
+
<span class="qr-corner br"></span>
|
| 305 |
+
|
| 306 |
+
<h2>
|
| 307 |
+
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
| 308 |
+
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
| 309 |
+
<rect x="3" y="3" width="7" height="7"></rect><rect x="14" y="3" width="7" height="7"></rect>
|
| 310 |
+
<rect x="14" y="14" width="7" height="7"></rect><path d="M3 14h7v7H3z"></path>
|
| 311 |
+
</svg>
|
| 312 |
+
ساخت QR Code
|
| 313 |
+
</h2>
|
| 314 |
+
<p class="hint">متن یا لینک خود را وارد کنید. برای مثال: https://example.com</p>
|
| 315 |
+
|
| 316 |
+
<div class="group">
|
| 317 |
+
<label for="text-input">متن یا لینک</label>
|
| 318 |
+
<textarea id="text-input" rows="4" placeholder="مثلاً: https://google.com">سلام دنیا</textarea>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 319 |
</div>
|
|
|
|
| 320 |
|
| 321 |
+
<div class="actions">
|
| 322 |
+
<button id="generate-btn" type="button" title="ساخت QR Code">
|
| 323 |
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
| 324 |
+
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
| 325 |
+
<path d="M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2v0z"/><path d="M12 8l4 4-4 4"/><path d="M8 12h7"/>
|
| 326 |
+
</svg>
|
| 327 |
+
ساخت QR
|
| 328 |
+
</button>
|
| 329 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
|
| 331 |
+
<div class="result">
|
| 332 |
+
<div id="generate-loader" class="loader"></div>
|
| 333 |
+
<div id="qr-code-display"></div>
|
| 334 |
+
</div>
|
| 335 |
+
</section>
|
| 336 |
+
|
| 337 |
+
<!-- پنل خواندن -->
|
| 338 |
+
<section class="panel" id="panel-read" dir="rtl">
|
| 339 |
+
<span class="qr-corner tl"></span>
|
| 340 |
+
<span class="qr-corner tr"></span>
|
| 341 |
+
<span class="qr-corner bl"></span>
|
| 342 |
+
<span class="qr-corner br"></span>
|
| 343 |
+
|
| 344 |
+
<h2>
|
| 345 |
+
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
| 346 |
+
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
| 347 |
+
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/>
|
| 348 |
+
</svg>
|
| 349 |
+
خواندن QR Code
|
| 350 |
+
</h2>
|
| 351 |
+
<p class="hint">تصویر QR Code را انتخاب کنید تا متن داخل آن خوانده شود.</p>
|
| 352 |
+
|
| 353 |
+
<div class="group">
|
| 354 |
+
<label for="file-input">انتخاب تصویر QR</label>
|
| 355 |
+
<div class="file-wrap">
|
| 356 |
+
<input type="file" id="file-input" accept="image/*" />
|
| 357 |
+
<label class="file-label" for="file-input">
|
| 358 |
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
| 359 |
+
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
| 360 |
+
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/>
|
| 361 |
+
</svg>
|
| 362 |
+
لمس برای انتخاب فایل تصویر
|
| 363 |
+
</label>
|
| 364 |
+
</div>
|
| 365 |
+
<p id="file-name"></p>
|
| 366 |
+
</div>
|
| 367 |
|
| 368 |
+
<div class="actions">
|
| 369 |
+
<button id="read-btn" type="button" title="خواندن QR Code">
|
| 370 |
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
| 371 |
+
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
| 372 |
+
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/>
|
| 373 |
+
</svg>
|
| 374 |
+
خواندن
|
| 375 |
+
</button>
|
| 376 |
+
</div>
|
| 377 |
|
| 378 |
+
<div class="result">
|
| 379 |
+
<div id="read-loader" class="loader"></div>
|
| 380 |
+
<p id="decoded-text" class="muted">نتیجه در اینجا نمایش داده میشود.</p>
|
| 381 |
+
</div>
|
| 382 |
+
</section>
|
| 383 |
+
</div>
|
| 384 |
+
</div>
|
| 385 |
+
|
| 386 |
+
<script>
|
| 387 |
+
// Endpoint سرویس
|
| 388 |
+
const SPACE_URL = "https://cultrix-qrcode-read-generate.hf.space";
|
| 389 |
+
|
| 390 |
+
// المانها
|
| 391 |
+
const generateBtn = document.getElementById('generate-btn');
|
| 392 |
+
const readBtn = document.getElementById('read-btn');
|
| 393 |
+
const textInput = document.getElementById('text-input');
|
| 394 |
+
const fileInput = document.getElementById('file-input');
|
| 395 |
+
const qrCodeDisplay = document.getElementById('qr-code-display');
|
| 396 |
+
const decodedText = document.getElementById('decoded-text');
|
| 397 |
+
const generateLoader = document.getElementById('generate-loader');
|
| 398 |
+
const readLoader = document.getElementById('read-loader');
|
| 399 |
+
const fileNameDisplay = document.getElementById('file-name');
|
| 400 |
+
|
| 401 |
+
// نمایش نام فایل انتخابشده
|
| 402 |
+
fileInput.addEventListener('change', () => {
|
| 403 |
+
if (fileInput.files.length > 0) {
|
| 404 |
+
fileNameDisplay.textContent = `فایل انتخاب شده: ${fileInput.files[0].name}`;
|
| 405 |
+
} else {
|
| 406 |
+
fileNameDisplay.textContent = '';
|
| 407 |
+
}
|
| 408 |
+
});
|
| 409 |
+
|
| 410 |
+
// توابع کمکی Gradio Queue
|
| 411 |
+
const generateSessionHash = () => Math.random().toString(36).substring(2, 15);
|
| 412 |
+
|
| 413 |
+
const listenForData = (sessionHash, onResult, onError) => {
|
| 414 |
+
const eventSource = new EventSource(`${SPACE_URL}/gradio_api/queue/data?session_hash=${sessionHash}`);
|
| 415 |
+
|
| 416 |
+
eventSource.onmessage = (event) => {
|
| 417 |
+
const data = JSON.parse(event.data);
|
| 418 |
+
if (data.msg === "process_completed") {
|
| 419 |
+
eventSource.close();
|
| 420 |
+
if (data.output.error) {
|
| 421 |
+
onError(data.output.error);
|
| 422 |
+
} else {
|
| 423 |
+
onResult(data.output.data);
|
| 424 |
+
}
|
| 425 |
+
} else if (data.msg === "process_starts") {
|
| 426 |
+
// شروع پردازش
|
| 427 |
+
console.log("پردازش شروع شد...");
|
| 428 |
+
} else if (data.msg === "process_failed") {
|
| 429 |
+
eventSource.close();
|
| 430 |
+
onError("پردازش با خطا مواجه شد.");
|
| 431 |
+
}
|
| 432 |
+
};
|
| 433 |
+
|
| 434 |
+
eventSource.onerror = (err) => {
|
| 435 |
+
console.error("EventSource failed:", err);
|
| 436 |
+
eventSource.close();
|
| 437 |
+
onError("خطا در ارتباط با سرور.");
|
| 438 |
+
};
|
| 439 |
+
};
|
| 440 |
+
|
| 441 |
+
// ساخت QR
|
| 442 |
+
generateBtn.addEventListener('click', async () => {
|
| 443 |
+
const text = textInput.value.trim();
|
| 444 |
+
if (!text) return alert("لطفاً متنی را وارد کنید.");
|
| 445 |
+
|
| 446 |
+
generateLoader.style.display = 'block';
|
| 447 |
+
qrCodeDisplay.innerHTML = '';
|
| 448 |
+
generateBtn.disabled = true;
|
| 449 |
+
|
| 450 |
+
const sessionHash = generateSessionHash();
|
| 451 |
+
|
| 452 |
+
try {
|
| 453 |
+
const joinResponse = await fetch(`${SPACE_URL}/gradio_api/queue/join`, {
|
| 454 |
+
method: 'POST',
|
| 455 |
+
headers: { 'Content-Type': 'application/json' },
|
| 456 |
+
body: JSON.stringify({ fn_index: 0, data: [text], session_hash: sessionHash })
|
| 457 |
});
|
| 458 |
|
| 459 |
+
if (!joinResponse.ok) throw new Error(`خطا در ارسال درخواست: ${joinResponse.statusText}`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 460 |
|
| 461 |
+
listenForData(
|
| 462 |
+
sessionHash,
|
| 463 |
+
(result) => {
|
| 464 |
+
if (result && result[0]) {
|
| 465 |
+
qrCodeDisplay.innerHTML = result[0];
|
| 466 |
+
} else {
|
| 467 |
+
qrCodeDisplay.innerText = "خطا: خروجی معتبر دریافت نشد.";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 468 |
}
|
| 469 |
+
},
|
| 470 |
+
(error) => {
|
| 471 |
+
alert(`خطا در پردازش: ${error}`);
|
| 472 |
+
qrCodeDisplay.innerText = "خطا در ساخت تصویر.";
|
| 473 |
+
}
|
| 474 |
+
);
|
| 475 |
+
} catch (error) {
|
| 476 |
+
alert(`یک خطا رخ داد: ${error.message}`);
|
| 477 |
+
} finally {
|
| 478 |
+
generateLoader.style.display = 'none';
|
| 479 |
+
generateBtn.disabled = false;
|
| 480 |
+
}
|
| 481 |
+
});
|
| 482 |
+
|
| 483 |
+
// خواندن QR
|
| 484 |
+
readBtn.addEventListener('click', async () => {
|
| 485 |
+
const file = fileInput.files[0];
|
| 486 |
+
if (!file) return alert("لطفاً یک فایل تصویر انتخاب کنید.");
|
| 487 |
+
|
| 488 |
+
readLoader.style.display = 'block';
|
| 489 |
+
decodedText.innerText = '';
|
| 490 |
+
readBtn.disabled = true;
|
| 491 |
+
|
| 492 |
+
try {
|
| 493 |
+
const formData = new FormData();
|
| 494 |
+
formData.append('files', file);
|
| 495 |
+
|
| 496 |
+
const uploadResponse = await fetch(`${SPACE_URL}/gradio_api/upload`, {
|
| 497 |
+
method: 'POST',
|
| 498 |
+
body: formData
|
| 499 |
});
|
| 500 |
+
if (!uploadResponse.ok) throw new Error(`خطا در آپلود فایل: ${uploadResponse.statusText}`);
|
| 501 |
|
| 502 |
+
const uploadResult = await uploadResponse.json();
|
| 503 |
+
const serverFilePath = uploadResult[0];
|
|
|
|
|
|
|
|
|
|
|
|
|
| 504 |
|
| 505 |
+
const fileDataObject = {
|
| 506 |
+
path: serverFilePath,
|
| 507 |
+
url: `${SPACE_URL}/gradio_api/file=${serverFilePath}`,
|
| 508 |
+
orig_name: file.name,
|
| 509 |
+
};
|
| 510 |
|
| 511 |
+
const sessionHash = generateSessionHash();
|
| 512 |
+
const joinResponse = await fetch(`${SPACE_URL}/gradio_api/queue/join`, {
|
| 513 |
+
method: 'POST',
|
| 514 |
+
headers: { 'Content-Type': 'application/json' },
|
| 515 |
+
body: JSON.stringify({ fn_index: 1, data: [fileDataObject], session_hash: sessionHash })
|
| 516 |
});
|
| 517 |
+
if (!joinResponse.ok) throw new Error(`خطا در ارسال به صف: ${joinResponse.statusText}`);
|
| 518 |
+
|
| 519 |
+
listenForData(
|
| 520 |
+
sessionHash,
|
| 521 |
+
(result) => {
|
| 522 |
+
decodedText.innerText = `متن خوانده شده:\n${result[0]}`;
|
| 523 |
+
},
|
| 524 |
+
(error) => {
|
| 525 |
+
alert(`خطا در پردازش: ${error}`);
|
| 526 |
+
decodedText.innerText = "خطا در خواندن کد.";
|
| 527 |
+
}
|
| 528 |
+
);
|
| 529 |
+
} catch (error) {
|
| 530 |
+
alert(`یک خطا رخ داد: ${error.message}`);
|
| 531 |
+
decodedText.innerText = "نتیجه در اینجا نمایش داده میشود.";
|
| 532 |
+
} finally {
|
| 533 |
+
readLoader.style.display = 'none';
|
| 534 |
+
readBtn.disabled = false;
|
| 535 |
+
}
|
| 536 |
+
});
|
| 537 |
+
|
| 538 |
+
// ناوبری بین پنلها (موبایل): کلیک روی قرصها => اسکرول به پنل هدف
|
| 539 |
+
const carousel = document.getElementById('carousel');
|
| 540 |
+
const pills = document.querySelectorAll('.pill');
|
| 541 |
+
const panels = Array.from(carousel.querySelectorAll('.panel'));
|
| 542 |
+
|
| 543 |
+
pills.forEach(btn=>{
|
| 544 |
+
btn.addEventListener('click', ()=>{
|
| 545 |
+
const el = document.getElementById(btn.dataset.target);
|
| 546 |
+
if (el) el.scrollIntoView({behavior:'smooth', inline:'start', block:'nearest'});
|
| 547 |
+
});
|
| 548 |
+
});
|
| 549 |
+
|
| 550 |
+
// بهروزرسانی حالت Active بر اساس اسکرول
|
| 551 |
+
const setActiveByScroll = ()=>{
|
| 552 |
+
const bounds = panels.map(el => Math.abs(el.getBoundingClientRect().left - carousel.getBoundingClientRect().left));
|
| 553 |
+
const nearestIndex = bounds.indexOf(Math.min(...bounds));
|
| 554 |
+
pills.forEach((p,i)=>p.classList.toggle('active', i===nearestIndex));
|
| 555 |
+
};
|
| 556 |
+
|
| 557 |
+
let ticking = false;
|
| 558 |
+
carousel.addEventListener('scroll', ()=>{
|
| 559 |
+
if(!ticking){
|
| 560 |
+
window.requestAnimationFrame(()=>{
|
| 561 |
+
setActiveByScroll();
|
| 562 |
+
ticking = false;
|
| 563 |
});
|
| 564 |
+
ticking = true;
|
| 565 |
+
}
|
| 566 |
+
});
|
| 567 |
+
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 568 |
</body>
|
| 569 |
</html>
|