Spaces:
Running
Running
File size: 66,255 Bytes
f9b3e8c |
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 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Honeycomb Chat - Synchronized communication between prefectures">
<meta name="theme-color" content="#3b82f6">
<meta property="og:title" content="Honeycomb Chat">
<meta property="og:description" content="Real-time synchronized communication with geometric prefectures">
<meta property="og:type" content="website">
<meta property="og:url" content="https://example.com">
<meta property="og:image" content="https://example.com/honeycomb-chat-preview.png">
<title>Honeycomb Chat</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
@keyframes float {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-10px); }
}
.floating {
animation: float 6s ease-in-out infinite;
}
.shape-transition {
transition: all 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}
.chat-bubble {
clip-path: polygon(0% 0%, 100% 0%, 100% 75%, 75% 75%, 75% 100%, 50% 75%, 0% 75%);
}
.triangle {
clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
.hexagon {
clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}
.pentagon {
clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%);
}
.octagon {
clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
}
.diamond {
clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}
.pennant {
clip-path: polygon(0% 0%, 100% 50%, 0% 100%);
}
.swallowtail {
clip-path: polygon(0% 0%, 100% 0%, 100% 70%, 50% 100%, 0% 70%);
}
.burgee {
clip-path: polygon(0% 25%, 50% 0%, 100% 25%, 50% 100%);
}
.houseflag {
clip-path: polygon(0% 0%, 100% 0%, 80% 50%, 100% 100%, 0% 100%, 20% 50%);
}
.honeycomb-bg {
background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M50 0L84 25V75L50 100L16 75V25L50 0Z' fill='none' stroke='%23e5e7eb' stroke-width='0.5'/%3E%3C/svg%3E");
background-size: 60px 60px;
}
.honeycomb-cell {
clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}
.prefecture-diligence {
background: linear-gradient(135deg, #f59e0b, #d97706);
}
.prefecture-industry {
background: linear-gradient(135deg, #10b981, #059669);
}
.prefecture-harmony {
background: linear-gradient(135deg, #3b82f6, #2563eb);
}
.prefecture-aquapod {
background: linear-gradient(135deg, #06b6d4, #0891b2);
}
.prefecture-archive {
background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}
.message-diligence {
background-color: #f59e0b;
color: white;
}
.message-industry {
background-color: #10b981;
color: white;
}
.message-harmony {
background-color: #3b82f6;
color: white;
}
.message-aquapod {
background-color: #06b6d4;
color: white;
}
.message-archive {
background-color: #8b5cf6;
color: white;
}
.flag-alpha {
background: linear-gradient(135deg, white 50%, blue 50%);
}
.flag-bravo {
background: linear-gradient(red 50%, white 50%);
}
.flag-charlie {
background: linear-gradient(blue 33%, white 33%, white 66%, red 66%);
}
.flag-delta {
background: linear-gradient(90deg, yellow 50%, blue 50%);
}
.flag-echo {
background: linear-gradient(blue 33%, red 33%, red 66%, blue 66%);
}
.flag-foxtrot {
background: linear-gradient(white 50%, red 50%);
}
.wave-animation {
position: relative;
overflow: hidden;
}
.wave-animation::after {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
animation: wave 2s linear infinite;
}
@keyframes wave {
0% { transform: translateX(-100%); }
100% { transform: translateX(100%); }
}
.pulse {
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.05); }
100% { transform: scale(1); }
}
.recipient-chip {
display: inline-flex;
align-items: center;
background-color: #e5e7eb;
border-radius: 9999px;
padding: 0.25rem 0.75rem;
margin-right: 0.5rem;
margin-bottom: 0.5rem;
font-size: 0.875rem;
}
.recipient-chip button {
margin-left: 0.5rem;
color: #6b7280;
background: none;
border: none;
cursor: pointer;
}
.recipient-chip button:hover {
color: #ef4444;
}
.bell-animation {
animation: ring 0.5s ease-in-out;
}
@keyframes ring {
0% { transform: rotate(-15deg); }
25% { transform: rotate(15deg); }
50% { transform: rotate(-10deg); }
75% { transform: rotate(10deg); }
100% { transform: rotate(0deg); }
}
.bell-count {
position: absolute;
top: -5px;
right: -5px;
background-color: #f59e0b;
color: white;
border-radius: 50%;
width: 20px;
height: 20px;
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
font-weight: bold;
}
</style>
</head>
<body class="bg-gradient-to-br from-gray-50 to-blue-50 min-h-screen">
<div class="container mx-auto px-4 py-8">
<!-- Header -->
<header class="flex flex-col items-center mb-8">
<div class="flex items-center justify-center mb-4">
<div class="honeycomb-cell bg-blue-500 w-12 h-12 flex items-center justify-center mr-3">
<i class="fas fa-comment-alt text-white text-xl"></i>
</div>
<h1 class="text-3xl font-bold text-gray-800">Honeycomb Chat</h1>
</div>
<p class="text-gray-600 text-center max-w-md">Synchronized communication between prefectures. No records stored.</p>
</header>
<!-- Connection Status -->
<div class="flex justify-center mb-6">
<div id="connectionStatus" class="flex items-center bg-white rounded-full px-4 py-2 shadow-md">
<div class="w-3 h-3 rounded-full bg-gray-400 mr-2"></div>
<span class="text-sm font-medium text-gray-600">Disconnected</span>
</div>
</div>
<!-- Chat Container -->
<div class="max-w-2xl mx-auto bg-white rounded-2xl shadow-xl overflow-hidden">
<!-- Chat Header -->
<div class="bg-gradient-to-r from-blue-500 to-indigo-600 p-4 flex items-center honeycomb-bg">
<div class="octagon bg-white w-8 h-8 flex items-center justify-center mr-3">
<i class="fas fa-users text-blue-500 text-sm"></i>
</div>
<h2 class="text-white font-semibold">Prefecture Channel</h2>
<div class="ml-auto flex space-x-2">
<button id="clearBtn" class="p-1 rounded-full hover:bg-blue-400 transition">
<i class="fas fa-trash-alt text-white"></i>
</button>
<button id="syncBtn" class="p-1 rounded-full hover:bg-blue-400 transition">
<i class="fas fa-sync-alt text-white"></i>
</button>
</div>
</div>
<!-- Messages Area -->
<div id="messages" class="h-96 overflow-y-auto p-4 space-y-4 bg-gray-50 honeycomb-bg">
<div class="flex justify-center">
<div class="bg-blue-100 text-blue-800 px-4 py-2 rounded-lg max-w-xs text-center">
<p>Welcome to Honeycomb Chat! Messages disappear when you close the window.</p>
</div>
</div>
</div>
<!-- Input Area -->
<div class="p-4 border-t border-gray-200 bg-white">
<div class="flex items-center">
<div class="flex-1 relative">
<input id="messageInput" type="text" placeholder="Type a message..."
class="w-full px-4 py-3 rounded-full border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent">
<button id="sendBtn" class="absolute right-2 top-1/2 transform -translate-y-1/2 bg-blue-500 text-white rounded-full p-2 hover:bg-blue-600 transition">
<i class="fas fa-paper-plane"></i>
</button>
</div>
<div class="ml-3 flex space-x-2">
<button id="shapeBtn" class="p-2 rounded-full bg-gray-100 hover:bg-gray-200 transition">
<i class="fas fa-shapes text-gray-700"></i>
</button>
<button id="prefectureBtn" class="p-2 rounded-full bg-gray-100 hover:bg-gray-200 transition">
<i class="fas fa-flag text-gray-700"></i>
</button>
<button id="aquapodBroadcastBtn" class="p-2 rounded-full bg-cyan-100 hover:bg-cyan-200 transition hidden">
<i class="fas fa-bullhorn text-cyan-700"></i>
</button>
</div>
</div>
<div id="shapeOptions" class="hidden mt-3 grid grid-cols-4 gap-3">
<button data-shape="circle" class="w-10 h-10 rounded-full bg-blue-500 hover:bg-blue-600 transition"></button>
<button data-shape="triangle" class="w-10 h-10 bg-green-500 hover:bg-green-600 transition triangle"></button>
<button data-shape="square" class="w-10 h-10 bg-purple-500 hover:bg-purple-600 transition"></button>
<button data-shape="hexagon" class="w-10 h-10 bg-yellow-500 hover:bg-yellow-600 transition hexagon"></button>
<button data-shape="pentagon" class="w-10 h-10 bg-red-500 hover:bg-red-600 transition pentagon"></button>
<button data-shape="octagon" class="w-10 h-10 bg-pink-500 hover:bg-pink-600 transition octagon"></button>
<button data-shape="diamond" class="w-10 h-10 bg-indigo-500 hover:bg-indigo-600 transition diamond"></button>
<button data-shape="pennant" class="w-10 h-10 bg-orange-500 hover:bg-orange-600 transition pennant"></button>
<button data-shape="swallowtail" class="w-10 h-10 bg-teal-500 hover:bg-teal-600 transition swallowtail"></button>
<button data-shape="burgee" class="w-10 h-10 bg-rose-500 hover:bg-rose-600 transition burgee"></button>
<button data-shape="houseflag" class="w-10 h-10 bg-lime-500 hover:bg-lime-600 transition houseflag"></button>
<button data-shape="flag-alpha" class="w-10 h-10 flag-alpha hover:opacity-90 transition"></button>
<button data-shape="flag-bravo" class="w-10 h-10 flag-bravo hover:opacity-90 transition"></button>
<button data-shape="flag-charlie" class="w-10 h-10 flag-charlie hover:opacity-90 transition"></button>
<button data-shape="flag-delta" class="w-10 h-10 flag-delta hover:opacity-90 transition"></button>
<button data-shape="flag-echo" class="w-10 h-10 flag-echo hover:opacity-90 transition"></button>
<button data-shape="flag-foxtrot" class="w-10 h-10 flag-foxtrot hover:opacity-90 transition"></button>
<button data-shape="bell" class="w-10 h-10 bg-amber-500 hover:bg-amber-600 transition rounded-full relative">
<i class="fas fa-bell text-white"></i>
</button>
<button data-shape="food" class="w-10 h-10 bg-emerald-500 hover:bg-emerald-600 transition rounded-full">
<i class="fas fa-utensils text-white"></i>
</button>
<button data-shape="work" class="w-10 h-10 bg-slate-500 hover:bg-slate-600 transition rounded-full">
<i class="fas fa-briefcase text-white"></i>
</button>
</div>
<div id="prefectureOptions" class="hidden mt-3 grid grid-cols-5 gap-2">
<button data-prefecture="diligence" class="px-3 py-2 rounded-md prefecture-diligence text-white text-sm font-medium">Diligence</button>
<button data-prefecture="industry" class="px-3 py-2 rounded-md prefecture-industry text-white text-sm font-medium">Industry</button>
<button data-prefecture="harmony" class="px-3 py-2 rounded-md prefecture-harmony text-white text-sm font-medium">Harmony</button>
<button data-prefecture="aquapod" class="px-3 py-2 rounded-md prefecture-aquapod text-white text-sm font-medium">Aquapod</button>
<button data-prefecture="archive" class="px-3 py-2 rounded-md prefecture-archive text-white text-sm font-medium">Archive</button>
</div>
<div id="aquapodBroadcastOptions" class="hidden mt-3 bg-cyan-50 p-3 rounded-lg">
<h4 class="text-sm font-medium text-cyan-800 mb-2">Aquapod Broadcast</h4>
<div class="grid grid-cols-3 gap-2">
<button data-broadcast="alert" class="px-2 py-1 rounded-md bg-amber-100 hover:bg-amber-200 text-amber-800 text-xs font-medium">
<i class="fas fa-exclamation-triangle mr-1"></i> Alert
</button>
<button data-bbroadcast="resources" class="px-2 py-1 rounded-md bg-emerald-100 hover:bg-emerald-200 text-emerald-800 text-xs font-medium">
<i class="fas fa-fish mr-1"></i> Resources
</button>
<button data-broadcast="meeting" class="px-2 py-1 rounded-md bg-blue-100 hover:bg-blue-200 text-blue-800 text-xs font-medium">
<i class="fas fa-users mr-1"></i> Meeting
</button>
<button data-broadcast="emergency" class="px-2 py-1 rounded-md bg-red-100 hover:bg-red-200 text-red-800 text-xs font-medium">
<i class="fas fa-sos mr-1"></i> Emergency
</button>
<button data-broadcast="maintenance" class="px-2 py-1 rounded-md bg-slate-100 hover:bg-slate-200 text-slate-800 text-xs font-medium">
<i class="fas fa-tools mr-1"></i> Maintenance
</button>
<button data-broadcast="custom" class="px-2 py-1 rounded-md bg-cyan-100 hover:bg-cyan-200 text-cyan-800 text-xs font-medium">
<i class="fas fa-edit mr-1"></i> Custom
</button>
</div>
</div>
<!-- Bell Input Modal -->
<div id="bellModal" class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
<div class="bg-white rounded-lg p-6 max-w-sm w-full">
<h3 class="text-lg font-medium text-gray-900 mb-4">Send Bells</h3>
<div class="mb-4">
<label for="bellCount" class="block text-sm font-medium text-gray-700 mb-2">Number of Bells (1-8)</label>
<input type="number" id="bellCount" min="1" max="8" value="1"
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-amber-500">
</div>
<div class="mb-4">
<label for="bellMessage" class="block text-sm font-medium text-gray-700 mb-2">Optional Message</label>
<input type="text" id="bellMessage" placeholder="What are the bells for?"
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-amber-500">
</div>
<div class="flex justify-end space-x-3">
<button id="cancelBellBtn" class="px-4 py-2 bg-gray-200 text-gray-800 rounded-md hover:bg-gray-300 transition">
Cancel
</button>
<button id="confirmBellBtn" class="px-4 py-2 bg-amber-500 text-white rounded-md hover:bg-amber-600 transition">
Send Bells
</button>
</div>
</div>
</div>
</div>
</div>
<!-- User Identification -->
<div class="mt-6 flex justify-center">
<div class="bg-white rounded-lg shadow-md p-4 max-w-md w-full">
<h3 class="font-medium text-gray-700 mb-3">Prefecture Identification</h3>
<!-- Sender Information -->
<div class="mb-4 border-b pb-4">
<h4 class="text-sm font-medium text-gray-600 mb-2">Your Information</h4>
<div class="flex items-center space-x-3 mb-3">
<div id="userShape" class="w-10 h-10 rounded-full bg-blue-500 flex items-center justify-center">
<i class="fas fa-user text-white"></i>
</div>
<input id="usernameInput" type="text" placeholder="Your name"
class="flex-1 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent">
</div>
<div class="mb-3">
<label for="mmsiInput" class="block text-sm font-medium text-gray-700 mb-1">Your MMSI (Optional)</label>
<div class="relative">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<i class="fas fa-ship text-gray-400"></i>
</div>
<input id="mmsiInput" type="text" placeholder="123456789"
class="pl-10 w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
maxlength="9" pattern="\d*">
</div>
<p class="mt-1 text-xs text-gray-500">9-digit Maritime Mobile Service Identity</p>
</div>
<div id="currentPrefecture" class="text-sm font-medium text-gray-600">
Current Prefecture: <span class="text-blue-500">None selected</span>
</div>
</div>
<!-- Recipient Selection -->
<div>
<h4 class="text-sm font-medium text-gray-600 mb-2">Recipient Selection</h4>
<!-- Recipient Prefecture -->
<div class="mb-3">
<label class="block text-sm font-medium text-gray-700 mb-1">Recipient Prefecture</label>
<div class="grid grid-cols-5 gap-2">
<button data-recipient-prefecture="diligence" class="px-2 py-1 rounded-md bg-orange-100 hover:bg-orange-200 text-orange-800 text-xs font-medium">Diligence</button>
<button data-recipient-prefecture="industry" class="px-2 py-1 rounded-md bg-emerald-100 hover:bg-emerald-200 text-emerald-800 text-xs font-medium">Industry</button>
<button data-recipient-prefecture="harmony" class="px-2 py-1 rounded-md bg-blue-100 hover:bg-blue-200 text-blue-800 text-xs font-medium">Harmony</button>
<button data-recipient-prefecture="aquapod" class="px-2 py-1 rounded-md bg-cyan-100 hover:bg-cyan-200 text-cyan-800 text-xs font-medium">Aquapod</button>
<button data-recipient-prefecture="archive" class="px-2 py-1 rounded-md bg-violet-100 hover:bg-violet-200 text-violet-800 text-xs font-medium">Archive</button>
<button data-recipient-prefecture="all" class="px-2 py-1 rounded-md bg-gray-100 hover:bg-gray-200 text-gray-800 text-xs font-medium col-span-5">All Prefectures</button>
</div>
</div>
<!-- Specific Recipients -->
<div class="mb-3">
<label class="block text-sm font-medium text-gray-700 mb-1">Specific Recipients</label>
<div class="flex items-center space-x-2 mb-2">
<input id="recipientNameInput" type="text" placeholder="Recipient name"
class="flex-1 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm">
<input id="recipientMmsiInput" type="text" placeholder="MMSI"
class="w-24 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm"
maxlength="9" pattern="\d*">
<button id="addRecipientBtn" class="px-3 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600 transition">
<i class="fas fa-plus"></i>
</button>
</div>
<div id="recipientsList" class="flex flex-wrap"></div>
</div>
<!-- Current Recipients -->
<div class="text-sm font-medium text-gray-600">
Sending to: <span id="currentRecipients" class="text-blue-500">All prefectures</span>
</div>
</div>
</div>
</div>
<!-- Bell Totals Display -->
<div id="bellTotals" class="hidden fixed bottom-4 right-4 bg-white rounded-lg shadow-lg p-4 z-40">
<h3 class="font-medium text-gray-700 mb-2">Your Bell Totals</h3>
<div id="bellTotalsList" class="space-y-2">
<!-- Will be populated dynamically -->
</div>
<button id="closeBellTotals" class="mt-3 text-sm text-blue-500 hover:text-blue-700">
Close
</button>
</div>
<!-- Floating Shapes -->
<div class="fixed top-0 left-0 w-full h-full pointer-events-none overflow-hidden z-0">
<div class="absolute top-1/4 left-1/6 w-16 h-16 bg-blue-200 opacity-20 rounded-full floating shape-transition"></div>
<div class="absolute top-1/3 right-1/5 w-12 h-12 bg-indigo-200 opacity-20 triangle floating shape-transition" style="animation-delay: 1s;"></div>
<div class="absolute bottom-1/4 left-1/4 w-20 h-20 bg-purple-200 opacity-20 hexagon floating shape-transition" style="animation-delay: 2s;"></div>
<div class="absolute bottom-1/3 right-1/4 w-14 h-14 bg-pink-200 opacity-20 pentagon floating shape-transition" style="animation-delay: 3s;"></div>
<div class="absolute top-1/5 right-1/6 w-18 h-18 bg-yellow-200 opacity-20 octagon floating shape-transition" style="animation-delay: 1.5s;"></div>
<div class="absolute bottom-1/5 left-1/5 w-16 h-16 bg-green-200 opacity-20 diamond floating shape-transition" style="animation-delay: 2.5s;"></div>
<div class="absolute top-1/6 right-1/4 w-14 h-14 bg-orange-200 opacity-20 pennant floating shape-transition" style="animation-delay: 0.5s;"></div>
<div class="absolute bottom-1/6 left-1/3 w-16 h-16 bg-teal-200 opacity-20 swallowtail floating shape-transition" style="animation-delay: 1.8s;"></div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Elements
const messageInput = document.getElementById('messageInput');
const sendBtn = document.getElementById('sendBtn');
const messages = document.getElementById('messages');
const clearBtn = document.getElementById('clearBtn');
const syncBtn = document.getElementById('syncBtn');
const shapeBtn = document.getElementById('shapeBtn');
const shapeOptions = document.getElementById('shapeOptions');
const prefectureBtn = document.getElementById('prefectureBtn');
const prefectureOptions = document.getElementById('prefectureOptions');
const aquapodBroadcastBtn = document.getElementById('aquapodBroadcastBtn');
const aquapodBroadcastOptions = document.getElementById('aquapodBroadcastOptions');
const userShape = document.getElementById('userShape');
const usernameInput = document.getElementById('usernameInput');
const mmsiInput = document.getElementById('mmsiInput');
const connectionStatus = document.getElementById('connectionStatus');
const currentPrefectureDisplay = document.getElementById('currentPrefecture').querySelector('span');
const recipientNameInput = document.getElementById('recipientNameInput');
const recipientMmsiInput = document.getElementById('recipientMmsiInput');
const addRecipientBtn = document.getElementById('addRecipientBtn');
const recipientsList = document.getElementById('recipientsList');
const currentRecipientsDisplay = document.getElementById('currentRecipients');
const bellModal = document.getElementById('bellModal');
const bellCountInput = document.getElementById('bellCount');
const bellMessageInput = document.getElementById('bellMessage');
const confirmBellBtn = document.getElementById('confirmBellBtn');
const cancelBellBtn = document.getElementById('cancelBellBtn');
const bellTotals = document.getElementById('bellTotals');
const bellTotalsList = document.getElementById('bellTotalsList');
const closeBellTotals = document.getElementById('closeBellTotals');
// State
let currentShape = 'circle';
let currentPrefecture = null;
let username = 'User' + Math.floor(Math.random() * 1000);
let mmsi = '';
let isConnected = false;
let channel = null;
let recipientPrefecture = 'all';
let specificRecipients = [];
let bellTransactions = []; // Stores all bell transactions
let bellBalances = {}; // Stores current bell balances by recipient MMSI
// Initialize
usernameInput.value = username;
updateConnectionStatus(false);
updateRecipientsDisplay();
// Event Listeners
sendBtn.addEventListener('click', sendMessage);
messageInput.addEventListener('keypress', function(e) {
if (e.key === 'Enter') sendMessage();
});
clearBtn.addEventListener('click', clearMessages);
syncBtn.addEventListener('click', toggleConnection);
shapeBtn.addEventListener('click', toggleShapeOptions);
prefectureBtn.addEventListener('click', togglePrefectureOptions);
aquapodBroadcastBtn.addEventListener('click', toggleAquapodBroadcastOptions);
addRecipientBtn.addEventListener('click', addRecipient);
confirmBellBtn.addEventListener('click', confirmBellTransaction);
cancelBellBtn.addEventListener('click', cancelBellTransaction);
closeBellTotals.addEventListener('click', () => bellTotals.classList.add('hidden'));
// Toggle bell totals display when clicking on bell shape
document.querySelector('[data-shape="bell"]').addEventListener('click', function() {
if (currentShape === 'bell') {
updateBellTotalsDisplay();
bellTotals.classList.toggle('hidden');
}
});
// Recipient prefecture selection
document.querySelectorAll('[data-recipient-prefecture]').forEach(btn => {
btn.addEventListener('click', function() {
recipientPrefecture = this.dataset.recipientPrefecture;
specificRecipients = []; // Clear specific recipients when changing prefecture
updateRecipientsList();
updateRecipientsDisplay();
// Update active state
document.querySelectorAll('[data-recipient-prefecture]').forEach(b => {
b.classList.remove('bg-gray-200', 'text-gray-800');
const color = getColorForPrefecture(b.dataset.recipientPrefecture);
if (b.dataset.recipientPrefecture === 'all') {
b.classList.add('bg-gray-100', 'hover:bg-gray-200', 'text-gray-800');
} else {
b.classList.add(`bg-${color}-100`, `hover:bg-${color}-200`, `text-${color}-800`);
}
});
// Set active state for selected button
if (recipientPrefecture === 'all') {
this.classList.add('bg-gray-200', 'text-gray-800');
} else {
const color = getColorForPrefecture(recipientPrefecture);
this.classList.add(`bg-${color}-200`, `text-${color}-900`);
}
});
});
// Shape selection
document.querySelectorAll('#shapeOptions button').forEach(btn => {
btn.addEventListener('click', function() {
currentShape = this.dataset.shape;
// Special handling for bell shape
if (currentShape === 'bell') {
showBellModal();
} else {
updateUserShape();
toggleShapeOptions();
}
});
});
// Prefecture selection
document.querySelectorAll('#prefectureOptions button').forEach(btn => {
btn.addEventListener('click', function() {
currentPrefecture = this.dataset.prefecture;
currentPrefectureDisplay.textContent = this.textContent;
currentPrefectureDisplay.className = `text-${getColorForPrefecture(currentPrefecture)}-500`;
// Show/hide Aquapod broadcast button based on selected prefecture
if (currentPrefecture === 'aquapod') {
aquapodBroadcastBtn.classList.remove('hidden');
} else {
aquapodBroadcastBtn.classList.add('hidden');
aquapodBroadcastOptions.classList.add('hidden');
}
togglePrefectureOptions();
});
});
// Aquapod broadcast selection
document.querySelectorAll('#aquapodBroadcastOptions button').forEach(btn => {
btn.addEventListener('click', function() {
const broadcastType = this.dataset.broadcast;
let message = '';
switch(broadcastType) {
case 'alert':
message = "Aquapod Alert: All prefectures please be advised of potential marine disturbances in sector 4.";
break;
case 'resources':
message = "Aquapod Resource Update: New marine resources available for collection at buoy markers 12-15.";
break;
case 'meeting':
message = "Aquapod Meeting: All prefecture representatives required for monthly coordination at the central hub.";
break;
case 'emergency':
message = "Aquapod Emergency: Immediate assistance required at coordinates 34.5°N, 72.1°W. All available units respond.";
break;
case 'maintenance':
message = "Aquapod Maintenance: Desalination systems will be offline for scheduled maintenance tomorrow 0800-1200.";
break;
case 'custom':
message = prompt("Enter your broadcast message:", "Aquapod Broadcast: ");
if (!message) return;
break;
}
// Send to all prefectures
sendBroadcastMessage(message);
toggleAquapodBroadcastOptions();
});
});
usernameInput.addEventListener('change', function() {
username = this.value || 'Anonymous';
});
mmsiInput.addEventListener('input', function() {
// Validate MMSI input (only numbers, max 9 digits)
this.value = this.value.replace(/\D/g, '').slice(0, 9);
mmsi = this.value;
});
recipientMmsiInput.addEventListener('input', function() {
// Validate MMSI input (only numbers, max 9 digits)
this.value = this.value.replace(/\D/g, '').slice(0, 9);
});
// Functions
function sendMessage() {
const message = messageInput.value.trim();
if (!message) return;
// Create and display message with recipient info
let recipientInfo = '';
if (recipientPrefecture !== 'all' || specificRecipients.length > 0) {
recipientInfo = ` [To: ${getRecipientDescription()}]`;
}
displayMessage(message + recipientInfo, username, currentShape, currentPrefecture, true, mmsi);
// In a real app, this would broadcast to the selected recipients
// For demo purposes, we'll simulate responses from the selected prefecture(s)
setTimeout(() => {
if (isConnected) {
const respondingPrefectures = getRespondingPrefectures();
respondingPrefectures.forEach((prefecture, index) => {
setTimeout(() => {
displayMessage(
`${getPrefectureResponse(message, prefecture)}`,
`Prefecture ${prefecture.charAt(0).toUpperCase() + prefecture.slice(1)}`,
getRandomShape(),
prefecture,
false,
generateRandomMMSI()
);
}, 1000 + (index * 800));
});
}
}, 1000);
// Clear input
messageInput.value = '';
}
function sendBroadcastMessage(message) {
if (!message) return;
// Display the broadcast message with special styling
displayMessage(message, "Aquapod Broadcast", "wave", "aquapod", true, mmsi);
// Simulate responses from all prefectures
if (isConnected) {
const prefectures = ['diligence', 'industry', 'harmony', 'archive'];
prefectures.forEach((prefecture, index) => {
setTimeout(() => {
displayMessage(
`Prefecture ${prefecture.charAt(0).toUpperCase() + prefecture.slice(1)} acknowledges broadcast.`,
`Prefecture ${prefecture.charAt(0).toUpperCase() + prefecture.slice(1)}`,
getRandomShape(),
prefecture,
false,
generateRandomMMSI()
);
}, 1500 + (index * 800));
});
}
}
function addRecipient() {
const name = recipientNameInput.value.trim();
const mmsi = recipientMmsiInput.value.trim();
if (!name) return;
specificRecipients.push({
name: name,
mmsi: mmsi
});
recipientNameInput.value = '';
recipientMmsiInput.value = '';
updateRecipientsList();
updateRecipientsDisplay();
// If we have specific recipients, switch to "specific" mode
if (specificRecipients.length > 0 && recipientPrefecture !== 'specific') {
recipientPrefecture = 'specific';
updateRecipientsDisplay();
}
}
function removeRecipient(index) {
specificRecipients.splice(index, 1);
updateRecipientsList();
updateRecipientsDisplay();
// If no more specific recipients, switch back to "all"
if (specificRecipients.length === 0 && recipientPrefecture === 'specific') {
recipientPrefecture = 'all';
updateRecipientsDisplay();
}
}
function updateRecipientsList() {
recipientsList.innerHTML = '';
specificRecipients.forEach((recipient, index) => {
const chip = document.createElement('div');
chip.className = 'recipient-chip';
let chipText = recipient.name;
if (recipient.mmsi) {
chipText += ` (MMSI: ${recipient.mmsi})`;
}
chip.innerHTML = `
<span>${chipText}</span>
<button onclick="removeRecipient(${index})">
<i class="fas fa-times"></i>
</button>
`;
recipientsList.appendChild(chip);
});
}
function updateRecipientsDisplay() {
currentRecipientsDisplay.textContent = getRecipientDescription();
}
function getRecipientDescription() {
if (recipientPrefecture === 'all') {
return 'All prefectures';
} else if (recipientPrefecture === 'specific') {
if (specificRecipients.length === 0) {
return 'No recipients selected';
} else if (specificRecipients.length === 1) {
return specificRecipients[0].name + (specificRecipients[0].mmsi ? ` (MMSI: ${specificRecipients[0].mmsi})` : '');
} else {
return `${specificRecipients.length} specific recipients`;
}
} else {
return `Prefecture ${recipientPrefecture.charAt(0).toUpperCase() + recipientPrefecture.slice(1)}`;
}
}
function getRespondingPrefectures() {
if (recipientPrefecture === 'all') {
return ['diligence', 'industry', 'harmony', 'archive'];
} else if (recipientPrefecture === 'specific') {
return specificRecipients.length > 0 ?
[specificRecipients[0].name.toLowerCase().replace(/\s+/g, '-')] :
[];
} else {
return [recipientPrefecture];
}
}
function displayMessage(text, sender, shape, prefecture, isCurrentUser, mmsi = '') {
const messageDiv = document.createElement('div');
messageDiv.className = `flex ${isCurrentUser ? 'justify-end' : 'justify-start'}`;
const shapeDiv = document.createElement('div');
shapeDiv.className = `w-8 h-8 flex-shrink-0 flex items-center justify-center mr-2 ${isCurrentUser ? 'order-last ml-2' : 'mr-2'}`;
// Special case for Aquapod broadcast wave effect
if (shape === 'wave') {
shapeDiv.className += ' wave-animation bg-cyan-500 rounded-full';
const icon = document.createElement('i');
icon.className = 'fas fa-bullhorn text-white';
shapeDiv.appendChild(icon);
}
// Apply shape and special styling for flags and icons
else if (shape.startsWith('flag-')) {
shapeDiv.className += ` ${shape}`;
const icon = document.createElement('i');
icon.className = `fas fa-flag text-xs ${getFlagIconColor(shape)}`;
shapeDiv.appendChild(icon);
}
else if (shape === 'bell' || shape === 'food' || shape === 'work') {
shapeDiv.className += ` rounded-full bg-${getColorForShape(shape)}-500`;
const icon = document.createElement('i');
icon.className = `fas fa-${shape} text-white text-xs`;
shapeDiv.appendChild(icon);
}
else {
shapeDiv.classList.add('bg-' + getColorForShape(shape) + '-500');
if (shape !== 'circle') {
shapeDiv.classList.add(shape);
} else {
shapeDiv.classList.add('rounded-full');
}
const icon = document.createElement('i');
icon.className = `fas fa-${shape === 'circle' ? 'user' : 'shapes'} text-white text-xs`;
shapeDiv.appendChild(icon);
}
const contentDiv = document.createElement('div');
contentDiv.className = `max-w-xs ${isCurrentUser ? 'text-right' : 'text-left'}`;
const senderSpan = document.createElement('span');
senderSpan.className = `text-xs font-medium ${isCurrentUser ? 'text-blue-600' : 'text-gray-600'}`;
// Add MMSI to sender if provided
if (mmsi) {
senderSpan.innerHTML = `${sender} <span class="text-xs text-gray-500">(MMSI: ${mmsi})</span>`;
} else {
senderSpan.textContent = sender;
}
const textDiv = document.createElement('div');
textDiv.className = `mt-1 px-4 py-2 rounded-lg ${prefecture ? 'message-' + prefecture : 'bg-blue-500 text-white'} ${shape === 'wave' ? 'pulse' : ''}`;
textDiv.textContent = text;
contentDiv.appendChild(senderSpan);
contentDiv.appendChild(textDiv);
messageDiv.appendChild(isCurrentUser ? contentDiv : shapeDiv);
messageDiv.appendChild(isCurrentUser ? shapeDiv : contentDiv);
messages.appendChild(messageDiv);
messages.scrollTop = messages.scrollHeight;
}
function clearMessages() {
messages.innerHTML = `
<div class="flex justify-center">
<div class="bg-blue-100 text-blue-800 px-4 py-2 rounded-lg max-w-xs text-center">
<p>Chat cleared. Start a new conversation!</p>
</div>
</div>
`;
}
function toggleConnection() {
isConnected = !isConnected;
updateConnectionStatus(isConnected);
if (isConnected) {
// In a real app, this would establish a connection
displaySystemMessage('Connected to prefecture network. Messages are now synchronized.');
} else {
displaySystemMessage('Disconnected from prefecture network. Messages are no longer synchronized.');
}
}
function updateConnectionStatus(connected) {
const statusDot = connectionStatus.querySelector('div');
const statusText = connectionStatus.querySelector('span');
if (connected) {
statusDot.className = 'w-3 h-3 rounded-full bg-green-500 mr-2';
statusText.textContent = 'Connected';
syncBtn.innerHTML = '<i class="fas fa-unlink text-white"></i>';
} else {
statusDot.className = 'w-3 h-3 rounded-full bg-gray-400 mr-2';
statusText.textContent = 'Disconnected';
syncBtn.innerHTML = '<i class="fas fa-link text-white"></i>';
}
}
function toggleShapeOptions() {
shapeOptions.classList.toggle('hidden');
// Hide other options if visible
if (!prefectureOptions.classList.contains('hidden')) {
prefectureOptions.classList.add('hidden');
}
if (!aquapodBroadcastOptions.classList.contains('hidden')) {
aquapodBroadcastOptions.classList.add('hidden');
}
}
function togglePrefectureOptions() {
prefectureOptions.classList.toggle('hidden');
// Hide other options if visible
if (!shapeOptions.classList.contains('hidden')) {
shapeOptions.classList.add('hidden');
}
if (!aquapodBroadcastOptions.classList.contains('hidden')) {
aquapodBroadcastOptions.classList.add('hidden');
}
}
function toggleAquapodBroadcastOptions() {
if (currentPrefecture === 'aquapod') {
aquapodBroadcastOptions.classList.toggle('hidden');
// Hide other options if visible
if (!shapeOptions.classList.contains('hidden')) {
shapeOptions.classList.add('hidden');
}
if (!prefectureOptions.classList.contains('hidden')) {
prefectureOptions.classList.add('hidden');
}
}
}
function updateUserShape() {
// Clear all shape classes
userShape.className = 'w-10 h-10 flex items-center justify-center';
// Special case for icons
if (currentShape === 'bell' || currentShape === 'food' || currentShape === 'work') {
userShape.className += ` rounded-full bg-${getColorForShape(currentShape)}-500`;
const icon = userShape.querySelector('i') || document.createElement('i');
icon.className = `fas fa-${currentShape} text-white`;
if (!userShape.querySelector('i')) {
userShape.appendChild(icon);
}
}
// Apply shape and special styling for flags
else if (currentShape.startsWith('flag-')) {
userShape.className += ` ${currentShape}`;
const icon = userShape.querySelector('i') || document.createElement('i');
icon.className = `fas fa-flag ${getFlagIconColor(currentShape)}`;
if (!userShape.querySelector('i')) {
userShape.appendChild(icon);
}
} else {
userShape.classList.add('bg-' + getColorForShape(currentShape) + '-500');
if (currentShape !== 'circle') {
userShape.classList.add(currentShape);
} else {
userShape.classList.add('rounded-full');
}
// Update icon
const icon = userShape.querySelector('i') || document.createElement('i');
icon.className = `fas fa-${currentShape === 'circle' ? 'user' : 'shapes'} text-white`;
if (!userShape.querySelector('i')) {
userShape.appendChild(icon);
}
}
}
function displaySystemMessage(text) {
const div = document.createElement('div');
div.className = 'flex justify-center';
div.innerHTML = `
<div class="bg-gray-100 text-gray-600 px-4 py-2 rounded-lg max-w-xs text-center text-sm">
<p>${text}</p>
</div>
`;
messages.appendChild(div);
messages.scrollTop = messages.scrollHeight;
}
function getRandomShape() {
const shapes = [
'circle', 'triangle', 'square', 'hexagon', 'pentagon',
'octagon', 'diamond', 'pennant', 'swallowtail', 'burgee',
'houseflag', 'flag-alpha', 'flag-bravo', 'flag-charlie',
'flag-delta', 'flag-echo', 'flag-foxtrot', 'bell', 'food', 'work'
];
return shapes[Math.floor(Math.random() * shapes.length)];
}
function getRandomPrefecture() {
const prefectures = ['diligence', 'industry', 'harmony', 'aquapod', 'archive'];
return prefectures[Math.floor(Math.random() * prefectures.length)];
}
function generateRandomMMSI() {
// Generate a random 9-digit MMSI for simulated responses
return Math.floor(100000000 + Math.random() * 900000000).toString();
}
function getColorForShape(shape) {
const colors = {
'circle': 'blue',
'triangle': 'green',
'square': 'purple',
'hexagon': 'yellow',
'pentagon': 'red',
'octagon': 'pink',
'diamond': 'indigo',
'pennant': 'orange',
'swallowtail': 'teal',
'burgee': 'rose',
'houseflag': 'lime',
'bell': 'amber',
'food': 'emerald',
'work': 'slate'
};
return colors[shape] || 'blue';
}
function getColorForPrefecture(prefecture) {
const colors = {
'diligence': 'orange',
'industry': 'emerald',
'harmony': 'blue',
'aquapod': 'cyan',
'archive': 'violet'
};
return colors[prefecture] || 'blue';
}
function getFlagIconColor(flagShape) {
// Determine appropriate icon color based on flag colors
const flagColors = {
'flag-alpha': 'text-blue-600', // White/Blue - blue text for visibility
'flag-bravo': 'text-red-600', // Red/White - red text
'flag-charlie': 'text-white', // Blue/White/Red - white for contrast
'flag-delta': 'text-blue-600', // Yellow/Blue - blue text
'flag-echo': 'text-white', // Blue/Red/Blue - white for contrast
'flag-foxtrot': 'text-red-600' // White/Red - red text
};
return flagColors[flagShape] || 'text-white';
}
function getPrefectureResponse(message, prefecture) {
const responses = {
'diligence': `Regarding "${message}", our workers are already on it with maximum efficiency.`,
'industry': `"${message}" noted. Our factories will process this request immediately.`,
'harmony': `We appreciate your message about "${message}". Let's work together peacefully.`,
'aquapod': `"${message}" received. Our marine systems are analyzing this input.`,
'archive': `"${message}" has been recorded in our permanent knowledge banks.`
};
return responses[prefecture] || `Prefecture acknowledges: "${message}"`;
}
// Bell system functions
function showBellModal() {
bellModal.classList.remove('hidden');
bellCountInput.value = '1';
bellMessageInput.value = '';
}
function cancelBellTransaction() {
bellModal.classList.add('hidden');
toggleShapeOptions();
}
function confirmBellTransaction() {
const bellCount = parseInt(bellCountInput.value);
const bellMessage = bellMessageInput.value.trim();
if (bellCount < 1 || bellCount > 8) {
alert('Please enter a number between 1 and 8');
return;
}
// Get recipient MMSI (if specific recipient is selected)
let recipientMmsi = '';
if (recipientPrefecture === 'specific' && specificRecipients.length > 0) {
recipientMmsi = specificRecipients[0].mmsi;
}
// Record the transaction
const transaction = {
senderMmsi: mmsi,
recipientMmsi: recipientMmsi,
recipientPrefecture: recipientPrefecture,
bellCount: bellCount,
message: bellMessage,
timestamp: new Date().toISOString()
};
bellTransactions.push(transaction);
// Update bell balances
if (recipientMmsi) {
if (!bellBalances[recipientMmsi]) {
bellBalances[recipientMmsi] = 0;
}
bellBalances[recipientMmsi] += bellCount;
}
// Display the bell message
let displayMessage = `Sent ${bellCount} bell${bellCount !== 1 ? 's' : ''}`;
if (bellMessage) {
displayMessage += ` for: ${bellMessage}`;
}
if (recipientPrefecture === 'specific' && specificRecipients.length > 0) {
displayMessage += ` to ${specificRecipients[0].name}`;
if (recipientMmsi) {
displayMessage += ` (MMSI: ${recipientMmsi})`;
}
} else if (recipientPrefecture !== 'all') {
displayMessage += ` to Prefecture ${recipientPrefecture.charAt(0).toUpperCase() + recipientPrefecture.slice(1)}`;
}
displayMessage(displayMessage, username, 'bell', currentPrefecture, true, mmsi);
// Simulate response if connected
if (isConnected) {
setTimeout(() => {
const respondingPrefectures = getRespondingPrefectures();
respondingPrefectures.forEach((prefecture, index) => {
setTimeout(() => {
let responseMessage = '';
if (recipientPrefecture === 'specific' && specificRecipients.length > 0) {
responseMessage = `${specificRecipients[0].name} received ${bellCount} bell${bellCount !== 1 ? 's' : ''}`;
if (recipientMmsi) {
responseMessage += ` (Total: ${bellBalances[recipientMmsi] || bellCount} bells)`;
}
} else {
responseMessage = `Prefecture ${prefecture.charAt(0).toUpperCase() + prefecture.slice(1)} received ${bellCount} bell${bellCount !== 1 ? 's' : ''}`;
}
if (bellMessage) {
responseMessage += ` for: ${bellMessage}`;
}
displayMessage(
responseMessage,
recipientPrefecture === 'specific' && specificRecipients.length > 0 ?
specificRecipients[0].name :
`Prefecture ${prefecture.charAt(0).toUpperCase() + prefecture.slice(1)}`,
'bell',
prefecture,
false,
recipientPrefecture === 'specific' && specificRecipients.length > 0 ?
specificRecipients[0].mmsi || generateRandomMMSI() :
generateRandomMMSI()
);
}, 1000 + (index * 800));
});
}, 1000);
}
// Close modal and update UI
bellModal.classList.add('hidden');
updateUserShape();
toggleShapeOptions();
}
function updateBellTotalsDisplay() {
bellTotalsList.innerHTML = '';
if (Object.keys(bellBalances).length === 0) {
bellTotalsList.innerHTML = '<p class="text-sm text-gray-500">No bell transactions yet</p>';
return;
}
// Group transactions by recipient
const recipientGroups = {};
bellTransactions.forEach(tx => {
if (tx.recipientMmsi) {
if (!recipientGroups[tx.recipientMmsi]) {
recipientGroups[tx.recipientMmsi] = {
total: 0,
transactions: []
};
}
recipientGroups[tx.recipientMmsi].total += tx.bellCount;
recipientGroups[tx.recipientMmsi].transactions.push(tx);
}
});
// Display totals for each recipient
for (const [mmsi, data] of Object.entries(recipientGroups)) {
const recipientDiv = document.createElement('div');
recipientDiv.className = 'border-b pb-2 mb-2';
// Find recipient name if available
let recipientName = 'Unknown';
const recipient = specificRecipients.find(r => r.mmsi === mmsi);
if (recipient) {
recipientName = recipient.name;
}
recipientDiv.innerHTML = `
<div class="flex justify-between items-center">
<div>
<h4 class="text-sm font-medium">${recipientName}</h4>
<p class="text-xs text-gray-500">MMSI: ${mmsi}</p>
</div>
<div class="flex items-center">
<div class="w-6 h-6 rounded-full bg-amber-500 flex items-center justify-center mr-2">
<i class="fas fa-bell text-white text-xs"></i>
</div>
<span class="font-medium">${data.total}</span>
</div>
</div>
`;
// Add transaction details (collapsible)
const detailsDiv = document.createElement('div');
detailsDiv.className = 'mt-2 hidden';
data.transactions.forEach(tx => {
const txDiv = document.createElement('div');
txDiv.className = 'text-xs py-1 border-t border-gray-100';
txDiv.innerHTML = `
<div class="flex justify-between">
<span>${new Date(tx.timestamp).toLocaleTimeString()}</span>
<span class="font-medium">${tx.bellCount} bell${tx.bellCount !== 1 ? 's' : ''}</span>
</div>
${tx.message ? `<div class="text-gray-500 mt-1">"${tx.message}"</div>` : ''}
`;
detailsDiv.appendChild(txDiv);
});
recipientDiv.addEventListener('click', () => {
detailsDiv.classList.toggle('hidden');
});
recipientDiv.appendChild(detailsDiv);
bellTotalsList.appendChild(recipientDiv);
}
}
// Make removeRecipient function available globally for the onclick handler
window.removeRecipient = removeRecipient;
// Simulate metadata synchronization (in a real app, this would use WebRTC or similar)
setInterval(() => {
if (isConnected) {
// Update metadata tags to simulate synchronization
document.querySelector('meta[name="theme-color"]').content =
`#${Math.floor(Math.random()*16777215).toString(16)}`;
}
}, 5000);
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=privateuserh/honeycombxhat-beta1-04" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |