Spaces:
Running
Running
File size: 39,586 Bytes
0d1f33b | 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 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CyberDeck | 3D Extension & Asset Manager</title>
<!-- External Libraries -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.5/FileSaver.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Share+Tech+Mono&display=swap" rel="stylesheet">
<style>
:root {
--neon-cyan: #00f3ff;
--neon-pink: #ff00ff;
--neon-green: #0aff0a;
--dark-bg: #050505;
--panel-bg: rgba(20, 20, 20, 0.95);
--border-color: #333;
--scan-line: rgba(0, 243, 255, 0.05);
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
background-color: var(--dark-bg);
color: #e0e0e0;
font-family: 'Share Tech Mono', monospace;
overflow-x: hidden;
min-height: 100vh;
display: flex;
flex-direction: column;
}
/* Background Effects */
.bg-grid {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image:
linear-gradient(rgba(0, 243, 255, 0.1) 1px, transparent 1px),
linear-gradient(90deg, rgba(0, 243, 255, 0.1) 1px, transparent 1px);
background-size: 40px 40px;
z-index: -2;
opacity: 0.15;
animation: gridMove 20s linear infinite;
}
@keyframes gridMove {
0% { transform: translate(0, 0); }
100% { transform: translate(40px, 40px); }
}
.vignette {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: radial-gradient(circle, transparent 50%, black 100%);
z-index: -1;
pointer-events: none;
}
/* Header */
header {
padding: 20px 40px;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid var(--border-color);
background: rgba(5, 5, 5, 0.85);
backdrop-filter: blur(10px);
z-index: 100;
position: sticky;
top: 0;
box-shadow: 0 0 20px rgba(0, 243, 255, 0.1);
}
.logo {
font-family: 'Orbitron', sans-serif;
font-size: 1.5rem;
color: var(--neon-cyan);
text-shadow: 0 0 10px var(--neon-cyan);
letter-spacing: 2px;
display: flex;
align-items: center;
gap: 12px;
}
.anycoder-link {
color: var(--neon-green);
text-decoration: none;
font-size: 0.85rem;
border: 1px solid var(--neon-green);
padding: 6px 16px;
border-radius: 4px;
transition: all 0.3s ease;
font-weight: bold;
}
.anycoder-link:hover {
background: var(--neon-green);
color: black;
box-shadow: 0 0 15px var(--neon-green);
}
/* Navigation Tabs */
.nav-tabs {
display: flex;
background: rgba(0, 0, 0, 0.6);
border-bottom: 1px solid var(--border-color);
padding: 0 40px;
overflow-x: auto;
}
.nav-tab {
padding: 15px 30px;
background: transparent;
border: none;
color: #888;
font-family: 'Orbitron', sans-serif;
cursor: pointer;
transition: all 0.3s;
position: relative;
text-transform: uppercase;
font-size: 0.9rem;
white-space: nowrap;
}
.nav-tab.active {
color: var(--neon-cyan);
background: rgba(0, 243, 255, 0.05);
}
.nav-tab.active::after {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 3px;
background: var(--neon-cyan);
box-shadow: 0 0 10px var(--neon-cyan);
}
.nav-tab:hover {
color: #fff;
background: rgba(255, 255, 255, 0.05);
}
/* Main Content */
main {
flex: 1;
padding: 30px;
max-width: 1400px;
margin: 0 auto;
width: 100%;
}
.tab-content {
display: none;
animation: fadeIn 0.5s ease;
}
.tab-content.active {
display: block;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
/* Panels */
.panel {
background: var(--panel-bg);
border: 1px solid var(--border-color);
border-radius: 10px;
padding: 25px;
margin-bottom: 25px;
backdrop-filter: blur(5px);
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
transition: border-color 0.3s;
}
.panel:hover {
border-color: rgba(255, 255, 255, 0.2);
}
.panel-title {
font-family: 'Orbitron', sans-serif;
color: var(--neon-pink);
margin-bottom: 20px;
font-size: 1.3rem;
display: flex;
align-items: center;
gap: 12px;
text-transform: uppercase;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
padding-bottom: 10px;
}
/* Form Elements */
.input-group {
margin-bottom: 20px;
}
label {
display: block;
font-size: 0.9rem;
color: #aaa;
margin-bottom: 8px;
text-transform: uppercase;
letter-spacing: 1px;
}
input[type="text"],
input[type="file"],
textarea,
select {
width: 100%;
background: rgba(0, 0, 0, 0.6);
border: 1px solid #444;
color: var(--neon-cyan);
padding: 12px;
font-family: 'Share Tech Mono', monospace;
border-radius: 5px;
outline: none;
transition: all 0.3s;
}
input[type="text"]:focus,
textarea:focus,
select:focus {
border-color: var(--neon-cyan);
box-shadow: 0 0 15px rgba(0, 243, 255, 0.15);
}
textarea {
min-height: 120px;
resize: vertical;
font-size: 0.9rem;
}
/* Buttons */
.btn {
background: transparent;
border: 1px solid var(--neon-cyan);
color: var(--neon-cyan);
padding: 10px 20px;
cursor: pointer;
font-family: 'Orbitron', sans-serif;
text-transform: uppercase;
transition: all 0.3s;
position: relative;
overflow: hidden;
border-radius: 5px;
font-size: 0.85rem;
display: inline-flex;
align-items: center;
gap: 8px;
margin-right: 10px;
margin-bottom: 10px;
}
.btn::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(0, 243, 255, 0.2), transparent);
transition: 0.5s;
}
.btn:hover::before {
left: 100%;
}
.btn:hover {
background: rgba(0, 243, 255, 0.1);
box-shadow: 0 0 15px rgba(0, 243, 255, 0.3);
transform: translateY(-2px);
letter-spacing: 1px;
}
.btn-pink {
border-color: var(--neon-pink);
color: var(--neon-pink);
}
.btn-pink:hover {
background: rgba(255, 0, 255, 0.1);
box-shadow: 0 0 15px rgba(255, 0, 255, 0.3);
}
.btn-green {
border-color: var(--neon-green);
color: var(--neon-green);
}
.btn-green:hover {
background: rgba(10, 255, 10, 0.1);
box-shadow: 0 0 15px rgba(10, 255, 10, 0.3);
}
/* File Tree */
.file-tree {
background: rgba(0, 0, 0, 0.5);
border: 1px solid var(--border-color);
border-radius: 5px;
padding: 15px;
max-height: 300px;
overflow-y: auto;
font-family: 'Share Tech Mono', monospace;
}
.file-tree::-webkit-scrollbar {
width: 8px;
}
.file-tree::-webkit-scrollbar-track {
background: #111;
}
.file-tree::-webkit-scrollbar-thumb {
background: #333;
border-radius: 4px;
}
.file-tree::-webkit-scrollbar-thumb:hover {
background: var(--neon-cyan);
}
.file-item {
padding: 8px 12px;
cursor: pointer;
display: flex;
align-items: center;
gap: 10px;
transition: all 0.2s;
border-radius: 3px;
border-left: 2px solid transparent;
}
.file-item:hover {
background: rgba(0, 243, 255, 0.1);
border-left: 2px solid var(--neon-cyan);
color: #fff;
}
.file-icon {
color: var(--neon-pink);
}
/* Asset List */
.asset-list {
list-style: none;
max-height: 300px;
overflow-y: auto;
background: rgba(0, 0, 0, 0.3);
border-radius: 5px;
padding: 10px;
}
.asset-item {
padding: 10px;
margin-bottom: 8px;
background: rgba(255, 255, 255, 0.03);
border-radius: 5px;
display: flex;
align-items: center;
gap: 10px;
transition: all 0.3s;
border: 1px solid transparent;
}
.asset-item:hover {
background: rgba(0, 243, 255, 0.05);
border-color: rgba(255, 255, 255, 0.1);
}
.asset-checkbox {
width: 18px;
height: 18px;
accent-color: var(--neon-pink);
cursor: pointer;
}
/* 3D Scene */
.scene-3d {
width: 100%;
height: 400px;
background: radial-gradient(circle at center, #1a1a2e, #050505);
display: flex;
align-items: center;
justify-content: center;
perspective: 1000px;
border: 1px solid var(--border-color);
border-radius: 10px;
overflow: hidden;
position: relative;
}
.cube-container {
width: 150px;
height: 150px;
position: relative;
transform-style: preserve-3d;
animation: rotate3d 15s infinite linear;
}
@keyframes rotate3d {
from { transform: rotateX(0deg) rotateY(0deg); }
to { transform: rotateX(360deg) rotateY(360deg); }
}
.cube-face {
position: absolute;
width: 150px;
height: 150px;
background: rgba(0, 243, 255, 0.1);
border: 2px solid var(--neon-cyan);
display: flex;
align-items: center;
justify-content: center;
font-size: 1.2rem;
font-weight: bold;
color: var(--neon-cyan);
backface-visibility: visible;
text-shadow: 0 0 10px var(--neon-cyan);
box-shadow: 0 0 20px rgba(0, 243, 255, 0.1) inset;
}
.face-front { transform: translateZ(75px); }
.face-back { transform: rotateY(180deg) translateZ(75px); }
.face-right { transform: rotateY(90deg) translateZ(75px); }
.face-left { transform: rotateY(-90deg) translateZ(75px); }
.face-top { transform: rotateX(90deg) translateZ(75px); }
.face-bottom { transform: rotateX(-90deg) translateZ(75px); }
/* Status */
.status-bar {
background: rgba(0, 0, 0, 0.8);
border: 1px solid var(--neon-green);
border-left: 4px solid var(--neon-green);
border-radius: 4px;
padding: 12px 15px;
font-family: 'Share Tech Mono', monospace;
color: var(--neon-green);
margin-top: 20px;
min-height: 45px;
display: flex;
align-items: center;
font-size: 0.9rem;
}
.status-bar i {
margin-right: 10px;
animation: blink 2s infinite;
}
@keyframes blink {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
/* Grid Layout */
.grid-2 {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
}
.grid-options {
display: flex;
flex-wrap: wrap;
gap: 20px;
margin-bottom: 15px;
}
.checkbox-label {
display: flex !important;
align-items: center;
gap: 8px;
cursor: pointer;
color: #ccc !important;
text-transform: none !important;
font-size: 0.9rem;
}
.checkbox-label input {
width: auto !important;
margin: 0;
}
@media (max-width: 768px) {
.grid-2 {
grid-template-columns: 1fr;
}
header {
padding: 15px 20px;
flex-direction: column;
gap: 15px;
text-align: center;
}
.nav-tabs {
padding: 0 10px;
justify-content: flex-start;
}
.nav-tab {
padding: 12px 15px;
font-size: 0.8rem;
}
main {
padding: 15px;
}
.scene-3d {
height: 300px;
}
.cube-container {
width: 120px;
height: 120px;
}
.cube-face {
width: 120px;
height: 120px;
}
.face-front { transform: translateZ(60px); }
.face-back { transform: rotateY(180deg) translateZ(60px); }
.face-right { transform: rotateY(90deg) translateZ(60px); }
.face-left { transform: rotateY(-90deg) translateZ(60px); }
.face-top { transform: rotateX(90deg) translateZ(60px); }
.face-bottom { transform: rotateX(-90deg) translateZ(60px); }
}
</style>
</head>
<body>
<div class="bg-grid"></div>
<div class="vignette"></div>
<header>
<div class="logo">
<i class="fas fa-cube"></i> CYBERDECK // MANAGER
</div>
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="anycoder-link">
Built with anycoder <i class="fas fa-external-link-alt"></i>
</a>
</header>
<nav class="nav-tabs">
<button class="nav-tab active" onclick="switchTab('import')">
<i class="fas fa-file-import"></i> Import CRX/ZIP
</button>
<button class="nav-tab" onclick="switchTab('scanner')">
<i class="fas fa-radar"></i> Asset Scanner
</button>
<button class="nav-tab" onclick="switchTab('merger')">
<i class="fas fa-layer-group"></i> File Merger
</button>
<button class="nav-tab" onclick="switchTab('3d')">
<i class="fas fa-cube"></i> 3D Showroom
</button>
</nav>
<main>
<!-- Import CRX/ZIP Tab -->
<div id="import" class="tab-content active">
<div class="panel">
<h2 class="panel-title">
<i class="fas fa-file-archive"></i> Extension Source Manager
</h2>
<div class="grid-2">
<div class="input-group">
<label>Select Extension File (.CRX, .ZIP)</label>
<input type="file" id="crxFile" accept=".crx,.zip" onchange="handleCRXFile(event)">
</div>
<div class="input-group">
<label>File Operations</label>
<button class="btn" onclick="extractFiles()">
<i class="fas fa-unlock"></i> Extract Files
</button>
<button class="btn btn-pink" onclick="repackFiles()">
<i class="fas fa-box"></i> Repack ZIP
</button>
</div>
</div>
<div class="status-bar" id="importStatus">
<i class="fas fa-terminal"></i> Ready for file input...
</div>
</div>
<div class="panel" id="fileTreePanel" style="display: none;">
<h3 class="panel-title">
<i class="fas fa-folder-tree"></i> Extracted Files
</h3>
<div class="file-tree" id="fileTree"></div>
<div class="input-group">
<label>File Content Editor</label>
<textarea id="fileEditor" placeholder="Select a file to view/edit its content..."></textarea>
</div>
</div>
</div>
<!-- Asset Scanner Tab -->
<div id="scanner" class="tab-content">
<div class="panel">
<h2 class="panel-title">
<i class="fas fa-search-location"></i> 3D Asset Scanner
</h2>
<div class="input-group">
<label>Input Source (URLs or HTML)</label>
<textarea id="scanInput" placeholder="Paste URLs, HTML content, or lists to scan for 3D assets (OBJ, GLTF, Sketchfab, etc)..."></textarea>
</div>
<div class="grid-2">
<div>
<button class="btn" onclick="scanForAssets()">
<i class="fas fa-bolt"></i> Auto-Detect Assets
</button>
<button class="btn btn-pink" onclick="loadHistory()">
<i class="fas fa-history"></i> Load History
</button>
</div>
<div>
<button class="btn btn-green" onclick="exportAssets()">
<i class="fas fa-download"></i> Export Selected
</button>
</div>
</div>
<div class="input-group">
<label>Detected Assets</label>
<ul class="asset-list" id="assetList">
<li style="color: #888; font-style: italic; padding: 10px;">No assets detected yet...</li>
</ul>
</div>
<div class="status-bar" id="scannerStatus">
<i class="fas fa-satellite-dish"></i> Scanner ready...
</div>
</div>
</div>
<!-- File Merger Tab -->
<div id="merger" class="tab-content">
<div class="panel">
<h2 class="panel-title">
<i class="fas fa-code-merge"></i> Project Merger & Optimizer
</h2>
<div class="input-group">
<label>Upload Multiple Files</label>
<input type="file" id="mergeFiles" multiple onchange="handleMergeFiles(event)">
</div>
<div class="input-group">
<label>Merge Options</label>
<div class="grid-options">
<label class="checkbox-label">
<input type="checkbox" id="minify"> Minify JS/CSS
</label>
<label class="checkbox-label">
<input type="checkbox" id="removeComments"> Remove Comments
</label>
<label class="checkbox-label">
<input type="checkbox" id="inlineImages"> Inline Images (Base64)
</label>
</div>
</div>
<button class="btn" onclick="performMerge()">
<i class="fas fa-cogs"></i> Process & Download Bundle
</button>
<div class="input-group">
<label>Merged Output Preview</label>
<textarea id="mergeOutput" readonly placeholder="Merged content will appear here..."></textarea>
</div>
<div class="status-bar" id="mergerStatus">
<i class="fas fa-microchip"></i> Ready to merge files...
</div>
</div>
</div>
<!-- 3D Showroom Tab -->
<div id="3d" class="tab-content">
<div class="panel">
<h2 class="panel-title">
<i class="fas fa-eye"></i> CSS3 3D Viewer
</h2>
<div class="scene-3d">
<div class="cube-container">
<div class="cube-face face-front">CYBER</div>
<div class="cube-face face-back">DECK</div>
<div class="cube-face face-right">DATA</div>
<div class="cube-face face-left">CORE</div>
<div class="cube-face face-top">UPLINK</div>
<div class="cube-face face-bottom">SYS</div>
</div>
</div>
<div class="grid-2">
<div class="input-group">
<label>Cube Opacity: <span id="opacityValue">10%</span></label>
<input type="range" id="opacitySlider" min="0" max="100" value="10"
oninput="updateCubeOpacity(this.value)">
</div>
<div class="input-group">
<label>Animation Speed</label>
<select id="speedSelect" onchange="updateAnimationSpeed(this.value)">
<option value="30s">Glacial</option>
<option value="20s">Slow</option>
<option value="15s" selected>Normal</option>
<option value="5s">Fast</option>
<option value="2s">Hyper</option>
</select>
</div>
</div>
<button class="btn btn-green" onclick="download3DScene()" style="width: 100%; margin-top: 10px;">
<i class="fas fa-download"></i> Download 3D Scene HTML
</button>
<div class="status-bar" id="3dStatus">
<i class="fas fa-cube"></i> 3D Scene Active
</div>
</div>
</div>
</main>
<script>
// Global variables
let currentZip = null;
let extractedFiles = {};
let detectedAssets = [];
let mergedFiles = {};
let activeTab = 'import';
// Tab switching
function switchTab(tabName) {
// Hide all tabs
document.querySelectorAll('.tab-content').forEach(tab => {
tab.classList.remove('active');
});
// Remove active class from all nav tabs
document.querySelectorAll('.nav-tab').forEach(tab => {
tab.classList.remove('active');
});
// Show selected tab
document.getElementById(tabName).classList.add('active');
// Add active class to clicked nav tab
// Find the button that calls this function with this tabName
const buttons = document.querySelectorAll('.nav-tab');
buttons.forEach(btn => {
if(btn.getAttribute('onclick').includes(tabName)) {
btn.classList.add('active');
}
});
activeTab = tabName;
}
// Update status messages
function updateStatus(statusId, message, isError = false) {
const el = document.getElementById(statusId);
const color = isError ? 'var(--neon-pink)' : 'var(--neon-green)';
el.style.borderColor = color;
el.style.color = color;
// Get icon class
let iconClass = 'fas fa-check-circle';
if (isError) iconClass = 'fas fa-exclamation-triangle';
else if (message.includes('Loading') || message.includes('Processing')) iconClass = 'fas fa-spinner fa-spin';
else if (message.includes('Ready')) iconClass = 'fas fa-satellite-dish';
el.innerHTML = `<i class="${iconClass}"></i> ${message}`;
}
// Import/Extract CRX/ZIP functions
async function handleCRXFile(event) {
const file = event.target.files[0];
if (!file) return;
updateStatus('importStatus', `Loading ${file.name}...`);
try {
// Read file as array buffer
const arrayBuffer = await file.arrayBuffer();
// Load with JSZip
currentZip = await JSZip.loadAsync(arrayBuffer);
updateStatus('importStatus', 'File loaded. Click "Extract Files" to view contents.');
} catch (error) {
updateStatus('importStatus', `Error: ${error.message}`, true);
console.error(error);
}
}
async function extractFiles() {
if (!currentZip) {
updateStatus('importStatus', 'No file loaded. Please select a CRX/ZIP file first.', true);
return;
}
updateStatus('importStatus', 'Extracting files...');
extractedFiles = {};
let fileTreeHTML = '';
// Convert iterator to array to handle async operations if needed,
// though forEach is synchronous in JSZip for reading metadata
const files = [];
currentZip.forEach((relativePath, file) => {
files.push({ relativePath, file });
});
// Sort folders first, then files
files.sort((a, b) => {
const pathA = a.relativePath.split('/');
const pathB = b.relativePath.split('/');
return pathA[0].localeCompare(pathB[0]);
});
files.forEach(({ relativePath, file }) => {
if (!file.dir) {
extractedFiles[relativePath] = file;
const icon = getFileIcon(relativePath);
fileTreeHTML += `
<div class="file-item" onclick="viewFile('${relativePath.replace(/'/g, "\\'")}')">
<i class="${icon} file-icon"></i>
<span>${relativePath}</span>
</div>
`;
}
});
document.getElementById('fileTree').innerHTML = fileTreeHTML;
document.getElementById('fileTreePanel').style.display = 'block';
updateStatus('importStatus', `Extracted ${Object.keys(extractedFiles).length} files.`);
}
function getFileIcon(filename) {
const ext = filename.split('.').pop().toLowerCase();
const icons = {
'js': 'fab fa-js',
'mjs': 'fab fa-js',
'css': 'fab fa-css3-alt',
'scss': 'fab fa-sass',
'html': 'fab fa-html5',
'json': 'fas fa-file-code',
'png': 'fas fa-file-image',
'jpg': 'fas fa-file-image',
'jpeg': 'fas fa-file-image',
'gif': 'fas fa-file-image',
'svg': 'fas fa-bezier-curve',
'ico': 'fas fa-id-badge',
'xml': 'fas fa-file-code',
'md': 'fab fa-markdown'
};
return icons[ext] || 'fas fa-file';
}
async function viewFile(filename) {
if (!extractedFiles[filename]) return;
updateStatus('importStatus', `Reading ${filename}...`);
try {
const content = await extractedFiles[filename].async('text');
document.getElementById('fileEditor').value = content;
updateStatus('importStatus', `Viewing: ${filename}`);
} catch (e) {
document.getElementById('fileEditor').value = "[Binary or Unreadable File]";
updateStatus('importStatus', `Cannot display binary file: ${filename}`);
}
}
async function repackFiles() {
if (!currentZip) {
updateStatus('importStatus', 'No files to repack.', true);
return;
}
updateStatus('importStatus', 'Repacking files...');
// Generate the zip file
const blob = await currentZip.generateAsync({
type: 'blob',
compression: "DEFLATE",
compressionOptions: { level: 9 }
});
// Download the file
saveAs(blob, 'cyberdeck_repacked.zip');
updateStatus('importStatus', 'Repacked file downloaded successfully.');
}
// Asset Scanner functions
function scanForAssets() {
const input = document.getElementById('scanInput').value;
if (!input.trim()) {
updateStatus('scannerStatus', 'Please provide input to scan.', true);
return;
}
updateStatus('scannerStatus', 'Scanning for assets...');
// Asset detection patterns
const patterns = [
/\.obj$/i,
/\.gltf$/i,
/\.glb$/i,
/\.fbx$/i,
/\.3ds$/i,
/\.stl$/i,
/sketchfab\.com/i,
/free3d\.io/i,
/archive\.org/i,
/raw\.githubusercontent/i,
/\.min\.js$/ // Common for three.js bundles
];
const lines = input.split(/[\s\n,]+/);
const assetList = document.getElementById('assetList');
assetList.innerHTML = '';
let foundCount = 0;
detectedAssets = []; // Reset global list
lines.forEach(line => {
const trimmed = line.trim();
if (!trimmed) return;
const isAsset = patterns.some(pattern => pattern.test(trimmed));
// Also try to catch URLs containing specific keywords even without exact extension
const heuristicMatch = (trimmed.includes('3d-model') || trimmed.includes('download/file')) && trimmed.length > 10;
if ((isAsset || heuristicMatch) && trimmed.length > 5) {
// Avoid duplicates in UI
if (!detectedAssets.includes(trimmed)) {
foundCount++;
const assetId = `asset-${foundCount}`;
detectedAssets.push(trimmed);
const li = document.createElement('li');
li.className = 'asset-item';
li.innerHTML = `
<input type="checkbox" class="asset-checkbox" id="${assetId}" checked data-url="${trimmed.replace(/"/g, '"')}">
<label for="${assetId}" style="cursor: pointer; flex: 1; word-break: break-all;">${trimmed}</label>
`;
assetList.appendChild(li);
// Save to history
saveToHistory(trimmed);
}
}
});
if (foundCount === 0) {
assetList.innerHTML = '<li style="color: #888; padding: 10px;">No assets found matching known patterns.</li>';
}
updateStatus('scannerStatus', `Found ${foundCount} assets.`);
}
function saveToHistory(asset) {
let history = JSON.parse(localStorage.getItem('cyberdeck_assetHistory') || '[]');
if (!history.includes(asset)) {
history.unshift(asset);
if (history.length > 100) history.pop(); // Keep last 100
localStorage.setItem('cyberdeck_assetHistory', JSON.stringify(history));
}
}
function loadHistory() {
const history = JSON.parse(localStorage.getItem('cyberdeck_assetHistory') || '[]');
const assetList = document.getElementById('assetList');
assetList.innerHTML = '';
if (history.length === 0) {
assetList.innerHTML = '<li style="color: #888; padding: 10px;">No history found.</li>';
updateStatus('scannerStatus', 'No history available.', true);
return;
}
history.forEach((asset, index) => {
const assetId = `history-${index}`;
const li = document.createElement('li');
li.className = 'asset-item';
li.innerHTML = `
<input type="checkbox" class="asset-checkbox" id="${assetId}" checked data-url="${asset.replace(/"/g, '"')}">
<label for="${assetId}" style="cursor: pointer; flex: 1; word-break: break-all;">${asset}</label>
`;
assetList.appendChild(li);
});
updateStatus('scannerStatus', `Loaded ${history.length} items from history.`);
}
function exportAssets() {
const checkboxes = document.querySelectorAll('#assetList .asset-checkbox:checked');
const selectedAssets = Array.from(checkboxes).map(cb => cb.getAttribute('data-url') || cb.nextElementSibling.textContent);
if (selectedAssets.length === 0) {
updateStatus('scannerStatus', 'No assets selected.', true);
return;
}
const content = `# Exported 3D Assets\n# Generated by CyberDeck\n\n${selectedAssets.join('\n')}`;
const blob = new Blob([content], { type: 'text/plain' });
saveAs(blob, 'exported_assets.txt');
updateStatus('scannerStatus', `Exported ${selectedAssets.length} assets.`);
}
// File Merger functions
async function handleMergeFiles(event) {
const files = event.target.files;
if (!files || files.length === 0) return;
mergedFiles = {};
updateStatus('mergerStatus', `Loading ${files.length} files...`);
for (let i = 0; i < files.length; i++) {
const file = files[i];
const content = await file.text();
mergedFiles[file.name] = content;
}
updateStatus('mergerStatus', `${files.length} files loaded. Ready to merge.`);
}
async function performMerge() {
if (Object.keys(mergedFiles).length === 0) {
updateStatus('mergerStatus', 'No files to merge. Please upload files first.', true);
return;
}
updateStatus('mergerStatus', 'Processing merge...');
const minify = document.getElementById('minify').checked;
const removeComments = document.getElementById('removeComments').checked;
// Note: inlineImages requires FileReader API for binary data, simplified here
let mergedContent = `/* Merged by CyberDeck */\n`;
let fileCount = 0;
for (const [filename, content] of Object.entries(mergedFiles)) {
fileCount++;
let processed = content;
if (removeComments) {
// Remove HTML comments
processed = processed.replace(/<!--[\s\S]*?-->/g, '');
// Remove JS single line and multi-line comments (simple regex, complex AST is better for production)
processed = processed.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm, '$1');
// Remove CSS comments
processed = processed.replace(/\/\*[\s\S]*?\*\//g, '');
}
if (minify) {
// Very basic minification (whitespace removal)
processed = processed.replace(/\s+/g, ' ').trim();
// Remove newlines
processed = processed.replace(/;\s*/g, ';').replace(/\{\s*/g, '{').replace(/\}\s*/g, '}');
}
mergedContent += `\n/* === FILE: ${filename} === */\n${processed}\n`;
}
mergedContent += `\n/* End of merge. Total files: ${fileCount} */`;
document.getElementById('mergeOutput').value = mergedContent;
// Download the merged file
const blob = new Blob([mergedContent], { type: 'text/plain' });
saveAs(blob, 'merged_bundle.txt');
updateStatus('mergerStatus', `Merge complete. ${fileCount} files bundled.`);
}
// 3D Scene functions
function updateCubeOpacity(value) {
document.getElementById('opacityValue').textContent = value + '%';
document.querySelectorAll('.cube-face').forEach(face => {
face.style.background = `rgba(0, 243, 255, ${value / 100})`;
});
}
function updateAnimationSpeed(speed) {
const container = document.querySelector('.cube-container');
container.style.animationDuration = speed;
updateStatus('3dStatus', `Animation speed: ${speed}`);
}
function download3DScene() {
const opacity = document.getElementById('opacitySlider').value;
const speed = document.getElementById('speedSelect').value;
// Get computed colors for the standalone file
const cssVars = `
:root {
--neon-cyan: #00f3ff;
--dark-bg: # |