File size: 79,180 Bytes
f6b0fbc 574d903 f6b0fbc 1274119 f6b0fbc | 1 2 3 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 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 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 | <!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>جداساز حرفهای صدا</title>
<link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<style>
:root {
--app-font: 'Vazirmatn', sans-serif;
--app-bg: #F8F9FC;
--panel-bg: #FFFFFF;
--panel-border: #EAEFF7;
--input-bg: #F6F8FB;
--input-border: #E1E7EF;
--text-primary: #1A202C;
--text-secondary: #626F86;
--text-tertiary: #8A94A6;
--accent-primary: #4A6CFA;
--accent-primary-hover: #3553D6;
--accent-primary-glow: rgba(74, 108, 250, 0.25);
--accent-secondary: #0FD4A8;
--success-color: #38A169;
--danger-color: #e53e3e;
--danger-color-hover: #c53030;
--shadow-sm: 0 1px 2px 0 rgba(26, 32, 44, 0.03);
--shadow-md: 0 4px 6px -1px rgba(26, 32, 44, 0.05), 0 2px 4px -2px rgba(26, 32, 44, 0.04);
--shadow-lg: 0 10px 15px -3px rgba(26, 32, 44, 0.06), 0 4px 6px -4px rgba(26, 32, 44, 0.05);
--shadow-xl: 0 20px 25px -5px rgba(26, 32, 44, 0.07), 0 8px 10px -6px rgba(26, 32, 44, 0.05);
--radius-card: 24px;
--radius-btn: 14px;
--radius-input: 12px;
--transition-smooth: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
--igadlm-alpha-color-warning-bg: #FFFBEB;
--igadlm-alpha-color-warning-border: #FBBF24;
--igadlm-alpha-color-warning-text: #B45309;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
*, *::before, *::after { box-sizing: border-box; }
body {
font-family: var(--app-font);
background-color: var(--app-bg);
color: var(--text-primary);
line-height: 1.6;
padding: 2.5rem 1rem;
margin: 0;
display: flex;
justify-content: center;
align-items: flex-start;
min-height: 100vh;
}
.container { max-width: 820px; width: 100%; }
header {
text-align: center;
margin-bottom: 2.5rem;
animation: fadeIn 0.8s 0.1s ease-out backwards;
position: relative;
padding: 2rem 0;
overflow: hidden;
}
#neural-network-canvas {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
}
.header-content {
position: relative;
z-index: 2;
}
.logo {
width: 80px;
height: 80px;
margin: 0 auto 1.5rem;
background: linear-gradient(145deg, var(--accent-primary), var(--accent-secondary));
border-radius: 25px;
display: flex;
align-items: center;
justify-content: center;
box-shadow: var(--shadow-lg);
animation: float 3s ease-in-out infinite;
}
h1 {
font-size: 2.8rem; font-weight: 800; margin: 0;
background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
-webkit-background-clip: text; -webkit-text-fill-color: transparent;
letter-spacing: -1px;
}
.subtitle { font-size: 1.1rem; color: var(--text-secondary); margin-top: 0.5rem; }
main {
padding: 2.5rem;
background-color: var(--panel-bg);
border-radius: var(--radius-card);
box-shadow: var(--shadow-xl);
border: 1px solid var(--panel-border);
animation: fadeIn 0.8s 0.3s ease-out backwards;
}
.form-group { margin-bottom: 2.5rem; }
.form-label {
display: flex; align-items: center; gap: 0.75rem;
font-weight: 700; color: var(--text-primary); font-size: 1.2em;
margin-bottom: 1.2rem;
}
.form-label svg { width: 24px; height: 24px; color: var(--accent-primary); }
label { display: block; margin-bottom: 0.5rem; font-weight: 500; color: var(--text-secondary); }
.audio-input-container {
position: relative;
border: 2px dashed var(--input-border);
border-radius: var(--radius-input);
padding: 1.5rem;
text-align: center;
cursor: pointer;
transition: var(--transition-smooth);
background-color: var(--input-bg);
min-height: 80px;
display: flex;
justify-content: center;
align-items: center;
}
.audio-input-container:hover, .audio-input-container.drag-over {
border-color: var(--accent-primary);
background-color: #fff;
box-shadow: 0 0 15px var(--accent-primary-glow);
}
.audio-input-container.has-file {
border-style: solid;
border-color: var(--success-color);
background-color: #fff;
box-shadow: 0 0 15px rgba(56, 161, 105, 0.2);
cursor: default;
}
#audio-prompt { color: var(--text-secondary); font-weight: 500; }
.audio-player { display: none; align-items: center; width: 100%; gap: 1.5rem; }
.audio-input-container.has-file .audio-player { display: flex; }
.audio-input-container.has-file #audio-prompt { display: none; }
.play-pause-btn {
background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
border: none; border-radius: 50%; width: 52px; height: 52px;
display: flex; align-items: center; justify-content: center;
cursor: pointer; transition: var(--transition-smooth); flex-shrink: 0; box-shadow: var(--shadow-md);
}
.play-pause-btn:hover { transform: scale(1.08); box-shadow: var(--shadow-lg); }
.play-pause-btn svg { width: 26px; height: 26px; color: white; }
.play-pause-btn .icon-pause { display: none; }
.waveform-container { flex-grow: 1; display: flex; flex-direction: column; gap: 0.5rem; }
#waveform { width: 100%; height: 60px; cursor: pointer; background-color: var(--app-bg); border-radius: 8px; border: 1px solid var(--input-border); }
.audio-info { font-size: 0.85rem; color: var(--text-tertiary); width: 100%; display: flex; justify-content: space-between; padding: 0 0.25rem; }
#audioFileName { font-weight: 500; color: var(--text-secondary); word-break: break-all; text-align: right; }
#resetAudioBtn {
position: absolute; top: -12px; left: -12px; z-index: 10;
background-color: var(--panel-bg); border: 1px solid var(--panel-border); color: var(--text-tertiary);
width: 28px; height: 28px; border-radius: 50%; font-size: 24px; font-weight: bold; line-height: 0;
cursor: flex; align-items: center; justify-content: center; padding: 0 0 4px 1px;
box-shadow: var(--shadow-md); transition: var(--transition-smooth);
opacity: 0; transform: scale(0.8); pointer-events: none;
}
.audio-input-container.has-file #resetAudioBtn { opacity: 1; transform: scale(1); pointer-events: all; }
#resetAudioBtn:hover {
background-color: var(--danger-color); color: white;
border-color: var(--danger-color-hover); transform: scale(1.1) rotate(90deg);
}
.settings-grid-redesigned { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.checkbox-card {
position: relative; cursor: pointer; background-color: var(--input-bg);
border: 2px solid var(--input-border); border-radius: var(--radius-btn); padding: 1rem;
transition: var(--transition-smooth); text-align: center;
}
.checkbox-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--accent-primary-hover); }
.checkbox-card input[type="radio"], .checkbox-card input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.card-content { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.75rem; pointer-events: none; }
.card-icon svg { width: 36px; height: 36px; color: var(--text-tertiary); transition: var(--transition-smooth); }
.card-label { font-weight: 600; font-size: 0.95rem; color: var(--text-secondary); transition: var(--transition-smooth); }
.checkbox-card:has(input:checked) {
background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary)); border-color: transparent; color: white;
box-shadow: 0 8px 20px -4px var(--accent-primary-glow), 0 8px 20px -4px rgba(15, 212, 168, 0.3); transform: translateY(-4px) scale(1.02);
}
.checkbox-card:has(input:checked) .card-icon svg, .checkbox-card:has(input:checked) .card-label { color: white; }
.select-card {
grid-column: 1 / -1; display: flex; align-items: center; gap: 1rem;
background-color: var(--input-bg); border: 2px solid var(--input-border); border-radius: var(--radius-btn); padding: 0.5rem 1rem;
}
.select-card .card-icon svg { width: 28px; height: 28px; color: var(--text-tertiary); }
.select-card select {
width: 100%; padding: 0.75rem 0.5rem; border: none; background-color: transparent;
font-family: inherit; font-weight: 600; font-size: 1rem; color: var(--text-primary);
appearance: none; -webkit-appearance: none; cursor: pointer;
}
.select-card select:focus { outline: none; }
.settings-subheader {
font-size: 1rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 1rem;
grid-column: 1 / -1; padding-bottom: 0.5rem; border-bottom: 1px solid var(--panel-border);
}
details { border: 1px solid var(--panel-border); border-radius: var(--radius-card); margin-bottom: 1.5rem; background-color: var(--app-bg); transition: var(--transition-smooth); }
details[open] { box-shadow: var(--shadow-md); }
summary {
font-weight: 600; color: var(--text-primary); font-size: 1.125rem; padding: 1.25rem 1.5rem;
cursor: pointer; outline: none; list-style: none; display: flex; justify-content: space-between; align-items: center;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: '▼'; font-size: 0.8em; color: var(--text-tertiary); transition: transform 0.2s ease-in-out; }
details[open] summary::after { transform: rotate(180deg); }
.details-content { padding: 0 1.5rem 1.5rem; }
button#generateBtn {
display: flex; align-items: center; justify-content: center; gap: 0.75rem; width: 100%; padding: 1.1rem;
font-size: 1.2rem; font-weight: 700; background: linear-gradient(95deg, var(--accent-secondary) 0%, var(--accent-primary) 100%);
color: #fff; border: none; border-radius: var(--radius-btn); cursor: pointer; transition: all 0.3s ease;
box-shadow: 0 6px 12px -3px var(--accent-primary-glow), 0 6px 12px -3px rgba(15, 212, 168, 0.25); margin-top: 1.5rem;
}
button#generateBtn:hover:not(:disabled) {
transform: translateY(-5px) scale(1.02); box-shadow: 0 8px 20px -4px var(--accent-primary-glow), 0 8px 20px -4px rgba(15, 212, 168, 0.3);
}
button#generateBtn:disabled { background: var(--text-tertiary); cursor: not-allowed; box-shadow: none; opacity: 0.7; }
#result-container { border: 1px solid var(--panel-border); border-radius: var(--radius-card); padding: 1.5rem; background-color: var(--app-bg); box-shadow: var(--shadow-sm) inset; }
#progress-container { margin-top: 2rem; }
.progress-steps {
list-style: none; padding: 0; margin: 0 0 1rem 0; display: flex;
justify-content: space-between; position: relative;
}
.progress-steps::before {
content: ''; position: absolute; top: 20px; right: 0; transform: translateY(-50%);
height: 4px; width: 100%; background-color: var(--input-border); z-index: 1;
}
.progress-steps::after {
content: ''; position: absolute; top: 20px; right: 0; transform: translateY(-50%);
height: 4px; width: 0; background-color: var(--accent-primary); z-index: 2; transition: width 0.4s ease;
}
.progress-steps.step-2::after { width: 50%; } .progress-steps.step-3::after { width: 100%; }
.progress-steps.completed::after { background-color: var(--success-color); }
.progress-steps.error::after { background-color: var(--danger-color); }
.step { text-align: center; position: relative; z-index: 3; flex: 1; }
.step-icon {
width: 40px; height: 40px; border-radius: 50%; background-color: var(--panel-bg);
border: 4px solid var(--input-border); display: inline-flex; align-items: center; justify-content: center; transition: border-color 0.4s ease;
}
.step-icon svg { width: 20px; height: 20px; color: var(--text-tertiary); }
.step-label { font-size: 0.875rem; color: var(--text-tertiary); margin-top: 0.5rem; font-weight: 500;}
.step.active .step-icon { border-color: var(--accent-primary); }
.step.active .step-icon svg { color: var(--accent-primary); animation: spin 1.5s linear infinite; }
.step.active .step-label { color: var(--accent-primary); font-weight: 600; }
.step.completed .step-icon { border-color: var(--success-color); background-color: var(--success-color); }
.step.completed .step-icon svg { color: white; animation: none; }
.step.completed .step-label { color: var(--text-primary); }
.step.error .step-icon { border-color: var(--danger-color); background-color: var(--danger-color); }
.step.error .step-icon svg { color: white; animation: none; }
.step.error .step-label { color: var(--danger-color); }
#progress-status-text { text-align: center; color: var(--text-secondary); height: 2rem; font-weight: 500; }
#result-output {
display: none; background: #fff; border: 1px solid var(--panel-border);
border-radius: var(--radius-card); padding: 1.5rem 2rem; box-shadow: var(--shadow-md); animation: fadeIn 0.5s;
}
.output-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--panel-border); }
.output-header svg { width: 28px; height: 28px; color: var(--success-color); }
.output-header h3 { margin: 0; font-size: 1.2rem; font-weight: 700; color: var(--text-primary); }
.output-player-container {
background-color: var(--input-bg);
border: 1px solid var(--panel-border);
border-radius: var(--radius-btn);
padding: 0.75rem;
margin-bottom: 1.5rem;
}
.wa-player-card {
display: flex;
align-items: center;
gap: 1rem;
}
.wa-play-pause {
background-color: var(--accent-primary);
border: none; border-radius: 50%; width: 48px; height: 48px;
display: flex; align-items: center; justify-content: center;
cursor: pointer; transition: var(--transition-smooth); flex-shrink: 0; box-shadow: var(--shadow-sm);
}
.wa-play-pause:hover { transform: scale(1.05); background-color: var(--accent-primary-hover); }
.wa-play-pause svg { color: white; width: 24px; height: 24px; margin-right: 2px; }
.wa-play-pause .wa-icon-pause { display: none; margin-right: 0; }
.wa-play-pause.playing .wa-icon-pause { display: block; }
.wa-play-pause.playing .wa-icon-play { display: none; }
.wa-timeline-container {
flex-grow: 1;
position: relative;
height: 50px;
display: flex;
align-items: center;
cursor: pointer;
}
#wa-waveform-canvas {
width: 100%;
height: 100%;
}
.wa-scrubber-container {
position: absolute;
top: 0;
right: 0;
width: 15px;
height: 100%;
display: flex;
align-items: center;
transform: translateX(50%);
pointer-events: none;
}
.wa-scrubber-handle {
width: 15px;
height: 15px;
background-color: var(--accent-primary);
border-radius: 50%;
position: relative;
box-shadow: var(--shadow-md);
}
.wa-scrubber-loader {
position: absolute;
top: 50%;
left: 50%;
width: 30px;
height: 30px;
margin-top: -15px;
margin-left: -15px;
border: 3px solid rgba(74, 108, 250, 0.2);
border-top-color: var(--accent-primary);
border-radius: 50%;
animation: spin 1s linear infinite;
opacity: 0;
transition: opacity 0.2s;
}
.wa-scrubber-container.loading .wa-scrubber-loader {
opacity: 1;
}
.wa-time-display {
font-size: 0.9rem;
font-weight: 500;
color: var(--text-secondary);
padding-left: 0.5rem;
min-width: 45px;
text-align: center;
font-variant-numeric: tabular-nums;
}
a.download-button {
display: flex; align-items: center; justify-content: center; gap: 0.75rem; width: 100%; padding: 0.9rem;
font-size: 1.1rem; font-weight: 600; background-color: var(--accent-primary); color: #fff; text-decoration: none;
border: none; border-radius: var(--radius-btn); cursor: pointer; transition: var(--transition-smooth);
}
a.download-button:hover { background-color: var(--accent-primary-hover); transform: translateY(-3px); box-shadow: var(--shadow-lg); }
a.download-button svg { width: 22px; height: 22px; }
#criticalErrorSection.active { display: block; animation: fadeIn 0.5s; }
@keyframes slideInUp {
from { opacity: 0; transform: translateY(30px); }
to { opacity: 1; transform: translateY(0); }
}
:root {
--guide-bg: rgba(255, 255, 255, 0.98);
--guide-border: rgba(102, 126, 234, 0.2);
--guide-text-title: #2d3748;
--guide-text-body: #4a5568;
--guide-accent: #667eea;
--primary-gradient-guide: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
--success-gradient-guide: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%);
--radius-md-guide: 12px;
--radius-lg-guide: 20px;
}
.ip-reset-guide-container {
text-align: right; background: var(--guide-bg); backdrop-filter: blur(10px);
padding: 40px; border-radius: var(--radius-lg-guide);
box-shadow: var(--shadow-xl); border: 1px solid var(--guide-border); animation: slideInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) both;
width: 100%; position: relative; overflow: hidden; box-sizing: border-box;
}
.ip-reset-guide-container::before {
content: ''; position: absolute; top: 0; left: 0; right: 0; height: 5px; background: var(--primary-gradient-guide);
}
.guide-header { display: flex; align-items: center; margin-bottom: 30px; }
.guide-header-icon { width: 60px; height: 60px; margin-left: 20px; animation: float 3s ease-in-out infinite; }
.guide-header h2 { font-size: 1.5rem; color: var(--guide-text-title); font-weight: 700; margin: 0; }
.guide-header p { color: var(--guide-text-body); font-size: 0.8rem; margin-top: 5px; margin-bottom: 0; }
.guide-content { font-size: 0.95rem; color: var(--guide-text-body); line-height: 1.8; }
.info-card { background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%); border: 1px solid rgba(102, 126, 234, 0.2); border-radius: var(--radius-md-guide); padding: 20px; margin: 20px 0; position: relative; overflow: hidden; }
.info-card p { font-size: 0.85rem; line-height: 1.7; margin: 0; }
.info-card::before { content: ''; position: absolute; top: 0; right: 0; width: 4px; height: 100%; background: var(--primary-gradient-guide); }
.info-card-header { display: flex; align-items: center; margin-bottom: 12px; }
.info-card-icon { width: 24px; height: 24px; margin-left: 12px; }
.info-card-title { font-weight: 600; color: var(--guide-text-title); font-size: 1rem; }
.summary-section { margin-top: 25px; padding: 20px; border-radius: var(--radius-md-guide); background: linear-gradient(135deg, #56ab2f15 0%, #a8e06315 100%); border: 1px solid rgba(86, 171, 47, 0.2); position: relative; overflow: hidden; }
.summary-section::before { content: ''; position: absolute; top: 0; right: 0; width: 4px; height: 100%; background: var(--success-gradient-guide); }
.summary-header { display: flex; align-items: center; margin-bottom: 10px; }
.summary-icon { width: 24px; height: 24px; margin-left: 10px; }
.summary-title { font-weight: 600; color: #2f5a33; font-size: 1rem; }
.summary-text { color: #2f5a33; font-size: 0.9rem; line-height: 1.7; }
.video-button-container { text-align: center; margin: 25px 0 10px 0; }
.elegant-video-button { display: inline-flex; align-items: center; justify-content: center; padding: 7px 18px; background-color: #f0f2f5; color: var(--guide-accent); border: 1px solid #e2e8f0; text-decoration: none; border-radius: var(--radius-md-guide); font-weight: 600; font-size: 0.8rem; cursor: pointer; font-family: inherit; transition: all 0.3s ease; box-shadow: var(--shadow-sm); }
.elegant-video-button:hover { background: var(--primary-gradient-guide); color: white; border-color: transparent; transform: translateY(-2px); box-shadow: 0 6px 16px rgba(102, 126, 234, 0.3); }
.elegant-video-button-icon { width: 16px; height: 16px; margin-left: 8px; fill: currentColor; }
.guide-actions { display: flex; gap: 15px; margin-top: 30px; padding-top: 25px; border-top: 1px solid #e2e8f0; }
.action-button { padding: 14px 24px; border: none; border-radius: var(--radius-md-guide); font-size: 0.95rem; font-weight: 600; cursor: pointer; flex: 1; transition: var(--transition-smooth); position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.action-button-icon { width: 20px; height: 20px; margin-right: 0; margin-left: 8px; }
.back-button { background: white; color: var(--guide-text-body); border: 2px solid #e2e8f0; flex: 0.4; }
.back-button:hover { background: #f7fafc; border-color: var(--guide-accent); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.retry-button { background: var(--primary-gradient-guide); color: white; flex: 0.6; box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3); }
.retry-button:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4); }
@media (max-width: 768px) {
main { padding: 1.5rem; }
h1 { font-size: 2.2rem; }
.details-content { grid-template-columns: 1fr; }
.settings-grid-redesigned { grid-template-columns: repeat(2, 1fr); gap: 0.75rem;}
.card-icon svg { width: 28px; height: 28px; }
.card-label { font-size: 0.85rem; }
#result-output { padding: 1.5rem; }
.wa-player-card { flex-direction: row; gap: 0.5rem; }
.wa-play-pause { width: 40px; height: 40px; }
.wa-play-pause svg { width: 20px; height: 20px; }
}
</style>
</head>
<body>
<div class="container">
<header>
<canvas id="neural-network-canvas"></canvas>
<div class="header-content">
<div class="logo">
<svg width="50" height="50" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9 3C6.23858 3 4 5.23858 4 8V16C4 18.7614 6.23858 21 9 21H15C17.7614 21 20 18.7614 20 16V8C20 5.23858 17.7614 3 15 3H9Z" fill="white" opacity="0.9"/>
<path d="M8 10V14M12 8V16M16 11V13" stroke="#4A6CFA" stroke-width="2" stroke-linecap="round"/>
</svg>
</div>
<h1>جداساز حرفهای صدا</h1>
<p class="subtitle">وکال و موسیقی پسزمینه را با قدرت هوش مصنوعی جدا کنید</p>
</div>
</header>
<main>
<div class="form-group">
<div class="form-label">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18V5l12-2v13"></path><circle cx="6" cy="18" r="3"></circle><circle cx="18" cy="16" r="3"></circle></svg>
۱. فایل صوتی را بارگذاری کنید
</div>
<label for="media_file" class="audio-input-container">
<div id="audio-prompt">
<span>فایل صوتی را اینجا بکشید یا برای انتخاب کلیک کنید</span>
</div>
<div class="audio-player">
<button type="button" class="play-pause-btn">
<svg class="icon-play" viewBox="0 0 24 24"><path fill="currentColor" d="M8 5v14l11-7z"></path></svg>
<svg class="icon-pause" viewBox="0 0 24 24"><path fill="currentColor" d="M6 19h4V5H6v14zm8-14v14h4V5h-4z"></path></svg>
</button>
<div class="waveform-container">
<canvas id="waveform"></canvas>
<div class="audio-info">
<span id="audioFileName"></span>
<span id="audioDuration"></span>
</div>
</div>
</div>
<button id="resetAudioBtn" type="button" title="حذف فایل صوتی">×</button>
</label>
<input type="file" id="media_file" accept="audio/*" required style="display: none;">
</div>
<div class="form-group">
<div class="form-label">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M4 14h16"/><path d="M4 8h16"/><path d="M4 4h9"/></svg>
۲. تنظیمات اصلی را انتخاب کنید
</div>
<div class="settings-grid-redesigned">
<h3 class="settings-subheader">جزء مورد نظر (Stem):</h3>
<label class="checkbox-card">
<input type="radio" name="stem" value="vocal" checked>
<div class="card-content">
<div class="card-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" y1="19" x2="12" y2="22"></line></svg></div>
<span class="card-label">وکال</span>
</div>
</label>
<label class="checkbox-card">
<input type="radio" name="stem" value="background">
<div class="card-content">
<div class="card-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18V5l12-2v13"></path><circle cx="6" cy="18" r="3"></circle><circle cx="18" cy="16" r="3"></circle></svg></div>
<span class="card-label">پسزمینه</span>
</div>
</label>
<div class="select-card">
<div class="card-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>
</div>
<select id="target_format">
<option value="WAV" selected>فرمت خروجی: WAV</option>
<option value="MP3">فرمت خروجی: MP3</option>
<option value="FLAC">فرمت خروجی: FLAC</option>
</select>
</div>
</div>
</div>
<details>
<summary>تنظیمات پیشرفته</summary>
<div class="details-content" style="padding-top: 1.5rem;">
<div class="settings-grid-redesigned">
<h3 class="settings-subheader">گزینههای دیگر:</h3>
<label class="checkbox-card">
<input type="checkbox" id="main">
<div class="card-content">
<div class="card-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path><polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline><line x1="12" y1="22.08" x2="12" y2="12"></line></svg></div>
<span class="card-label">Main</span>
</div>
</label>
<label class="checkbox-card">
<input type="checkbox" id="dereverb">
<div class="card-content">
<div class="card-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 8c-4.97 0-9 1.79-9 4s4.03 4 9 4 9-1.79 9-4-4.03-4-9-4Z"/><path d="m18.5 13.51.45-1.01.9-2.02"/><path d="m5.05 13.51-.45-1.01-.9-2.02"/></svg></div>
<span class="card-label">Dereverb</span>
</div>
</label>
<label class="checkbox-card">
<input type="checkbox" id="vocal_effects">
<div class="card-content">
<div class="card-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15.5 2.5a2.5 2.5 0 0 1 3 4.5"/><path d="m14 6 1 1"/><path d="M18.5 6.5a2.5 2.5 0 0 0-3-4.5"/><path d="m18 2-1-1"/><path d="m12 12 2-2"/><path d="m12 12-2 2"/><path d="m6 18-2 2"/><path d="M12 12 6 6"/><path d="M18 12h-2"/><path d="M6 12H4"/><path d="m12 18 v-2"/></svg></div>
<span class="card-label">افکت وکال</span>
</div>
</label>
<label class="checkbox-card">
<input type="checkbox" id="background_effects">
<div class="card-content">
<div class="card-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 1 1-6.219-8.56"/><path d="M10.23 7.23 8 5l-2.23 2.23"/><path d="m13.77 16.77 2.23 2.23 2.23-2.23"/></svg></div>
<span class="card-label">افکت پسزمینه</span>
</div>
</label>
</div>
<details>
<summary>پارامترهای پیشرفته وکال</summary>
<div class="details-content" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem;">
<div class="form-group"><label>اندازه اتاق ریورب: <span id="vocal_reverb_room_size_val">0.15</span></label><input type="range" id="vocal_reverb_room_size" min="0" max="1" step="0.01" value="0.15" oninput="this.previousElementSibling.querySelector('span').textContent = this.value"></div>
<div class="form-group"><label>میزان Damping ریورب: <span id="vocal_reverb_damping_val">0.7</span></label><input type="range" id="vocal_reverb_damping" min="0" max="1" step="0.01" value="0.7" oninput="this.previousElementSibling.querySelector('span').textContent = this.value"></div>
<div class="form-group"><label>میزان خشکی ریورب: <span id="vocal_reverb_dryness_val">0.8</span></label><input type="range" id="vocal_reverb_dryness" min="0" max="1" step="0.01" value="0.8" oninput="this.previousElementSibling.querySelector('span').textContent = this.value"></div>
<div class="form-group"><label>میزان تری ریورب: <span id="vocal_reverb_wet_level_val">0.2</span></label><input type="range" id="vocal_reverb_wet_level" min="0" max="1" step="0.01" value="0.2" oninput="this.previousElementSibling.querySelector('span').textContent = this.value"></div>
<div class="form-group"><label for="vocal_delay_seconds">تاخیر (ثانیه):</label><input type="number" id="vocal_delay_seconds" step="0.1" value="0"></div>
<div class="form-group"><label>میزان ترکیب دیلی: <span id="vocal_delay_mix_val">0</span></label><input type="range" id="vocal_delay_mix" min="0" max="1" step="0.01" value="0" oninput="this.previousElementSibling.querySelector('span').textContent = this.value"></div>
<div class="form-group"><label for="vocal_compressor_threshold_db">آستانه کمپرسور (dB):</label><input type="number" id="vocal_compressor_threshold_db" step="1" value="-15"></div>
<div class="form-group"><label for="vocal_compressor_ratio">نسبت کمپرسور:</label><input type="number" id="vocal_compressor_ratio" step="1" value="4"></div>
<div class="form-group"><label for="vocal_compressor_attack_ms">زمان Attack (ms):</label><input type="number" id="vocal_compressor_attack_ms" step="1" value="1"></div>
<div class="form-group"><label for="vocal_compressor_release_ms">زمان Release (ms):</label><input type="number" id="vocal_compressor_release_ms" step="1" value="100"></div>
<div class="form-group"><label for="vocal_gain_db">گین وکال (dB):</label><input type="number" id="vocal_gain_db" step="1" value="0"></div>
</div>
</details>
<details>
<summary>پارامترهای پیشرفته پسزمینه</summary>
<div class="details-content" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem;">
<div class="form-group"><label for="background_highpass_freq">فرکانس Highpass (Hz):</label><input type="number" id="background_highpass_freq" step="10" value="120"></div>
<div class="form-group"><label for="background_lowpass_freq">فرکانس Lowpass (Hz):</label><input type="number" id="background_lowpass_freq" step="100" value="11000"></div>
<div class="form-group"><label>اندازه اتاق ریورب: <span id="background_reverb_room_size_val">0.1</span></label><input type="range" id="background_reverb_room_size" min="0" max="1" step="0.01" value="0.1" oninput="this.previousElementSibling.querySelector('span').textContent = this.value"></div>
<div class="form-group"><label>میزان Damping ریورب: <span id="background_reverb_damping_val">0.5</span></label><input type="range" id="background_reverb_damping" min="0" max="1" step="0.01" value="0.5" oninput="this.previousElementSibling.querySelector('span').textContent = this.value"></div>
<div class="form-group"><label>میزان تری ریورب: <span id="background_reverb_wet_level_val">0.25</span></label><input type="range" id="background_reverb_wet_level" min="0" max="1" step="0.01" value="0.25" oninput="this.previousElementSibling.querySelector('span').textContent = this.value"></div>
<div class="form-group"><label for="background_compressor_threshold_db">آستانه کمپرسور (dB):</label><input type="number" id="background_compressor_threshold_db" step="1" value="-15"></div>
<div class="form-group"><label for="background_compressor_ratio">نسبت کمپرسور:</label><input type="number" id="background_compressor_ratio" step="1" value="4"></div>
<div class="form-group"><label for="background_compressor_attack_ms">زمان Attack (ms):</label><input type="number" id="background_compressor_attack_ms" step="1" value="15"></div>
<div class="form-group"><label for="background_compressor_release_ms">زمان Release (ms):</label><input type="number" id="background_compressor_release_ms" step="1" value="60"></div>
<div class="form-group"><label for="background_gain_db">گین پسزمینه (dB):</label><input type="number" id="background_gain_db" step="1" value="0"></div>
</div>
</details>
</div>
</details>
<button id="generateBtn">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" width="24" height="24"><path d="M12.0006 18.26L4.92956 21.0707L6.52246 13.468L0.587891 8.43853L8.61466 7.84003L12.0006 0.5L15.3865 7.84003L23.4133 8.43853L17.4787 13.468L19.0716 21.0707L12.0006 18.26Z"></path></svg>
<span>شروع پردازش</span>
</button>
<div class="form-group" style="margin-top: 2.5rem;">
<div class="form-label">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 3L12 8L17 10L12 12L10 17L8 12L3 10L8 8L10 3z"/><path d="M21 14l-1.5 3-3-1.5 3-3 1.5 3z"/><path d="M19.5 2.5l-3 1.5 1.5 3 3-1.5-1.5-3z"/></svg>
۳. نتیجه
</div>
<div id="result-container">
<div id="progress-container" style="display: none;">
<ul class="progress-steps" id="progress-steps">
<li class="step" id="step-1"><div class="step-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M13 10V4H6V20H18V10H13ZM11 12H16L12 16V12H11Z"></path></svg></div><div class="step-label">آپلود</div></li>
<li class="step" id="step-2"><div class="step-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M15.5 13H18V15H15.5V13ZM15.5 9H18V11H15.5V9ZM15.5 5H18V7H15.5V5ZM13.5 19H20C20.5523 19 21 18.5523 21 18V4C21 3.44772 20.5523 3 20 3H4C3.44772 3 3 3.44772 3 4V20C3 20.5523 3.44772 21 4 21H11.5V19H5V5H13.5V19Z"></path></svg></div><div class="step-label">ارسال</div></li>
<li class="step" id="step-3"><div class="step-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M14.9998 1.414L21.5855 8.00003V20.0001C21.5855 21.1047 20.6902 22.0001 19.5855 22.0001H4.41401C3.30944 22.0001 2.41401 21.1047 2.41401 20.0001V4.00005C2.41401 2.89548 3.30944 2.00005 4.41401 2.00005H14.9998V1.414ZM12.9999 15.0001H15.4141L10.4141 20.0001H7.99988L12.9999 15.0001ZM13.9999 3.41401V8.00003H19.5855L13.9999 3.41401Z"></path></svg></div><div class="step-label">پردازش</div></li>
</ul>
<p id="progress-status-text"></p>
</div>
<div id="result-output"></div>
<div id="criticalErrorSection" style="display: none;"></div>
</div>
</div>
</main>
</div>
<script>
const generateBtn = document.getElementById('generateBtn');
const mediaFileInput = document.getElementById('media_file');
const progressContainer = document.getElementById('progress-container');
const progressSteps = document.getElementById('progress-steps');
const progressStatusText = document.getElementById('progress-status-text');
const resultOutput = document.getElementById('result-output');
const criticalErrorSection = document.getElementById('criticalErrorSection');
const step1 = document.getElementById('step-1');
const step2 = document.getElementById('step-2');
const step3 = document.getElementById('step-3');
const checkmarkSVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M10.0007 15.1709L19.1931 5.97852L20.6073 7.39273L10.0007 17.9993L3.63672 11.6354L5.05093 10.2212L10.0007 15.1709Z"></path></svg>`;
const errorSVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M12.0007 10.5865L16.9504 5.63672L18.3646 7.05093L13.4149 12.0007L18.3646 16.9504L16.9504 18.3646L12.0007 13.4149L7.05093 18.3646L5.63672 16.9504L10.5865 12.0007L5.63672 7.05093L7.05093 5.63672L12.0007 10.5865Z"></path></svg>`;
const audioInputContainer = document.querySelector('.audio-input-container');
const resetAudioBtn = document.getElementById('resetAudioBtn');
const playPauseBtn = document.querySelector('.play-pause-btn');
const iconPlay = document.querySelector('.icon-play');
const iconPause = document.querySelector('.icon-pause');
const waveformCanvas = document.getElementById('waveform');
const audioFileNameEl = document.getElementById('audioFileName');
const audioDurationEl = document.getElementById('audioDuration');
const waveformCtx = waveformCanvas.getContext('2d');
let audioContext, audioBuffer, audioSource, analyser, animationFrameId, isPlaying = false;
let lastAttemptPayload = null;
let pollTimer = null;
function hideCriticalError() {
criticalErrorSection.style.display = 'none';
criticalErrorSection.innerHTML = '';
}
async function retryLastAttempt() {
if (lastAttemptPayload && lastAttemptPayload.mediaFile) {
await startSeparationProcess(lastAttemptPayload.mediaFile);
} else {
alert("اطلاعات کافی برای تلاش مجدد وجود ندارد. لطفا از نو شروع کنید.");
}
}
function showGpuQuotaError() {
progressContainer.style.display = 'none';
resultOutput.style.display = 'none';
criticalErrorSection.innerHTML = `
<div class="ip-reset-guide-container">
<div class="guide-header"><svg class="guide-header-icon" viewbox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> <defs><lineargradient id="grad1" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" style="stop-color: #667eea; stop-opacity: 1;"></stop><stop offset="100%" style="stop-color: #764ba2; stop-opacity: 1;"></stop></lineargradient></defs> <circle cx="50" cy="50" r="45" fill="url(#grad1)" opacity="0.1"></circle><circle cx="50" cy="50" r="35" fill="none" stroke="url(#grad1)" stroke-width="2" opacity="0.3"></circle><path d="M35 50 L45 60 L65 40" stroke="url(#grad1)" stroke-width="4" fill="none" stroke-linecap="round" stroke-linejoin="round"></path><circle cx="65" cy="35" r="8" fill="#fee140"></circle><path d="M62 35 L68 35 M65 32 L65 38" stroke="white" stroke-width="2" stroke-linecap="round"></path> </svg>
<div>
<h2>یک قدم تا ساخت فایل جدید</h2>
<p>نیازمند تغییر نقطه دستیابی</p>
</div>
</div>
<div class="guide-content">
<div class="info-card">
<div class="info-card-header"><svg class="info-card-icon" viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z" fill="#667eea" opacity="0.2"></path><path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z" stroke="#667eea" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg> <span class="info-card-title">راه حل سریع</span></div>
<p>طبق ویدیو آموزشی پایین بین نقطه دستیابی جابجا شوید تلاش مجدد بزنید تا فایل مجدداً تولید بشه.</p>
</div>
<div class="summary-section">
<div class="summary-header"><svg class="summary-icon" viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" fill="#56ab2f" opacity="0.2"></circle><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z" stroke="#56ab2f" stroke-width="2"></path><path d="M9 12l2 2 4-4" stroke="#56ab2f" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg> <span class="summary-title">خلاصه راهنما</span></div>
<div class="summary-text">هربار که این صفحه را مشاهده کردید: از اینترنت سیمکارت استفاده کنید، VPN را خاموش کرده و طبق ویدیو آموزشی پایین نقطه دستیابی رو تغییر دهید. «تلاش مجدد» کلیک کنید. با این روش ساده میتوانید به صورت نامحدود فایل بسازید! ☘️</div>
</div>
<div class="video-button-container"><button id="tutorialLinkBtn" class="elegant-video-button"> <svg class="elegant-video-button-icon" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24"><path d="M8 5v14l11-7z"></path></svg> <span>دیدن ویدیو آموزشی استفاده نامحدود</span> </button></div>
</div>
<div class="guide-actions">
<button class="action-button back-button"> <svg class="action-button-icon" viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M19 12H5M12 19l-7-7 7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg> <span>بازگشت</span> </button>
<button class="action-button retry-button"> <svg class="action-button-icon" viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M23 4v6h-6M1 20v-6h6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><path d="M20.49 9A9 9 0 0 0 5.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 0 1 3.51 15" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg> <span>تلاش مجدد</span> </button>
</div>
</div>`;
criticalErrorSection.querySelector('.back-button').addEventListener('click', hideCriticalError);
criticalErrorSection.querySelector('.retry-button').addEventListener('click', retryLastAttempt);
document.getElementById('tutorialLinkBtn').addEventListener('click', () => {
const tutorialUrl = '#/nav/online/news/getSingle/1149635/eyJpdiI6IjhHVGhPQWJwb3E0cjRXbnFWTW5BaUE9PSIsInZhbHVlIjoiS1V0dTdvT21wbXAwSXZaK1RCTG1pVXZqdlFJa1hXV1RKa2FLem9zU3pXMjd5MmlVOGc2YWY0NVdNR3h3Smp1aSIsIm1hYyI6IjY1NTA5ZDYzMjAzMTJhMGQyMWQ4NjA4ZDgyNGZjZDVlY2MyNjdiMjA2NWYzOWRjY2M4ZmVjYWRlMWNlMWQ3ODEiLCJ0YWciOiIifQ==/21135210';
parent.postMessage({ type: 'NAVIGATE_TO_URL', url: tutorialUrl }, '*');
});
criticalErrorSection.style.display = 'block';
generateBtn.disabled = false;
generateBtn.querySelector('span').textContent = 'تلاش مجدد';
}
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
audioInputContainer.addEventListener(eventName, e => { e.preventDefault(); e.stopPropagation(); }, false);
});
['dragenter', 'dragover'].forEach(eventName => {
audioInputContainer.addEventListener(eventName, () => audioInputContainer.classList.add('drag-over'), false);
});
['dragleave', 'drop'].forEach(eventName => {
audioInputContainer.addEventListener(eventName, () => audioInputContainer.classList.remove('drag-over'), false);
});
audioInputContainer.addEventListener('drop', e => {
mediaFileInput.files = e.dataTransfer.files;
mediaFileInput.dispatchEvent(new Event('change'));
});
function resetAudioSelection() {
if (audioSource) { audioSource.stop(); }
cancelAnimationFrame(animationFrameId);
isPlaying = false; audioBuffer = null;
iconPlay.style.display = 'block'; iconPause.style.display = 'none';
audioInputContainer.classList.remove('has-file');
mediaFileInput.value = '';
waveformCtx.clearRect(0, 0, waveformCanvas.width, waveformCanvas.height);
audioInputContainer.setAttribute('for', 'media_file');
}
async function setupAudio(file) {
if (!audioContext) { audioContext = new (window.AudioContext || window.webkitAudioContext)(); }
analyser = audioContext.createAnalyser();
analyser.fftSize = 2048;
const arrayBuffer = await file.arrayBuffer();
audioBuffer = await audioContext.decodeAudioData(arrayBuffer);
audioFileNameEl.textContent = file.name;
audioDurationEl.textContent = `${formatTime(audioBuffer.duration)}`;
audioInputContainer.classList.add('has-file');
audioInputContainer.removeAttribute('for');
visualizeAudio();
}
function playAudio() {
if (!audioBuffer) return;
if (audioSource) { audioSource.stop(); }
audioSource = audioContext.createBufferSource();
audioSource.buffer = audioBuffer;
audioSource.connect(analyser);
analyser.connect(audioContext.destination);
audioSource.start(0);
isPlaying = true;
iconPlay.style.display = 'none'; iconPause.style.display = 'block';
audioSource.onended = () => { isPlaying = false; iconPlay.style.display = 'block'; iconPause.style.display = 'none'; }
}
function stopAudio() {
if (audioSource) { audioSource.stop(); }
isPlaying = false;
iconPlay.style.display = 'block'; iconPause.style.display = 'none';
}
function visualizeAudio() {
if (!analyser) return;
const bufferLength = analyser.frequencyBinCount;
const dataArray = new Uint8Array(bufferLength);
waveformCtx.clearRect(0, 0, waveformCanvas.width, waveformCanvas.height);
function draw() {
animationFrameId = requestAnimationFrame(draw);
analyser.getByteTimeDomainData(dataArray);
waveformCtx.fillStyle = getComputedStyle(document.documentElement).getPropertyValue('--app-bg').trim();
waveformCtx.fillRect(0, 0, waveformCanvas.width, waveformCanvas.height);
waveformCtx.lineWidth = 2;
waveformCtx.strokeStyle = getComputedStyle(document.documentElement).getPropertyValue('--accent-primary').trim();
waveformCtx.beginPath();
const sliceWidth = waveformCanvas.width * 1.0 / bufferLength;
let x = 0;
for (let i = 0; i < bufferLength; i++) {
const v = dataArray[i] / 128.0;
const y = v * waveformCanvas.height / 2;
if (i === 0) { waveformCtx.moveTo(x, y); } else { waveformCtx.lineTo(x, y); }
x += sliceWidth;
}
waveformCtx.lineTo(waveformCanvas.width, waveformCanvas.height / 2);
waveformCtx.stroke();
}
draw();
}
function formatTime(seconds) {
if (isNaN(seconds)) return '0:00';
const minutes = Math.floor(seconds / 60);
const secs = Math.floor(seconds % 60);
return `${minutes}:${secs < 10 ? '0' : ''}${secs}`;
}
mediaFileInput.addEventListener('change', () => {
const file = mediaFileInput.files[0];
if (file) { setupAudio(file); } else { resetAudioSelection(); }
});
playPauseBtn.addEventListener('click', () => {
if (isPlaying) { stopAudio(); } else { playAudio(); }
});
resetAudioBtn.addEventListener('click', (e) => {
e.preventDefault(); e.stopPropagation(); resetAudioSelection();
});
const resetProgress = () => {
const originalIcons = {
'step-1': `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M13 10V4H6V20H18V10H13ZM11 12H16L12 16V12H11Z"></path></svg>`,
'step-2': `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M15.5 13H18V15H15.5V13ZM15.5 9H18V11H15.5V9ZM15.5 5H18V7H15.5V5ZM13.5 19H20C20.5523 19 21 18.5523 21 18V4C21 3.44772 20.5523 3 20 3H4C3.44772 3 3 3.44772 3 4V20C3 20.5523 3.44772 21 4 21H11.5V19H5V5H13.5V19Z"></path></svg>`,
'step-3': `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M14.9998 1.414L21.5855 8.00003V20.0001C21.5855 21.1047 20.6902 22.0001 19.5855 22.0001H4.41401C3.30944 22.0001 2.41401 21.1047 2.41401 20.0001V4.00005C2.41401 2.89548 3.30944 2.00005 4.41401 2.00005H14.9998V1.414ZM12.9999 15.0001H15.4141L10.4141 20.0001H7.99988L12.9999 15.0001ZM13.9999 3.41401V8.00003H19.5855L13.9999 3.41401Z"></path></svg>`
};
[step1, step2, step3].forEach(step => {
step.className = 'step';
step.querySelector('.step-icon').innerHTML = originalIcons[step.id];
});
progressSteps.className = 'progress-steps';
progressStatusText.textContent = '';
};
const updateProgress = (step, message, isError = false) => {
progressContainer.style.display = 'block';
resultOutput.style.display = 'none';
hideCriticalError();
resetProgress();
if (isError) {
progressSteps.classList.add('error');
const errorStep = document.getElementById(`step-${step}`);
if(errorStep) {
errorStep.classList.add('error');
errorStep.querySelector('.step-icon').innerHTML = errorSVG;
}
for(let i=1; i<step; i++) {
const completedStep = document.getElementById(`step-${i}`);
completedStep.classList.add('completed');
completedStep.querySelector('.step-icon').innerHTML = checkmarkSVG;
}
progressSteps.classList.add(`step-${step}`);
} else {
if (step > 0) {
const currentStep = document.getElementById(`step-${step}`);
if(currentStep) currentStep.classList.add('active');
progressSteps.classList.add(`step-${step}`);
}
if (step === 'completed') {
[step1, step2, step3].forEach(s => {
s.classList.add('completed');
s.querySelector('.step-icon').innerHTML = checkmarkSVG;
});
progressSteps.classList.add('completed');
} else {
for(let i=1; i<step; i++) {
const completedStep = document.getElementById(`step-${i}`);
completedStep.classList.add('completed');
completedStep.querySelector('.step-icon').innerHTML = checkmarkSVG;
}
}
}
progressStatusText.textContent = message;
};
async function startSeparationProcess(mediaFile) {
generateBtn.disabled = true;
generateBtn.querySelector('span').textContent = 'در حال پردازش...';
resultOutput.style.display = 'none';
resultOutput.innerHTML = '';
hideCriticalError();
resetProgress();
lastAttemptPayload = { mediaFile };
const runId = 'sep' + Math.random().toString(36).substring(2, 13) + Math.random().toString(36).substring(2, 13);
const fileExt = mediaFile.name.split('.').pop() || 'mp3';
try {
updateProgress(1, '۱/۳: در حال آپلود فایل صوتی...');
const formData = new FormData();
formData.append('file', mediaFile);
formData.append('run_id', `${runId}_input`);
formData.append('ext', fileExt);
const uploadResponse = await fetch('/api/webhook/upload', { method: 'POST', body: formData });
if (!uploadResponse.ok) throw new Error('خطا در آپلود فایل.');
updateProgress(2, '۲/۳: ارسال درخواست به صف پردازش...');
const stem = document.querySelector('input[name="stem"]:checked').value;
const main = document.getElementById('main').checked ? 'true' : 'false';
const dereverb = document.getElementById('dereverb').checked ? 'true' : 'false';
const vocal_effects = document.getElementById('vocal_effects').checked ? 'true' : 'false';
const background_effects = document.getElementById('background_effects').checked ? 'true' : 'false';
const vocal_reverb_room_size = document.getElementById('vocal_reverb_room_size').value;
const vocal_reverb_damping = document.getElementById('vocal_reverb_damping').value;
const vocal_reverb_dryness = document.getElementById('vocal_reverb_dryness').value;
const vocal_reverb_wet_level = document.getElementById('vocal_reverb_wet_level').value;
const vocal_delay_seconds = document.getElementById('vocal_delay_seconds').value;
const vocal_delay_mix = document.getElementById('vocal_delay_mix').value;
const vocal_compressor_threshold_db = document.getElementById('vocal_compressor_threshold_db').value;
const vocal_compressor_ratio = document.getElementById('vocal_compressor_ratio').value;
const vocal_compressor_attack_ms = document.getElementById('vocal_compressor_attack_ms').value;
const vocal_compressor_release_ms = document.getElementById('vocal_compressor_release_ms').value;
const vocal_gain_db = document.getElementById('vocal_gain_db').value;
const background_highpass_freq = document.getElementById('background_highpass_freq').value;
const background_lowpass_freq = document.getElementById('background_lowpass_freq').value;
const background_reverb_room_size = document.getElementById('background_reverb_room_size').value;
const background_reverb_damping = document.getElementById('background_reverb_damping').value;
const background_reverb_wet_level = document.getElementById('background_reverb_wet_level').value;
const background_compressor_threshold_db = document.getElementById('background_compressor_threshold_db').value;
const background_compressor_ratio = document.getElementById('background_compressor_ratio').value;
const background_compressor_attack_ms = document.getElementById('background_compressor_attack_ms').value;
const background_compressor_release_ms = document.getElementById('background_compressor_release_ms').value;
const background_gain_db = document.getElementById('background_gain_db').value;
const target_format = document.getElementById('target_format').value;
const packedConfig = `VOICECONFIG_SEPARATE_userRunId_${runId}_ext_${fileExt}_stem_${stem}_main_${main}_dereverb_${dereverb}_vocEff_${vocal_effects}_bgEff_${background_effects}_vRevRoom_${vocal_reverb_room_size}_vRevDamp_${vocal_reverb_damping}_vRevDry_${vocal_reverb_dryness}_vRevWet_${vocal_reverb_wet_level}_vDelaySec_${vocal_delay_seconds}_vDelayMix_${vocal_delay_mix}_vCompThresh_${vocal_compressor_threshold_db}_vCompRatio_${vocal_compressor_ratio}_vCompAttack_${vocal_compressor_attack_ms}_vCompRelease_${vocal_compressor_release_ms}_vGain_${vocal_gain_db}_bgHigh_${background_highpass_freq}_bgLow_${background_lowpass_freq}_bgRevRoom_${background_reverb_room_size}_bgRevDamp_${background_reverb_damping}_bgRevWet_${background_reverb_wet_level}_bgCompThresh_${background_compressor_threshold_db}_bgCompRatio_${background_compressor_ratio}_bgCompAttack_${background_compressor_attack_ms}_bgCompRelease_${background_compressor_release_ms}_bgGain_${background_gain_db}_format_${target_format}`;
const dispatchResponse = await fetch('/api/generate', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
prompt: packedConfig,
width: 1024,
height: 1024,
action_name: 'separate-audio'
})
});
if (!dispatchResponse.ok) throw new Error('خطا در ارسال درخواست به صف.');
const dispatchResult = await dispatchResponse.json();
if (dispatchResult.status !== 'success') throw new Error(dispatchResult.message || 'خطا در ارسال درخواست.');
updateProgress(3, '۳/۳: منتظر دریافت پاسخ از سرور...');
let attempts = 0;
const maxAttempts = 150;
pollTimer = setInterval(async () => {
try {
attempts++;
if (attempts > maxAttempts) {
clearInterval(pollTimer);
updateProgress(3, 'خطای زمان انتظار: سرور در زمان مقرر پاسخ نداد.', true);
generateBtn.disabled = false;
generateBtn.querySelector('span').textContent = 'شروع پردازش';
return;
}
const statusResponse = await fetch(`/api/status/${dispatchResult.run_id}`);
if (!statusResponse.ok) return;
const statusResult = await statusResponse.json();
if (statusResult.status === 'ready') {
clearInterval(pollTimer);
updateProgress('completed', 'پردازش با موفقیت انجام شد!');
const audioUrl = statusResult.url;
resultOutput.innerHTML = `
<div class="output-header">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M10.0007 15.1709L19.1931 5.97852L20.6073 7.39273L10.0007 17.9993L3.63672 11.6354L5.05093 10.2212L10.0007 15.1709Z"></path></svg>
<h3>فایل خروجی شما آماده است</h3>
</div>
<div class="output-player-container">
<div class="wa-player-card">
<audio id="output-audio-engine" src="${audioUrl}" preload="metadata"></audio>
<button class="wa-play-pause">
<svg class="wa-icon-play" viewBox="0 0 24 24"><path fill="currentColor" d="M8 5v14l11-7z"></path></svg>
<svg class="wa-icon-pause" viewBox="0 0 24 24"><path fill="currentColor" d="M6 19h4V5H6v14zm8-14v14h4V5h-4z"></path></svg>
</button>
<div class="wa-timeline-container">
<canvas id="wa-waveform-canvas"></canvas>
<div class="wa-scrubber-container">
<div class="wa-scrubber-handle"></div>
<div class="wa-scrubber-loader"></div>
</div>
</div>
<div class="wa-time-display">0:00</div>
</div>
</div>
<a href="javascript:void(0);" class="download-button" id="post-message-download-btn" data-url="${audioUrl}">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>
<span>دانلود فایل</span>
</a>`;
setupOutputPlayer();
document.getElementById('post-message-download-btn').addEventListener('click', function(e) {
e.preventDefault();
const downloadUrl = this.getAttribute('data-url');
if (window.parent) {
window.parent.postMessage({
type: 'DOWNLOAD_REQUEST',
url: downloadUrl
}, '*');
}
});
resultOutput.style.display = 'block';
generateBtn.disabled = false;
generateBtn.querySelector('span').textContent = 'ساخت فایل جدید';
} else if (statusResult.status === 'failed') {
clearInterval(pollTimer);
showGpuQuotaError();
}
} catch (pollErr) {
console.error('Polling error:', pollErr);
}
}, 5000);
} catch (error) {
console.error('Error:', error);
updateProgress(1, `یک خطا رخ داد: ${error.message}`, true);
generateBtn.disabled = false;
generateBtn.querySelector('span').textContent = 'شروع پردازش';
}
}
function setupOutputPlayer() {
const audio = document.getElementById('output-audio-engine');
const playBtn = document.querySelector('.wa-play-pause');
const timelineContainer = document.querySelector('.wa-timeline-container');
const scrubberContainer = document.querySelector('.wa-scrubber-container');
const timeDisplay = document.querySelector('.wa-time-display');
const canvas = document.getElementById('wa-waveform-canvas');
const ctx = canvas.getContext('2d');
let waveformData = [];
let isScrubbing = false;
let animationFrameRequest;
const playedColor = getComputedStyle(document.documentElement).getPropertyValue('--accent-primary').trim();
const unplayedColor = getComputedStyle(document.documentElement).getPropertyValue('--text-tertiary').trim();
function generateWaveformData(numBars) {
waveformData = [];
for (let i = 0; i < numBars; i++) {
const height = Math.random() * 0.7 + 0.25;
waveformData.push(height);
}
}
function drawWaveform() {
const dpr = window.devicePixelRatio || 1;
canvas.width = timelineContainer.clientWidth * dpr;
canvas.height = timelineContainer.clientHeight * dpr;
ctx.scale(dpr, dpr);
const width = timelineContainer.clientWidth;
const height = timelineContainer.clientHeight;
const barWidth = 3;
const gap = 2;
const totalBarWidth = barWidth + gap;
const numBars = Math.floor(width / totalBarWidth);
if (waveformData.length !== numBars) {
generateWaveformData(numBars);
}
ctx.clearRect(0, 0, width, height);
const progress = (audio.currentTime / audio.duration) || 0;
const playedWidth = progress * width;
for (let i = 0; i < numBars; i++) {
const barHeight = waveformData[i] * height;
const x = i * totalBarWidth;
const y = (height - barHeight) / 2;
const barIsPlayed = x < playedWidth;
ctx.fillStyle = barIsPlayed ? playedColor : unplayedColor;
ctx.beginPath();
ctx.roundRect(x, y, barWidth, barHeight, 2);
ctx.fill();
}
}
function updateUI() {
if (!audio.duration) return;
const progress = audio.currentTime / audio.duration;
const scrubberX = progress * timelineContainer.clientWidth;
scrubberContainer.style.left = `${scrubberX}px`;
timeDisplay.textContent = formatTime(audio.currentTime);
drawWaveform();
animationFrameRequest = requestAnimationFrame(updateUI);
}
playBtn.addEventListener('click', () => audio.paused ? audio.play() : audio.pause());
audio.addEventListener('play', () => {
playBtn.classList.add('playing');
cancelAnimationFrame(animationFrameRequest);
animationFrameRequest = requestAnimationFrame(updateUI);
});
audio.addEventListener('pause', () => {
playBtn.classList.remove('playing');
cancelAnimationFrame(animationFrameRequest);
});
audio.addEventListener('ended', () => {
playBtn.classList.remove('playing');
audio.currentTime = 0;
cancelAnimationFrame(animationFrameRequest);
requestAnimationFrame(updateUI);
});
audio.addEventListener('loadedmetadata', () => {
timeDisplay.textContent = formatTime(0);
requestAnimationFrame(updateUI);
});
audio.addEventListener('waiting', () => scrubberContainer.classList.add('loading'));
audio.addEventListener('canplay', () => scrubberContainer.classList.remove('loading'));
audio.addEventListener('playing', () => scrubberContainer.classList.remove('loading'));
function handleScrub(e) {
if (!audio.duration) return;
const rect = timelineContainer.getBoundingClientRect();
const clickX = e.clientX || e.touches[0].clientX;
const progress = Math.max(0, Math.min(1, (clickX - rect.left) / rect.width));
audio.currentTime = progress * audio.duration;
requestAnimationFrame(updateUI);
}
const startScrub = (e) => { isScrubbing = true; handleScrub(e); };
const endScrub = () => isScrubbing = false;
const doScrub = (e) => { if(isScrubbing) handleScrub(e); };
timelineContainer.addEventListener('mousedown', startScrub);
document.addEventListener('mousemove', doScrub);
document.addEventListener('mouseup', endScrub);
timelineContainer.addEventListener('touchstart', startScrub, { passive: true });
document.addEventListener('touchmove', doScrub, { passive: true });
document.addEventListener('touchend', endScrub);
window.addEventListener('resize', () => requestAnimationFrame(drawWaveform));
}
generateBtn.addEventListener('click', async () => {
const mediaFile = mediaFileInput.files[0];
if (!mediaFile) {
alert('لطفاً یک فایل صوتی انتخاب کنید.');
return;
}
startSeparationProcess(mediaFile);
});
document.addEventListener('DOMContentLoaded', () => {
const canvas = document.getElementById('neural-network-canvas');
if (!canvas) return;
const header = canvas.parentElement;
const ctx = canvas.getContext('2d');
let particles = [];
const particleCount = 20;
const maxDistance = 100;
const computedStyles = getComputedStyle(document.documentElement);
const particleColor = computedStyles.getPropertyValue('--accent-primary').trim();
const lineColor = computedStyles.getPropertyValue('--text-tertiary').trim();
function resizeCanvas() {
canvas.width = header.clientWidth;
canvas.height = header.clientHeight;
init();
}
class Particle {
constructor() {
this.x = Math.random() * canvas.width;
this.y = Math.random() * canvas.height;
this.vx = (Math.random() - 0.5) * 0.3;
this.vy = (Math.random() - 0.5) * 0.3;
this.radius = 1.2;
}
update() {
this.x += this.vx;
this.y += this.vy;
if (this.x < 0 || this.x > canvas.width) this.vx *= -1;
if (this.y < 0 || this.y > canvas.height) this.vy *= -1;
}
draw() {
ctx.beginPath();
ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2);
ctx.fillStyle = particleColor;
ctx.fill();
}
}
function init() {
particles = [];
for (let i = 0; i < particleCount; i++) {
particles.push(new Particle());
}
}
function connectParticles() {
for (let i = 0; i < particles.length; i++) {
for (let j = i + 1; j < particles.length; j++) {
const dx = particles[i].x - particles[j].x;
const dy = particles[i].y - particles[j].y;
const distance = Math.sqrt(dx * dx + dy * dy);
if (distance < maxDistance) {
ctx.beginPath();
ctx.moveTo(particles[i].x, particles[i].y);
ctx.lineTo(particles[j].x, particles[j].y);
ctx.strokeStyle = lineColor;
ctx.lineWidth = 0.2;
ctx.globalAlpha = 1 - distance / maxDistance;
ctx.stroke();
}
}
}
ctx.globalAlpha = 1;
}
function animate() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
particles.forEach(particle => {
particle.update();
particle.draw();
});
connectParticles();
requestAnimationFrame(animate);
}
window.addEventListener('resize', resizeCanvas);
resizeCanvas();
animate();
});
</script>
</body>
</html> |