@ywkrlerche/richardwho 1.0.36 → 1.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app.js +1163 -333
- package/config.js +10 -0
- package/games.json +1 -1
- package/index.html +133 -75
- package/logos/gn-101.webp +0 -0
- package/logos/gn-105.webp +0 -0
- package/logos/gn-107.webp +0 -0
- package/logos/gn-110.webp +0 -0
- package/logos/gn-113.webp +0 -0
- package/logos/gn-115.webp +0 -0
- package/logos/gn-116.webp +0 -0
- package/logos/gn-118.webp +0 -0
- package/logos/gn-120.webp +0 -0
- package/logos/gn-121.webp +0 -0
- package/logos/gn-122.webp +0 -0
- package/logos/gn-127.webp +0 -0
- package/logos/gn-128.webp +0 -0
- package/logos/gn-13.webp +0 -0
- package/logos/gn-130.webp +0 -0
- package/logos/gn-14.webp +0 -0
- package/logos/gn-148.webp +0 -0
- package/logos/gn-149.webp +0 -0
- package/logos/gn-15.webp +0 -0
- package/logos/gn-150.webp +0 -0
- package/logos/gn-151.webp +0 -0
- package/logos/gn-152.webp +0 -0
- package/logos/gn-153.webp +0 -0
- package/logos/gn-156.webp +0 -0
- package/logos/gn-158.webp +0 -0
- package/logos/gn-159.webp +0 -0
- package/logos/gn-16.webp +0 -0
- package/logos/gn-162.webp +0 -0
- package/logos/gn-165.webp +0 -0
- package/logos/gn-167.webp +0 -0
- package/logos/gn-17.webp +0 -0
- package/logos/gn-173.webp +0 -0
- package/logos/gn-174.webp +0 -0
- package/logos/gn-175.webp +0 -0
- package/logos/gn-178.webp +0 -0
- package/logos/gn-179.webp +0 -0
- package/logos/gn-18.webp +0 -0
- package/logos/gn-180.webp +0 -0
- package/logos/gn-188.webp +0 -0
- package/logos/gn-19.webp +0 -0
- package/logos/gn-190.webp +0 -0
- package/logos/gn-192.webp +0 -0
- package/logos/gn-193.webp +0 -0
- package/logos/gn-197.webp +0 -0
- package/logos/gn-199.webp +0 -0
- package/logos/gn-20.webp +0 -0
- package/logos/gn-202.webp +0 -0
- package/logos/gn-203.webp +0 -0
- package/logos/gn-204.webp +0 -0
- package/logos/gn-205.webp +0 -0
- package/logos/gn-207.webp +0 -0
- package/logos/gn-208.webp +0 -0
- package/logos/gn-21.webp +0 -0
- package/logos/gn-210.webp +0 -0
- package/logos/gn-22.webp +0 -0
- package/logos/gn-239.webp +0 -0
- package/logos/gn-240.webp +0 -0
- package/logos/gn-242.webp +0 -0
- package/logos/gn-25.webp +0 -0
- package/logos/gn-253.webp +0 -0
- package/logos/gn-255.webp +0 -0
- package/logos/gn-256.webp +0 -0
- package/logos/gn-258.webp +0 -0
- package/logos/gn-259.webp +0 -0
- package/logos/gn-26.webp +0 -0
- package/logos/gn-260.webp +0 -0
- package/logos/gn-273.webp +0 -0
- package/logos/gn-279.webp +0 -0
- package/logos/gn-28.webp +0 -0
- package/logos/gn-280.webp +0 -0
- package/logos/gn-281.webp +0 -0
- package/logos/gn-282.webp +0 -0
- package/logos/gn-29.webp +0 -0
- package/logos/gn-30.webp +0 -0
- package/logos/gn-300.webp +0 -0
- package/logos/gn-302.webp +0 -0
- package/logos/gn-304.webp +0 -0
- package/logos/gn-306.webp +0 -0
- package/logos/gn-308.webp +0 -0
- package/logos/gn-309.webp +0 -0
- package/logos/gn-31.webp +0 -0
- package/logos/gn-311.webp +0 -0
- package/logos/gn-312.webp +0 -0
- package/logos/gn-313.webp +0 -0
- package/logos/gn-315.webp +0 -0
- package/logos/gn-316.webp +0 -0
- package/logos/gn-317.webp +0 -0
- package/logos/gn-318.webp +0 -0
- package/logos/gn-319.webp +0 -0
- package/logos/gn-32.webp +0 -0
- package/logos/gn-320.webp +0 -0
- package/logos/gn-321.webp +0 -0
- package/logos/gn-322.webp +0 -0
- package/logos/gn-323.webp +0 -0
- package/logos/gn-324.webp +0 -0
- package/logos/gn-325.webp +0 -0
- package/logos/gn-326.webp +0 -0
- package/logos/gn-327.webp +0 -0
- package/logos/gn-328.webp +0 -0
- package/logos/gn-329.webp +0 -0
- package/logos/gn-335.webp +0 -0
- package/logos/gn-336.webp +0 -0
- package/logos/gn-337.webp +0 -0
- package/logos/gn-344.webp +0 -0
- package/logos/gn-345.webp +0 -0
- package/logos/gn-346.webp +0 -0
- package/logos/gn-347.webp +0 -0
- package/logos/gn-349.webp +0 -0
- package/logos/gn-351.webp +0 -0
- package/logos/gn-352.webp +0 -0
- package/logos/gn-354.webp +0 -0
- package/logos/gn-358.webp +0 -0
- package/logos/gn-359.webp +0 -0
- package/logos/gn-361.webp +0 -0
- package/logos/gn-363.webp +0 -0
- package/logos/gn-364.webp +0 -0
- package/logos/gn-365.webp +0 -0
- package/logos/gn-366.webp +0 -0
- package/logos/gn-367.webp +0 -0
- package/logos/gn-368.webp +0 -0
- package/logos/gn-37.webp +0 -0
- package/logos/gn-370.webp +0 -0
- package/logos/gn-371.webp +0 -0
- package/logos/gn-372.webp +0 -0
- package/logos/gn-373.webp +0 -0
- package/logos/gn-374.webp +0 -0
- package/logos/gn-375.webp +0 -0
- package/logos/gn-377.webp +0 -0
- package/logos/gn-378.webp +0 -0
- package/logos/gn-379.webp +0 -0
- package/logos/gn-380.webp +0 -0
- package/logos/gn-382.webp +0 -0
- package/logos/gn-383.webp +0 -0
- package/logos/gn-384.webp +0 -0
- package/logos/gn-386.webp +0 -0
- package/logos/gn-389.webp +0 -0
- package/logos/gn-391.webp +0 -0
- package/logos/gn-392.webp +0 -0
- package/logos/gn-393.webp +0 -0
- package/logos/gn-394.webp +0 -0
- package/logos/gn-397.webp +0 -0
- package/logos/gn-398.webp +0 -0
- package/logos/gn-399.webp +0 -0
- package/logos/gn-400.webp +0 -0
- package/logos/gn-401.webp +0 -0
- package/logos/gn-403.webp +0 -0
- package/logos/gn-405.webp +0 -0
- package/logos/gn-409.webp +0 -0
- package/logos/gn-410.webp +0 -0
- package/logos/gn-411.webp +0 -0
- package/logos/gn-413.webp +0 -0
- package/logos/gn-414.webp +0 -0
- package/logos/gn-415.webp +0 -0
- package/logos/gn-417.webp +0 -0
- package/logos/gn-418.webp +0 -0
- package/logos/gn-42.webp +0 -0
- package/logos/gn-420.webp +0 -0
- package/logos/gn-428.webp +0 -0
- package/logos/gn-429.webp +0 -0
- package/logos/gn-43.webp +0 -0
- package/logos/gn-431.webp +0 -0
- package/logos/gn-432.webp +0 -0
- package/logos/gn-433.webp +0 -0
- package/logos/gn-434.webp +0 -0
- package/logos/gn-437.webp +0 -0
- package/logos/gn-440.webp +0 -0
- package/logos/gn-442.webp +0 -0
- package/logos/gn-443.webp +0 -0
- package/logos/gn-448.webp +0 -0
- package/logos/gn-449.webp +0 -0
- package/logos/gn-45.webp +0 -0
- package/logos/gn-451.webp +0 -0
- package/logos/gn-452.webp +0 -0
- package/logos/gn-453.webp +0 -0
- package/logos/gn-455.webp +0 -0
- package/logos/gn-456.webp +0 -0
- package/logos/gn-459.webp +0 -0
- package/logos/gn-46.webp +0 -0
- package/logos/gn-460.webp +0 -0
- package/logos/gn-461.webp +0 -0
- package/logos/gn-462.webp +0 -0
- package/logos/gn-463.webp +0 -0
- package/logos/gn-466.webp +0 -0
- package/logos/gn-469.webp +0 -0
- package/logos/gn-47.webp +0 -0
- package/logos/gn-471.webp +0 -0
- package/logos/gn-474.webp +0 -0
- package/logos/gn-475.webp +0 -0
- package/logos/gn-476.webp +0 -0
- package/logos/gn-477.webp +0 -0
- package/logos/gn-478.webp +0 -0
- package/logos/gn-479.webp +0 -0
- package/logos/gn-48.webp +0 -0
- package/logos/gn-480.webp +0 -0
- package/logos/gn-481.webp +0 -0
- package/logos/gn-482.webp +0 -0
- package/logos/gn-483.webp +0 -0
- package/logos/gn-484.webp +0 -0
- package/logos/gn-485.webp +0 -0
- package/logos/gn-486.webp +0 -0
- package/logos/gn-487.webp +0 -0
- package/logos/gn-488.webp +0 -0
- package/logos/gn-489.webp +0 -0
- package/logos/gn-492.webp +0 -0
- package/logos/gn-495.webp +0 -0
- package/logos/gn-496.webp +0 -0
- package/logos/gn-497.webp +0 -0
- package/logos/gn-498.webp +0 -0
- package/logos/gn-499.webp +0 -0
- package/logos/gn-500.webp +0 -0
- package/logos/gn-502.webp +0 -0
- package/logos/gn-503.webp +0 -0
- package/logos/gn-504.webp +0 -0
- package/logos/gn-509.webp +0 -0
- package/logos/gn-511.webp +0 -0
- package/logos/gn-512.webp +0 -0
- package/logos/gn-513.webp +0 -0
- package/logos/gn-514.webp +0 -0
- package/logos/gn-516.webp +0 -0
- package/logos/gn-518.webp +0 -0
- package/logos/gn-519.webp +0 -0
- package/logos/gn-520.webp +0 -0
- package/logos/gn-521.webp +0 -0
- package/logos/gn-522.webp +0 -0
- package/logos/gn-525.webp +0 -0
- package/logos/gn-526.webp +0 -0
- package/logos/gn-527.webp +0 -0
- package/logos/gn-529.webp +0 -0
- package/logos/gn-530.webp +0 -0
- package/logos/gn-531.webp +0 -0
- package/logos/gn-532.webp +0 -0
- package/logos/gn-534.webp +0 -0
- package/logos/gn-536.webp +0 -0
- package/logos/gn-538.webp +0 -0
- package/logos/gn-539.webp +0 -0
- package/logos/gn-54.webp +0 -0
- package/logos/gn-540.webp +0 -0
- package/logos/gn-541.webp +0 -0
- package/logos/gn-542.webp +0 -0
- package/logos/gn-543.webp +0 -0
- package/logos/gn-544.webp +0 -0
- package/logos/gn-546.webp +0 -0
- package/logos/gn-551.webp +0 -0
- package/logos/gn-552.webp +0 -0
- package/logos/gn-553.webp +0 -0
- package/logos/gn-554.webp +0 -0
- package/logos/gn-555.webp +0 -0
- package/logos/gn-556.webp +0 -0
- package/logos/gn-558.webp +0 -0
- package/logos/gn-559.webp +0 -0
- package/logos/gn-560.webp +0 -0
- package/logos/gn-561.webp +0 -0
- package/logos/gn-562.webp +0 -0
- package/logos/gn-563.webp +0 -0
- package/logos/gn-564.webp +0 -0
- package/logos/gn-565.webp +0 -0
- package/logos/gn-567.webp +0 -0
- package/logos/gn-568.webp +0 -0
- package/logos/gn-569.webp +0 -0
- package/logos/gn-570.webp +0 -0
- package/logos/gn-571.webp +0 -0
- package/logos/gn-572.webp +0 -0
- package/logos/gn-573.webp +0 -0
- package/logos/gn-574.webp +0 -0
- package/logos/gn-576.webp +0 -0
- package/logos/gn-577.webp +0 -0
- package/logos/gn-578.webp +0 -0
- package/logos/gn-580.webp +0 -0
- package/logos/gn-581.webp +0 -0
- package/logos/gn-582.webp +0 -0
- package/logos/gn-583.webp +0 -0
- package/logos/gn-584.webp +0 -0
- package/logos/gn-587.webp +0 -0
- package/logos/gn-59.webp +0 -0
- package/logos/gn-594.webp +0 -0
- package/logos/gn-595.webp +0 -0
- package/logos/gn-597.webp +0 -0
- package/logos/gn-598.webp +0 -0
- package/logos/gn-6.webp +0 -0
- package/logos/gn-60.webp +0 -0
- package/logos/gn-600.webp +0 -0
- package/logos/gn-601.webp +0 -0
- package/logos/gn-603.webp +0 -0
- package/logos/gn-604.webp +0 -0
- package/logos/gn-605.webp +0 -0
- package/logos/gn-608.webp +0 -0
- package/logos/gn-609.webp +0 -0
- package/logos/gn-61.webp +0 -0
- package/logos/gn-610.webp +0 -0
- package/logos/gn-613.webp +0 -0
- package/logos/gn-614.webp +0 -0
- package/logos/gn-615.webp +0 -0
- package/logos/gn-616.webp +0 -0
- package/logos/gn-617.webp +0 -0
- package/logos/gn-618.webp +0 -0
- package/logos/gn-619.webp +0 -0
- package/logos/gn-62.webp +0 -0
- package/logos/gn-620.webp +0 -0
- package/logos/gn-621.webp +0 -0
- package/logos/gn-622.webp +0 -0
- package/logos/gn-629.webp +0 -0
- package/logos/gn-630.webp +0 -0
- package/logos/gn-631.webp +0 -0
- package/logos/gn-632.webp +0 -0
- package/logos/gn-633.webp +0 -0
- package/logos/gn-634.webp +0 -0
- package/logos/gn-635.webp +0 -0
- package/logos/gn-636.webp +0 -0
- package/logos/gn-637.webp +0 -0
- package/logos/gn-638.webp +0 -0
- package/logos/gn-639.webp +0 -0
- package/logos/gn-640.webp +0 -0
- package/logos/gn-641.webp +0 -0
- package/logos/gn-642.webp +0 -0
- package/logos/gn-643.webp +0 -0
- package/logos/gn-644.webp +0 -0
- package/logos/gn-645.webp +0 -0
- package/logos/gn-646.webp +0 -0
- package/logos/gn-647.webp +0 -0
- package/logos/gn-648.webp +0 -0
- package/logos/gn-656.webp +0 -0
- package/logos/gn-658.webp +0 -0
- package/logos/gn-659.webp +0 -0
- package/logos/gn-661.webp +0 -0
- package/logos/gn-663.webp +0 -0
- package/logos/gn-664.webp +0 -0
- package/logos/gn-665.webp +0 -0
- package/logos/gn-666.webp +0 -0
- package/logos/gn-668.webp +0 -0
- package/logos/gn-670.webp +0 -0
- package/logos/gn-673.webp +0 -0
- package/logos/gn-674.webp +0 -0
- package/logos/gn-675.webp +0 -0
- package/logos/gn-676.webp +0 -0
- package/logos/gn-677.webp +0 -0
- package/logos/gn-678.webp +0 -0
- package/logos/gn-679.webp +0 -0
- package/logos/gn-689.webp +0 -0
- package/logos/gn-690.webp +0 -0
- package/logos/gn-691.webp +0 -0
- package/logos/gn-692.webp +0 -0
- package/logos/gn-695.webp +0 -0
- package/logos/gn-697.webp +0 -0
- package/logos/gn-699.webp +0 -0
- package/logos/gn-700.webp +0 -0
- package/logos/gn-701.webp +0 -0
- package/logos/gn-703.webp +0 -0
- package/logos/gn-704.webp +0 -0
- package/logos/gn-707.webp +0 -0
- package/logos/gn-709.webp +0 -0
- package/logos/gn-712.webp +0 -0
- package/logos/gn-714.webp +0 -0
- package/logos/gn-715.webp +0 -0
- package/logos/gn-719.webp +0 -0
- package/logos/gn-720.webp +0 -0
- package/logos/gn-721.webp +0 -0
- package/logos/gn-722.webp +0 -0
- package/logos/gn-725.webp +0 -0
- package/logos/gn-727.webp +0 -0
- package/logos/gn-728.webp +0 -0
- package/logos/gn-729.webp +0 -0
- package/logos/gn-730.webp +0 -0
- package/logos/gn-731.webp +0 -0
- package/logos/gn-733.webp +0 -0
- package/logos/gn-735.webp +0 -0
- package/logos/gn-736.webp +0 -0
- package/logos/gn-737.webp +0 -0
- package/logos/gn-738.webp +0 -0
- package/logos/gn-740.webp +0 -0
- package/logos/gn-743.webp +0 -0
- package/logos/gn-744.webp +0 -0
- package/logos/gn-746.webp +0 -0
- package/logos/gn-747.webp +0 -0
- package/logos/gn-748.webp +0 -0
- package/logos/gn-750.webp +0 -0
- package/logos/gn-751.webp +0 -0
- package/logos/gn-753.webp +0 -0
- package/logos/gn-755.webp +0 -0
- package/logos/gn-756.webp +0 -0
- package/logos/gn-758.webp +0 -0
- package/logos/gn-759.webp +0 -0
- package/logos/gn-760.webp +0 -0
- package/logos/gn-761.webp +0 -0
- package/logos/gn-762.webp +0 -0
- package/logos/gn-763.webp +0 -0
- package/logos/gn-764.webp +0 -0
- package/logos/gn-765.webp +0 -0
- package/logos/gn-766.webp +0 -0
- package/logos/gn-767.webp +0 -0
- package/logos/gn-768.webp +0 -0
- package/logos/gn-769.webp +0 -0
- package/logos/gn-770.webp +0 -0
- package/logos/gn-773.webp +0 -0
- package/logos/gn-774.webp +0 -0
- package/logos/gn-775.webp +0 -0
- package/logos/gn-777.webp +0 -0
- package/logos/gn-780.webp +0 -0
- package/logos/gn-781.webp +0 -0
- package/logos/gn-783.webp +0 -0
- package/logos/gn-784.webp +0 -0
- package/logos/gn-79.webp +0 -0
- package/logos/gn-790.webp +0 -0
- package/logos/gn-793.webp +0 -0
- package/logos/gn-795.webp +0 -0
- package/logos/gn-796.webp +0 -0
- package/logos/gn-797.webp +0 -0
- package/logos/gn-798.webp +0 -0
- package/logos/gn-799.webp +0 -0
- package/logos/gn-80.webp +0 -0
- package/logos/gn-800.webp +0 -0
- package/logos/gn-801.webp +0 -0
- package/logos/gn-802.webp +0 -0
- package/logos/gn-806.webp +0 -0
- package/logos/gn-807.webp +0 -0
- package/logos/gn-808.webp +0 -0
- package/logos/gn-813.webp +0 -0
- package/logos/gn-815.webp +0 -0
- package/logos/gn-816.webp +0 -0
- package/logos/gn-817.webp +0 -0
- package/logos/gn-818.webp +0 -0
- package/logos/gn-834.webp +0 -0
- package/logos/gn-836.webp +0 -0
- package/logos/gn-837.webp +0 -0
- package/logos/gn-838.webp +0 -0
- package/logos/gn-839.webp +0 -0
- package/logos/gn-84.webp +0 -0
- package/logos/gn-840.webp +0 -0
- package/logos/gn-843.webp +0 -0
- package/logos/gn-844.webp +0 -0
- package/logos/gn-845.webp +0 -0
- package/logos/gn-852.webp +0 -0
- package/logos/gn-853.webp +0 -0
- package/logos/gn-860.webp +0 -0
- package/logos/gn-862.webp +0 -0
- package/logos/gn-863.webp +0 -0
- package/logos/gn-864.webp +0 -0
- package/logos/gn-87.webp +0 -0
- package/logos/gn-91.webp +0 -0
- package/logos/gn-92.webp +0 -0
- package/logos/gn-95.webp +0 -0
- package/logos/trivia-connections.webp +0 -0
- package/logos/trivia-funtrivia.webp +0 -0
- package/logos/trivia-globle.webp +0 -0
- package/logos/trivia-grid-baseball.webp +0 -0
- package/logos/trivia-grid-football.webp +0 -0
- package/logos/trivia-krillion.webp +0 -0
- package/logos/trivia-travle.webp +0 -0
- package/logos/trivia-triviaplaza.webp +0 -0
- package/logos/trivia-wordle.webp +0 -0
- package/logos/trivia-worldle.webp +0 -0
- package/package.json +1 -1
- package/style.css +386 -76
package/app.js
CHANGED
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
const THEME_KEY = "rug-theme";
|
|
11
11
|
const PER_ROW_KEY = "rug-per-row";
|
|
12
12
|
const MAX_RECENT = 6;
|
|
13
|
-
const MARQUEE_SPEED = 38; // pixels per second
|
|
14
13
|
|
|
15
14
|
const TAG_EMOJI = {
|
|
16
15
|
Minecraft: "⛏️", Racing: "🏎️", Sports: "⚽", Shooter: "🎯", Horror: "👻", Clicker: "👆",
|
|
@@ -26,7 +25,7 @@
|
|
|
26
25
|
const els = {
|
|
27
26
|
homeView: $("view-home"), gamesView: $("view-games"), homeInput: $("home-input"), homeSub: $("home-sub"),
|
|
28
27
|
grid: $("grid"), search: $("search"), sort: $("sort"), chips: $("chips"), count: $("count"), empty: $("empty"),
|
|
29
|
-
allTitle: $("all-title"),
|
|
28
|
+
allTitle: $("all-title"),
|
|
30
29
|
recentBlock: $("recent-block"), recentRow: $("recent-row"),
|
|
31
30
|
popularBlock: $("popular-block"), marquee: $("marquee"), marqueeTrack: $("marquee-track"),
|
|
32
31
|
player: $("player"), frame: $("game-frame"), playerTitle: $("player-title"),
|
|
@@ -91,7 +90,7 @@
|
|
|
91
90
|
return `<button class="tile" type="button" data-id="${escapeHtml(game.id)}" title="${escapeHtml(game.desc || game.name)}">
|
|
92
91
|
<span class="tile-art" style="background:${gradient(game)}">${escapeHtml(initials(game.name))}</span>
|
|
93
92
|
${url ? `<span class="tile-art"><img src="${url}" alt="" loading="${eager ? "eager" : "lazy"}" decoding="async" onerror="this.parentNode.remove()"></span>` : ""}
|
|
94
|
-
${popular ? `<span class="badge">Popular</span>` : ""}
|
|
93
|
+
${popular ? `<span class="badge">Popular</span>` : ""}${liveBadge(game)}
|
|
95
94
|
<span class="tile-label">${escapeHtml(game.name)}</span>
|
|
96
95
|
</button>`;
|
|
97
96
|
}
|
|
@@ -106,7 +105,7 @@
|
|
|
106
105
|
const counts = tagCounts();
|
|
107
106
|
const tags = ["All", ...Object.keys(counts).sort((a, b) => counts[b] - counts[a])];
|
|
108
107
|
els.chips.innerHTML = tags.map((t) =>
|
|
109
|
-
`<button class="tab" role="tab" type="button" data-tag="${escapeHtml(t)}" aria-selected="${t === activeTag}">${t === "All" ? "All
|
|
108
|
+
`<button class="tab" role="tab" type="button" data-tag="${escapeHtml(t)}" aria-selected="${t === activeTag}">${t === "All" ? "All" : escapeHtml(t)}</button>`
|
|
110
109
|
).join("");
|
|
111
110
|
}
|
|
112
111
|
|
|
@@ -134,11 +133,12 @@
|
|
|
134
133
|
// Strips are for browsing; hide them while searching or filtering
|
|
135
134
|
const browsing = !raw && activeTag === "All";
|
|
136
135
|
els.popularBlock.hidden = !browsing;
|
|
136
|
+
$("gotd").hidden = !browsing || !$("gotd").children.length;
|
|
137
137
|
els.recentBlock.hidden = !browsing || !els.recentRow.children.length;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
function renderRecent() {
|
|
141
|
-
const recent = store.get(RECENT_KEY, []).map((id) => byId.get(id)).filter(
|
|
141
|
+
const recent = store.get(RECENT_KEY, []).map((id) => byId.get(id)).filter((g) => g && !g.hidden);
|
|
142
142
|
els.recentRow.innerHTML = recent.map((g) => tileHtml(g, { eager: true })).join("");
|
|
143
143
|
els.recentBlock.hidden = recent.length === 0 || !!els.search.value.trim() || activeTag !== "All";
|
|
144
144
|
}
|
|
@@ -161,27 +161,182 @@
|
|
|
161
161
|
store.set(PER_ROW_KEY, n);
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
// ---------- Popular games:
|
|
164
|
+
// ---------- Popular games: an endless sideways glide ----------
|
|
165
|
+
// Done in CSS (a transform the graphics chip moves on its own), so it costs nothing per frame here
|
|
166
|
+
// and stops by itself whenever the Games page is hidden. Pauses while pointed at.
|
|
165
167
|
function startMarquee() {
|
|
166
|
-
const list =
|
|
168
|
+
const list = popularList(18);
|
|
167
169
|
if (!list.length) { els.popularBlock.hidden = true; return; }
|
|
168
|
-
const set = list.map((g) => tileHtml(g, { popular: true
|
|
169
|
-
els.marqueeTrack.innerHTML = set + set; // two copies so
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
170
|
+
const set = list.map((g) => tileHtml(g, { popular: true })).join("");
|
|
171
|
+
els.marqueeTrack.innerHTML = set + set; // two copies, so sliding by exactly one copy loops with no gap
|
|
172
|
+
els.marqueeTrack.style.setProperty("--glide", `${list.length * 9}s`);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// ---------- Popular = what people actually play ----------
|
|
176
|
+
// Every game start adds 1 to stats/plays/<game> in Firebase (at most once per 15s per person, checked by the
|
|
177
|
+
// database). While someone has a game open they're listed under stats/playing/<game>/<their id>, removed
|
|
178
|
+
// when they close it or leave. Until enough plays are counted, the hand-picked POPULAR list fills the gaps.
|
|
179
|
+
const community = { plays: {}, playing: {}, user: null, playingRef: null, shown: "" };
|
|
180
|
+
const fbKey = (id) => String(id).replace(/[.#$[\]/%]/g, (c) => "%" + c.charCodeAt(0).toString(16).toUpperCase());
|
|
181
|
+
const playsOf = (g) => community.plays[fbKey(g.id)] || 0;
|
|
182
|
+
const playingOf = (g) => community.playing[fbKey(g.id)] || 0;
|
|
183
|
+
function popularList(n) {
|
|
184
|
+
const counted = games.filter((g) => playsOf(g) > 0).sort((a, b) => playsOf(b) - playsOf(a));
|
|
185
|
+
const picked = POPULAR.map((id) => byId.get(id)).filter(Boolean);
|
|
186
|
+
return [...new Set([...counted, ...picked])].slice(0, n);
|
|
187
|
+
}
|
|
188
|
+
// "🔥 3 playing" on every tile of a game someone has open right now
|
|
189
|
+
function liveBadge(g) {
|
|
190
|
+
const n = playingOf(g);
|
|
191
|
+
return n > 0 ? `<span class="live-badge">🔥 ${n} playing</span>` : "";
|
|
192
|
+
}
|
|
193
|
+
function updateLiveBadges() {
|
|
194
|
+
document.querySelectorAll(".tile[data-id]").forEach((t) => {
|
|
195
|
+
const g = byId.get(t.dataset.id);
|
|
196
|
+
if (!g) return;
|
|
197
|
+
const html = liveBadge(g), old = t.querySelector(".live-badge");
|
|
198
|
+
if (old) old.remove();
|
|
199
|
+
if (html) t.insertAdjacentHTML("beforeend", html);
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
// Re-draw the Popular strip and home buttons only when the order actually changes (so the glide doesn't jump)
|
|
203
|
+
function refreshPopular() {
|
|
204
|
+
const ids = popularList(18).map((g) => g.id).join(",");
|
|
205
|
+
if (ids === community.shown) return;
|
|
206
|
+
community.shown = ids;
|
|
207
|
+
startMarquee();
|
|
208
|
+
renderHomeApps();
|
|
209
|
+
updateLiveBadges();
|
|
210
|
+
}
|
|
211
|
+
async function startCommunity() {
|
|
212
|
+
const app = await getFirebase();
|
|
213
|
+
if (!app) return;
|
|
214
|
+
const db = app.database();
|
|
215
|
+
let t = 0;
|
|
216
|
+
db.ref("stats/plays").on("value", (s) => { community.plays = s.val() || {}; clearTimeout(t); t = setTimeout(refreshPopular, 300); });
|
|
217
|
+
db.ref("stats/playing").on("value", (s) => {
|
|
218
|
+
const counts = {};
|
|
219
|
+
s.forEach((g) => { counts[g.key] = g.numChildren(); });
|
|
220
|
+
community.playing = counts;
|
|
221
|
+
updateLiveBadges();
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
async function signedInUser(app) {
|
|
225
|
+
const auth = app.auth();
|
|
226
|
+
return auth.currentUser || new Promise((ok) => { const off = auth.onAuthStateChanged((u) => { if (u) { off(); ok(u); } }); });
|
|
227
|
+
}
|
|
228
|
+
async function notePlayStart(game) {
|
|
229
|
+
const app = await getFirebase();
|
|
230
|
+
if (!app) return;
|
|
231
|
+
try {
|
|
232
|
+
const user = await signedInUser(app);
|
|
233
|
+
const db = app.database(), FV = window.firebase.database.ServerValue;
|
|
234
|
+
notePlayStop();
|
|
235
|
+
const ref = community.playingRef = db.ref(`stats/playing/${fbKey(game.id)}/${user.uid}`);
|
|
236
|
+
ref.onDisconnect().remove();
|
|
237
|
+
ref.set(true).catch(() => {});
|
|
238
|
+
// one combined write: the database refuses it if this person counted a play under 15s ago
|
|
239
|
+
await db.ref().update({ [`stats/plays/${fbKey(game.id)}`]: FV.increment(1), [`stats/playLast/${user.uid}`]: FV.TIMESTAMP });
|
|
240
|
+
} catch { /* too soon after the last one, or offline: not counted */ }
|
|
241
|
+
}
|
|
242
|
+
function notePlayStop() {
|
|
243
|
+
const ref = community.playingRef;
|
|
244
|
+
if (!ref) return;
|
|
245
|
+
community.playingRef = null;
|
|
246
|
+
ref.onDisconnect().cancel().catch(() => {});
|
|
247
|
+
ref.remove().catch(() => {});
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// ---------- Game of the day: a different game every day, the same one for everybody ----------
|
|
251
|
+
function renderGameOfDay() {
|
|
252
|
+
const pool = games.filter((g) => logoUrl(g) && g.desc);
|
|
253
|
+
if (!pool.length) return;
|
|
254
|
+
const g = pool[(dayNumber() * 2654435761 >>> 0) % pool.length]; // spread out, so neighbors in A–Z don't follow each other
|
|
255
|
+
$("gotd").innerHTML = `<button class="gotd-card" type="button" data-id="${escapeHtml(g.id)}">
|
|
256
|
+
<span class="gotd-art"><img src="${logoUrl(g)}" alt="" decoding="async"></span>
|
|
257
|
+
<span class="gotd-text"><span class="gotd-label">🎯 Game of the day</span><span class="gotd-name">${escapeHtml(g.name)}</span>
|
|
258
|
+
<span class="gotd-desc">${escapeHtml(g.desc)}</span><span class="gotd-play">Play now ▶</span></span></button>`;
|
|
259
|
+
$("gotd").hidden = false;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// ---------- Home: shortcut tiles for popular games under the search bar ----------
|
|
263
|
+
function renderHomeApps() {
|
|
264
|
+
const list = popularList(12);
|
|
265
|
+
$("home-apps").innerHTML = list.map((g) => {
|
|
266
|
+
const url = logoUrl(g);
|
|
267
|
+
const art = url ? `<img src="${url}" alt="" decoding="async">` : `<span style="background:${gradient(g)}">${escapeHtml(initials(g.name).slice(0, 2))}</span>`;
|
|
268
|
+
return `<button class="home-app" type="button" data-id="${escapeHtml(g.id)}" title="${escapeHtml(g.name)}"><span class="home-app-icon">${art}</span><span class="home-app-name">${escapeHtml(g.name)}</span></button>`;
|
|
269
|
+
}).join("");
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// ---------- Halloween: decorations on the home page, all of October ----------
|
|
273
|
+
// Drawn once (SVG, emoji and gradients); only the bats and the ghost move, using cheap transforms.
|
|
274
|
+
function cobweb(flip) {
|
|
275
|
+
const R = 260, spokes = 8, rings = 9;
|
|
276
|
+
const pt = (a, r) => [Math.cos(a) * r, Math.sin(a) * r];
|
|
277
|
+
let d = "";
|
|
278
|
+
for (let i = 0; i < spokes; i++) { const [x, y] = pt((i / (spokes - 1)) * Math.PI / 2, R); d += `M0 0L${x.toFixed(1)} ${y.toFixed(1)}`; }
|
|
279
|
+
for (let k = 1; k <= rings; k++) {
|
|
280
|
+
const r = (k / rings) * R * 0.95;
|
|
281
|
+
for (let i = 0; i < spokes - 1; i++) {
|
|
282
|
+
const a1 = (i / (spokes - 1)) * Math.PI / 2, a2 = ((i + 1) / (spokes - 1)) * Math.PI / 2;
|
|
283
|
+
const [x1, y1] = pt(a1, r), [x2, y2] = pt(a2, r), [cx, cy] = pt((a1 + a2) / 2, r * 0.86); // sags toward the corner
|
|
284
|
+
d += `M${x1.toFixed(1)} ${y1.toFixed(1)}Q${cx.toFixed(1)} ${cy.toFixed(1)} ${x2.toFixed(1)} ${y2.toFixed(1)}`;
|
|
181
285
|
}
|
|
182
|
-
requestAnimationFrame(step);
|
|
183
286
|
}
|
|
184
|
-
|
|
287
|
+
return `<svg class="web ${flip ? "right" : "left"}" viewBox="0 0 270 270"><path d="${d}"/></svg>`;
|
|
288
|
+
}
|
|
289
|
+
// ---------- Themes (Settings → Theme): Auto picks Halloween in October, Christmas in December, else Black ----------
|
|
290
|
+
const THEMES = ["auto", "black", "white", "halloween", "christmas"];
|
|
291
|
+
function resolveTheme(t) {
|
|
292
|
+
if (THEMES.includes(t) && t !== "auto") return t;
|
|
293
|
+
const m = new Date().getMonth();
|
|
294
|
+
return m === 9 ? "halloween" : m === 11 ? "christmas" : "black";
|
|
295
|
+
}
|
|
296
|
+
function applySiteTheme(choice) {
|
|
297
|
+
const t = resolveTheme(choice);
|
|
298
|
+
const root = document.documentElement;
|
|
299
|
+
root.dataset.theme = t === "white" ? "light" : "dark";
|
|
300
|
+
root.classList.toggle("halloween", t === "halloween");
|
|
301
|
+
root.classList.toggle("christmas", t === "christmas");
|
|
302
|
+
$("theme-color").content = { white: "#f6f6f8", halloween: "#110820", christmas: "#0b1424" }[t] || "#000000";
|
|
303
|
+
if (t === "halloween" && !document.querySelector(".spooky")) buildHalloween(); // scenery is only drawn once it's needed
|
|
304
|
+
if (t === "christmas" && !document.querySelector(".xmas")) buildChristmas();
|
|
305
|
+
}
|
|
306
|
+
function buildChristmas() {
|
|
307
|
+
const colors = ["#ef4444", "#facc15", "#22c55e", "#3b82f6"];
|
|
308
|
+
const bulbs = Array.from({ length: 26 }, (_, i) => `<i style="left:${(i + .5) * (100 / 26)}%;top:${10 + Math.sin(i * 1.3) * 5}px;--c:${colors[i % 4]};animation-delay:${(i % 5) * -.45}s"></i>`).join("");
|
|
309
|
+
const tree = (x, h) => `<path d="M${x} ${200 - h}l${h * .32} ${h * .45}h-${h * .12}l${h * .22} ${h * .3}h-${h * .1}l${h * .25} ${h * .25}h-${h * 1.34}l${h * .25}-${h * .25}h-${h * .1}l${h * .22}-${h * .3}h-${h * .12}Z"/>`;
|
|
310
|
+
$("view-home").insertAdjacentHTML("afterbegin", `<div class="xmas" aria-hidden="true">
|
|
311
|
+
<div class="lights"><svg viewBox="0 0 100 10" preserveAspectRatio="none"><path d="M0 2Q8 9 16 3T32 3 48 3 64 3 80 3 100 3"/></svg>${bulbs}</div>
|
|
312
|
+
<div class="snow s1"></div><div class="snow s2"></div>
|
|
313
|
+
<svg class="hills" viewBox="0 0 1600 240" preserveAspectRatio="xMidYMax slice">
|
|
314
|
+
<g class="pines">${tree(120, 120)}${tree(230, 80)}${tree(1380, 140)}${tree(1500, 90)}</g>
|
|
315
|
+
<path class="snowbank" d="M0 200C200 170 420 190 640 180S1100 165 1300 182 1520 186 1600 176V240H0Z"/>
|
|
316
|
+
</svg>
|
|
317
|
+
<span class="xmas-tree">🎄</span><span class="gift g1">🎁</span><span class="gift g2">🎁</span><span class="snowman">☃️</span>
|
|
318
|
+
</div>`);
|
|
319
|
+
}
|
|
320
|
+
function buildHalloween() {
|
|
321
|
+
const bat = `<svg viewBox="0 0 64 28"><path d="M32 8c2-4 3-6 3-8 1 3 2 5 3 6 5-4 14-6 26-2-6 2-9 6-10 12-4-3-8-3-11 0-2-3-5-4-8-3l-3 4-3-4c-3-1-6 0-8 3-3-3-7-3-11 0C9 10 6 6 0 4c12-4 21-2 26 2 1-1 2-3 3-6 0 2 1 4 3 8Z"/></svg>`;
|
|
322
|
+
$("view-home").insertAdjacentHTML("afterbegin", `<div class="spooky" aria-hidden="true">
|
|
323
|
+
<div class="stars"></div>
|
|
324
|
+
${cobweb(false)}${cobweb(true)}
|
|
325
|
+
<div class="spider"><span>🕷️</span></div>
|
|
326
|
+
<div class="moon"></div>
|
|
327
|
+
<div class="ghost">👻</div>
|
|
328
|
+
<div class="bat b1">${bat}</div><div class="bat b2">${bat}</div><div class="bat b3">${bat}</div>
|
|
329
|
+
<svg class="graveyard" viewBox="0 0 1600 240" preserveAspectRatio="xMidYMax slice">
|
|
330
|
+
<path class="ground" d="M0 190C220 160 420 175 640 168S1100 150 1300 165 1520 170 1600 160V240H0Z"/>
|
|
331
|
+
<g class="dark">
|
|
332
|
+
<path d="M180 200V120M180 140l-50-40M180 125l45-45M150 116l-26 4M205 96l24-6M180 160l40-12" stroke-width="9" stroke-linecap="round"/>
|
|
333
|
+
<path d="M600 190v-26a16 16 0 0 1 32 0v26ZM700 186v-34a20 20 0 0 1 40 0v34ZM790 190v-22a14 14 0 0 1 28 0v22ZM880 192v-36h8v-14h12v14h8v36Z"/>
|
|
334
|
+
<path d="M1300 200V118l40-40 40 40v12h24V100l30-30 30 30v-8h14v22l30 30v56Z"/>
|
|
335
|
+
</g>
|
|
336
|
+
<g class="windows"><rect x="1332" y="120" width="14" height="22" rx="7"/><rect x="1420" y="128" width="12" height="16"/><rect x="1446" y="128" width="12" height="16"/><path d="M1384 200v-26a12 12 0 0 1 24 0v26Z"/><rect x="1500" y="160" width="12" height="12"/></g>
|
|
337
|
+
</svg>
|
|
338
|
+
<span class="pumpkin p1">🎃</span><span class="pumpkin p2">🎃</span><span class="pumpkin p3">🎃</span>
|
|
339
|
+
</div>`);
|
|
185
340
|
}
|
|
186
341
|
|
|
187
342
|
// ---------- Game loading ----------
|
|
@@ -386,6 +541,7 @@
|
|
|
386
541
|
|
|
387
542
|
function stopGame() {
|
|
388
543
|
stats.stopPlay();
|
|
544
|
+
notePlayStop();
|
|
389
545
|
if (!currentLoad) return;
|
|
390
546
|
currentLoad.controller.abort();
|
|
391
547
|
currentLoad = null;
|
|
@@ -406,11 +562,11 @@
|
|
|
406
562
|
}
|
|
407
563
|
|
|
408
564
|
// ---------- Routing: "" home, #games, #recent, #play/<id> ----------
|
|
409
|
-
const VIEW_ORDER = ["home", "games", "
|
|
565
|
+
const VIEW_ORDER = ["home", "games", "trivia", "ai", "chat", "stats", "settings", "changelog"];
|
|
410
566
|
let lastView = null;
|
|
411
567
|
function viewFor(hash) {
|
|
412
568
|
return hash === "#games" || hash === "#recent" ? "games" : hash === "#settings" ? "settings" : hash === "#chat" ? "chat"
|
|
413
|
-
: hash === "#stats" ? "stats" : hash === "#changelog" ? "changelog" : hash === "#
|
|
569
|
+
: hash === "#stats" ? "stats" : hash === "#changelog" ? "changelog" : hash === "#ai" ? "ai" : hash === "#trivia" ? "trivia" : "home";
|
|
414
570
|
}
|
|
415
571
|
// Switching pages: the old page slides out while the new one slides in (down the side bar = upward,
|
|
416
572
|
// up the side bar = downward). Uses the browser's view transitions; older browsers just switch.
|
|
@@ -427,7 +583,6 @@
|
|
|
427
583
|
const m = location.hash.match(/^#play\/(.+)$/);
|
|
428
584
|
const game = m && byId.get(decodeURIComponent(m[1]));
|
|
429
585
|
if (game) {
|
|
430
|
-
if (live.viewer) stopWatching(); // a game covers the Live page: stop the stream's sound too
|
|
431
586
|
els.player.hidden = false;
|
|
432
587
|
document.body.classList.add("playing");
|
|
433
588
|
addRecent(game.id);
|
|
@@ -435,6 +590,7 @@
|
|
|
435
590
|
if (dockOpen()) openChat();
|
|
436
591
|
if (currentLoad?.id !== game.id) {
|
|
437
592
|
loadGame(game);
|
|
593
|
+
notePlayStart(game);
|
|
438
594
|
track(`Play: ${game.name}`, { name: "play_game", params: { game_name: game.name, game_category: game.tag } });
|
|
439
595
|
}
|
|
440
596
|
return;
|
|
@@ -451,9 +607,14 @@
|
|
|
451
607
|
lastView = view;
|
|
452
608
|
$("view-stats").hidden = view !== "stats";
|
|
453
609
|
$("view-changelog").hidden = view !== "changelog";
|
|
454
|
-
$("view-
|
|
455
|
-
|
|
456
|
-
|
|
610
|
+
$("view-ai").hidden = view !== "ai";
|
|
611
|
+
$("view-trivia").hidden = view !== "trivia";
|
|
612
|
+
if (view !== "trivia") { // leaving: stop the clock, close any puzzle site, and a half-done quiz starts over next time
|
|
613
|
+
stopTriviaTimer();
|
|
614
|
+
closeTriviaSite();
|
|
615
|
+
if (!$("trivia-play").hidden) triviaScreen("setup");
|
|
616
|
+
}
|
|
617
|
+
if (view === "ai") { renderAi(); setTimeout(() => $("ai-input").focus(), 50); }
|
|
457
618
|
if (view === "changelog") renderChangelog();
|
|
458
619
|
placeChatBox();
|
|
459
620
|
if (view === "settings") { renderSettings(); renderAdmin(); }
|
|
@@ -510,22 +671,21 @@
|
|
|
510
671
|
setInterval(clockTick, 1000);
|
|
511
672
|
}
|
|
512
673
|
|
|
513
|
-
|
|
514
|
-
document.documentElement.dataset.theme = t;
|
|
515
|
-
$("theme-color").content = t === "dark" ? "#000000" : "#f6f6f8"; // phone browser bar matches the page
|
|
516
|
-
$("theme-btn").title = t === "dark" ? "Switch to light mode" : "Switch to dark mode";
|
|
517
|
-
try { localStorage.setItem(THEME_KEY, t); } catch {}
|
|
518
|
-
}
|
|
674
|
+
// The theme lives in settings.theme now; the old light/dark switch's saved value is cleared
|
|
519
675
|
function initTheme() {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
applyTheme(document.documentElement.dataset.theme === "dark" ? "light" : "dark"));
|
|
676
|
+
try { localStorage.removeItem(THEME_KEY); } catch {}
|
|
677
|
+
applySiteTheme(settings.theme);
|
|
523
678
|
}
|
|
524
679
|
|
|
525
680
|
// ---------- What's new (changelog) ----------
|
|
526
681
|
// Newest first. Add an entry here with every publish; its version should match package.json.
|
|
527
682
|
// Each has: new (features), games (added/removed/fixed games), fixes (bugs). Leave a list out if empty.
|
|
528
683
|
const CHANGELOG = [
|
|
684
|
+
{ version: "1.0.37", date: "2026-10-29",
|
|
685
|
+
new: ["🤖 AI chat: ask anything, and it can look at pictures too", "A cleaner Games page: search on top, categories in one row", "🎃 Halloween look on the home page, plus quick buttons for popular games", "Hide the side bar with the arrow at its bottom", "🎨 Themes in Settings: Auto, Black, White, Halloween and Christmas",
|
|
686
|
+
"🔥 Popular games are now the ones people actually play, and games show how many are playing right now", "🎯 Game of the day on the Games page",
|
|
687
|
+
"📊 Polls in chat", "Trivia: a quick quiz with NFL, NBA and MLB (all 92 teams, players, easy to hard) and 11 more topics, plus daily puzzle games", "🔊 The soundboard now has its own button in the side bar", "Chat titles have been removed", "Live streaming has been removed"],
|
|
688
|
+
fixes: ["The site loads much faster: game pictures are about 6x smaller", "Smoother on Chromebooks: the background no longer animates", "Quicker page switching and loading screen", "Chat names are no longer censored (only slurs are hidden)", "Words with a K in them were wrongly being hidden in chat","The admin code works even when the chat is locked"] },
|
|
529
689
|
{ version: "1.0.36", date: "2026-10-28",
|
|
530
690
|
new: ["🎁 Send gifts during live streams: they pop up on the stream for everyone (one gift a minute)"],
|
|
531
691
|
fixes: ["Nickname and title boxes aren't cut off in the live chat anymore"] },
|
|
@@ -773,7 +933,6 @@
|
|
|
773
933
|
document.title = tabTitle(els.player.hidden ? "" : els.playerTitle.textContent);
|
|
774
934
|
const keys = CFG.panicKeys.map((k) => (k === " " ? "Space" : k)).join(" or ");
|
|
775
935
|
$("panic-btn").title = `Panic (${keys})`;
|
|
776
|
-
document.querySelector(".corner-links span").innerHTML = `${CFG.panicKeys.map((k) => `<kbd>${escapeHtml(k === " " ? "Space" : k)}</kbd>`).join(" or ")} panic`;
|
|
777
936
|
renderBookmark();
|
|
778
937
|
}
|
|
779
938
|
|
|
@@ -811,11 +970,10 @@
|
|
|
811
970
|
$("set-panic-custom-row").hidden = preset;
|
|
812
971
|
$("set-panic-custom").value = preset ? "" : CFG.panicUrl;
|
|
813
972
|
$("set-panic-key").textContent = CFG.panicKeys.map((k) => (k === " " ? "Space" : k)).join(" or ");
|
|
814
|
-
$("set-theme").value =
|
|
973
|
+
$("set-theme").value = THEMES.includes(settings.theme) ? settings.theme : "auto";
|
|
815
974
|
$("set-clock").value = clockIs24 ? "24" : "12";
|
|
816
975
|
$("set-per-row").value = String(store.get(PER_ROW_KEY, 6));
|
|
817
976
|
$("set-typing").checked = settings.typing !== false;
|
|
818
|
-
$("set-boot").checked = settings.boot !== false;
|
|
819
977
|
}
|
|
820
978
|
|
|
821
979
|
function bindSettings() {
|
|
@@ -853,11 +1011,10 @@
|
|
|
853
1011
|
if (e.key !== "Escape" && e.key.length === 1) { settings.panicKey = e.key; saveSettings(); }
|
|
854
1012
|
renderSettings();
|
|
855
1013
|
}, true);
|
|
856
|
-
$("set-theme").addEventListener("change", (e) =>
|
|
1014
|
+
$("set-theme").addEventListener("change", (e) => { settings.theme = e.target.value; saveSettings(); applySiteTheme(settings.theme); });
|
|
857
1015
|
$("set-clock").addEventListener("change", (e) => setClock24(e.target.value === "24"));
|
|
858
1016
|
$("set-per-row").addEventListener("change", (e) => setPerRow(Number(e.target.value)));
|
|
859
1017
|
$("set-typing").addEventListener("change", (e) => { settings.typing = e.target.checked; saveSettings(); startTypingPlaceholder(); });
|
|
860
|
-
$("set-boot").addEventListener("change", (e) => { settings.boot = e.target.checked; saveSettings(); });
|
|
861
1018
|
$("set-reset-stats").addEventListener("click", () => {
|
|
862
1019
|
if (!confirm("Reset your stats and achievements on this device?")) return;
|
|
863
1020
|
stats.data = null;
|
|
@@ -872,8 +1029,8 @@
|
|
|
872
1029
|
});
|
|
873
1030
|
$("set-reset").addEventListener("click", () => {
|
|
874
1031
|
settings = { disguise: "classroom", typing: true, boot: true };
|
|
1032
|
+
applySiteTheme("auto");
|
|
875
1033
|
saveSettings();
|
|
876
|
-
applyTheme("dark");
|
|
877
1034
|
setClock24(false);
|
|
878
1035
|
setPerRow(6);
|
|
879
1036
|
startTypingPlaceholder();
|
|
@@ -1081,12 +1238,24 @@
|
|
|
1081
1238
|
function extraWords() {
|
|
1082
1239
|
return String(chat.settings.words || "").split(/[\n,]+/).map((w) => plain(w).trim()).filter((w) => w.length >= 2);
|
|
1083
1240
|
}
|
|
1084
|
-
|
|
1241
|
+
// Names and titles only lose slurs and hate symbols; ordinary swears and rude words in a name are left alone
|
|
1242
|
+
const SLUR_ANYWHERE = ["nigg", "faggot", "fagot", "retard", "chink", "chingchong", "kike", "wetback", "tranny", "raghead",
|
|
1243
|
+
"towelhead", "beaner", "jigaboo", "porch monkey", "heil", "white power", "whitepower", "kkk", "1488"];
|
|
1244
|
+
const SLUR_WHOLE_WORD = ["fag", "fags", "nig", "spic", "gook", "coon"];
|
|
1245
|
+
function isBadWord(word, slursOnly = false) {
|
|
1085
1246
|
const p = plain(word).replace(/ /g, ""), w = tight(word);
|
|
1086
1247
|
if (!w || SAFE_WORDS.includes(p)) return false;
|
|
1248
|
+
const whole = slursOnly ? SLUR_WHOLE_WORD : BAD_WHOLE_WORD;
|
|
1249
|
+
const anywhere = slursOnly ? SLUR_ANYWHERE : [...BAD_ANYWHERE, ...extraWords()];
|
|
1087
1250
|
// whole-word list: check before and after squashing, since squashing turns "ass" into "as"
|
|
1088
|
-
|
|
1089
|
-
|
|
1251
|
+
if (whole.includes(p) || whole.includes(w)) return true;
|
|
1252
|
+
// Entries with numbers ("1488") are matched as typed; ones that squash to almost nothing ("kkk" -> "k")
|
|
1253
|
+
// are matched unsquashed, or every word with a k in it would be hidden
|
|
1254
|
+
return anywhere.some((b) => (/\d/.test(b) ? String(word).toLowerCase().includes(b)
|
|
1255
|
+
: tight(b).length >= 3 ? w.includes(tight(b)) : p.includes(plain(b).replace(/ /g, ""))));
|
|
1256
|
+
}
|
|
1257
|
+
function maskSlurs(text) {
|
|
1258
|
+
return String(text).split(/(\s+)/).map((w) => (/\S/.test(w) && isBadWord(w, true) ? maskWord(w) : w)).join("");
|
|
1090
1259
|
}
|
|
1091
1260
|
// Nothing is ever blocked: swear words just get their middle letters hidden ("f**k").
|
|
1092
1261
|
// The owner's extra word list (Settings → Tools) is hidden the same way.
|
|
@@ -1110,7 +1279,7 @@
|
|
|
1110
1279
|
const name = String(raw).replace(/\s+/g, " ").trim();
|
|
1111
1280
|
if (!name) return { error: "Pick a nickname." };
|
|
1112
1281
|
if ([...name].length > 16) return { error: "Nicknames can be up to 16 characters." };
|
|
1113
|
-
return { name:
|
|
1282
|
+
return { name: maskSlurs(name) };
|
|
1114
1283
|
}
|
|
1115
1284
|
|
|
1116
1285
|
const chat = {
|
|
@@ -1118,6 +1287,7 @@
|
|
|
1118
1287
|
settings: {}, // owner's live settings: slowMode (s), locked, words
|
|
1119
1288
|
mutedUntil: 0, banned: false,
|
|
1120
1289
|
flags: {}, // message key -> number of people who reported it
|
|
1290
|
+
votes: {}, // poll message key -> { voter id: option number }
|
|
1121
1291
|
lastText: "", lastTextAt: 0,
|
|
1122
1292
|
room: "main", // "main" (the Chat page / beside games) or "live" (beside the live stream)
|
|
1123
1293
|
};
|
|
@@ -1153,7 +1323,6 @@
|
|
|
1153
1323
|
chat.started = true;
|
|
1154
1324
|
$("chat-form").hidden = false;
|
|
1155
1325
|
$("chat-name").value = store.get("rug-chat-name", "");
|
|
1156
|
-
$("chat-title").value = store.get("rug-chat-title", "");
|
|
1157
1326
|
chatNote("Connecting…");
|
|
1158
1327
|
try {
|
|
1159
1328
|
await ensureUser(app);
|
|
@@ -1162,7 +1331,6 @@
|
|
|
1162
1331
|
return;
|
|
1163
1332
|
}
|
|
1164
1333
|
if (chat.admin) setAdminName();
|
|
1165
|
-
if (!$("view-live").hidden) renderLive(); // now we know whether this is the owner (Go live panel)
|
|
1166
1334
|
chatNote("");
|
|
1167
1335
|
const log = $("chat-log");
|
|
1168
1336
|
log.innerHTML = `<p class="chat-empty" id="chat-empty">No messages yet. Say hi!</p>`;
|
|
@@ -1190,7 +1358,7 @@
|
|
|
1190
1358
|
}
|
|
1191
1359
|
async function sweepOldMessages(db) {
|
|
1192
1360
|
const dayAgo = Date.now() - 86400000;
|
|
1193
|
-
for (const path of ["chat/messages"
|
|
1361
|
+
for (const path of ["chat/messages"]) {
|
|
1194
1362
|
try {
|
|
1195
1363
|
const old = await db.ref(path).orderByChild("ts").endAt(dayAgo).limitToFirst(200).once("value");
|
|
1196
1364
|
const changes = {};
|
|
@@ -1252,18 +1420,20 @@
|
|
|
1252
1420
|
} else if (typeof m.sticker === "string" && STICKERS.includes(m.sticker)) {
|
|
1253
1421
|
body = `<img class="chat-sticker" src="${STICKER_URL(m.sticker)}" alt="sticker" width="96" height="96" loading="lazy">`; } else if (typeof m.img === "string" && /^data:image\/(webp|jpeg);base64,[A-Za-z0-9+/=]+$/.test(m.img)) {
|
|
1254
1422
|
body = `<button class="chat-photo-btn" type="button" data-act="view" title="Open photo"><img class="chat-photo" src="${m.img}" alt="Photo from ${escapeHtml(m.name)}" loading="lazy"></button>`;
|
|
1423
|
+
} else if (m.poll && typeof m.poll.q === "string" && pollOptions(m.poll).length >= 2) {
|
|
1424
|
+
body = pollHtml(key, m.poll);
|
|
1255
1425
|
} else return null;
|
|
1256
1426
|
const t = new Date(m.ts || Date.now());
|
|
1257
1427
|
const div = document.createElement("div");
|
|
1258
1428
|
const mine = m.uid === chat.uid;
|
|
1259
|
-
div.className = "chat-msg" + (mine ? " me" : "") + (m.img ? " photo" : "") + (m.sticker ? " sticker" : "");
|
|
1429
|
+
div.className = "chat-msg" + (mine ? " me" : "") + (m.img ? " photo" : "") + (m.sticker ? " sticker" : "") + (m.poll ? " has-poll" : "");
|
|
1430
|
+
if (m.poll) div.pollData = m.poll; // kept so the bars can be redrawn as votes come in
|
|
1260
1431
|
div.dataset.key = key;
|
|
1261
1432
|
div.dataset.uid = m.uid || "";
|
|
1262
1433
|
div.dataset.name = m.name;
|
|
1263
1434
|
if (typeof m.text === "string") div.dataset.text = m.text;
|
|
1264
1435
|
if (!mine && typeof m.text === "string" && mentionsMe(m.text)) div.classList.add("mention");
|
|
1265
|
-
|
|
1266
|
-
div.innerHTML = `${m.admin ? `<span class="badge-admin">⭐ ADMIN</span>` : ""}${title}<span class="who" title="Mention">${escapeHtml(maskText(m.name))}</span>` +
|
|
1436
|
+
div.innerHTML = `${m.admin ? `<span class="badge-admin">⭐ ADMIN</span>` : ""}<span class="who" title="Mention">${escapeHtml(maskSlurs(m.name))}</span>` +
|
|
1267
1437
|
`${body}<span class="when">${t.toLocaleTimeString([], { hour: "numeric", minute: "2-digit" })}</span>` +
|
|
1268
1438
|
`<span class="msg-acts">` +
|
|
1269
1439
|
`<button class="mod act-delete" type="button" data-act="delete" title="Delete message">🗑</button>` +
|
|
@@ -1274,6 +1444,42 @@
|
|
|
1274
1444
|
applyFlags(div);
|
|
1275
1445
|
return div;
|
|
1276
1446
|
}
|
|
1447
|
+
// ---------- Polls: anyone can post one; everyone gets one vote (click again to take it back) ----------
|
|
1448
|
+
// Votes live at chat/votes/<message>/<voter> = option number
|
|
1449
|
+
function pollOptions(poll) {
|
|
1450
|
+
return Object.values(poll.o || {}).filter((o) => typeof o === "string" && o.trim()).slice(0, 4);
|
|
1451
|
+
}
|
|
1452
|
+
function pollHtml(key, poll) {
|
|
1453
|
+
const opts = pollOptions(poll), byVoter = chat.votes[key] || {};
|
|
1454
|
+
const votes = Object.values(byVoter), total = votes.length, my = byVoter[chat.uid];
|
|
1455
|
+
return `<div class="poll"><p class="poll-q">📊 ${escapeHtml(maskText(poll.q))}</p>` + opts.map((o, i) => {
|
|
1456
|
+
const n = votes.filter((v) => v === i).length, pct = total ? Math.round((n * 100) / total) : 0;
|
|
1457
|
+
return `<button class="poll-opt${my === i ? " on" : ""}" type="button" data-act="vote" data-i="${i}">` +
|
|
1458
|
+
`<span class="poll-bar" style="width:${pct}%"></span><span class="poll-label">${escapeHtml(maskText(o))}</span><span class="poll-n">${pct}%</span></button>`;
|
|
1459
|
+
}).join("") + `<p class="poll-total">${total} vote${total === 1 ? "" : "s"}${my === undefined ? " · tap to vote" : ""}</p></div>`;
|
|
1460
|
+
}
|
|
1461
|
+
function updatePolls() {
|
|
1462
|
+
$("chat-log").querySelectorAll(".chat-msg.has-poll").forEach((row) => {
|
|
1463
|
+
const old = row.querySelector(".poll");
|
|
1464
|
+
if (old && row.pollData) old.outerHTML = pollHtml(row.dataset.key, row.pollData);
|
|
1465
|
+
});
|
|
1466
|
+
}
|
|
1467
|
+
function bindPolls() {
|
|
1468
|
+
const maker = $("poll-maker"), btn = $("poll-btn");
|
|
1469
|
+
const show = (on) => { maker.hidden = !on; btn.setAttribute("aria-expanded", on); if (on) $("poll-q").focus(); };
|
|
1470
|
+
btn.addEventListener("click", () => show(maker.hidden));
|
|
1471
|
+
$("poll-cancel").addEventListener("click", () => show(false));
|
|
1472
|
+
maker.addEventListener("submit", async (e) => {
|
|
1473
|
+
e.preventDefault();
|
|
1474
|
+
const q = $("poll-q").value.replace(/\s+/g, " ").trim();
|
|
1475
|
+
const opts = [...maker.querySelectorAll(".poll-o")].map((i) => i.value.replace(/\s+/g, " ").trim()).filter(Boolean);
|
|
1476
|
+
if (!q || opts.length < 2) { chatNote("A poll needs a question and at least 2 options.", true); return; }
|
|
1477
|
+
if (await postMessage({ poll: { q: maskText(q).slice(0, 100), o: opts.map((o) => maskText(o).slice(0, 40)) } })) {
|
|
1478
|
+
maker.reset();
|
|
1479
|
+
show(false);
|
|
1480
|
+
}
|
|
1481
|
+
});
|
|
1482
|
+
}
|
|
1277
1483
|
function applyFlags(div) {
|
|
1278
1484
|
const n = chat.flags[div.dataset.key] || 0;
|
|
1279
1485
|
div.classList.toggle("flagged", n >= HIDE_AFTER_REPORTS);
|
|
@@ -1283,6 +1489,7 @@
|
|
|
1283
1489
|
|
|
1284
1490
|
// Live chat state: owner settings (slow mode, lock, extra words), my mute/ban, and report counts
|
|
1285
1491
|
function watchChatState(db) {
|
|
1492
|
+
db.ref("chat/votes").on("value", (s) => { chat.votes = s.val() || {}; updatePolls(); });
|
|
1286
1493
|
db.ref("chat/settings").on("value", (s) => {
|
|
1287
1494
|
chat.settings = s.val() || {};
|
|
1288
1495
|
updateChatStatus();
|
|
@@ -1318,7 +1525,7 @@
|
|
|
1318
1525
|
function slowSeconds() { return chat.admin ? 0 : Number(chat.settings.slowMode) || 0; } // no cooldown unless the owner turns on slow mode
|
|
1319
1526
|
function updateChatStatus() {
|
|
1320
1527
|
const why = blockedReason();
|
|
1321
|
-
["chat-text", "
|
|
1528
|
+
["chat-text", "emoji-btn", "photo-btn", "cam-btn"] /* Send stays clickable: the admin code works even when chat is locked */.forEach((id) => { if ($(id)) $(id).disabled = !!why; });
|
|
1322
1529
|
const slow = Number(chat.settings.slowMode) || 0;
|
|
1323
1530
|
$("chat-status").textContent = why || (chat.settings.locked ? "🔒 Chat is locked (only you can post)" : slow ? `🐢 Slow mode: one message every ${slow}s` : "");
|
|
1324
1531
|
$("chat-status").classList.toggle("err", !!why);
|
|
@@ -1395,6 +1602,13 @@
|
|
|
1395
1602
|
const row = btn.closest(".chat-msg");
|
|
1396
1603
|
const act = btn.dataset.act, uid = row.dataset.uid, name = row.dataset.name, key = row.dataset.key;
|
|
1397
1604
|
if (act === "view") { openPhoto(row.querySelector("img").src); return; }
|
|
1605
|
+
if (act === "vote") {
|
|
1606
|
+
if (!chat.uid) return;
|
|
1607
|
+
const i = Number(btn.dataset.i), mineNow = (chat.votes[key] || {})[chat.uid];
|
|
1608
|
+
try { await (await getFirebase()).database().ref(`chat/votes/${key}/${chat.uid}`).set(mineNow === i ? null : i); }
|
|
1609
|
+
catch { chatNote(blockedReason() || "Your vote didn't count. Try again.", true); }
|
|
1610
|
+
return;
|
|
1611
|
+
}
|
|
1398
1612
|
const mine = uid && uid === chat.uid;
|
|
1399
1613
|
const db = (await getFirebase()).database();
|
|
1400
1614
|
try {
|
|
@@ -1704,8 +1918,8 @@
|
|
|
1704
1918
|
await renderAdmin();
|
|
1705
1919
|
});
|
|
1706
1920
|
$("admin-clear").addEventListener("click", async () => {
|
|
1707
|
-
if (!chat.admin || !confirm("Delete every chat message for everyone
|
|
1708
|
-
try { await (await getFirebase()).database().ref(
|
|
1921
|
+
if (!chat.admin || !confirm("Delete every chat message for everyone?")) return;
|
|
1922
|
+
try { await (await getFirebase()).database().ref("chat/messages").remove(); }
|
|
1709
1923
|
catch { alert("Couldn't clear the chat."); }
|
|
1710
1924
|
});
|
|
1711
1925
|
}
|
|
@@ -1748,15 +1962,13 @@
|
|
|
1748
1962
|
const n = chatSender();
|
|
1749
1963
|
if (!n) return false;
|
|
1750
1964
|
if (!chat.admin) store.set("rug-chat-name", n.name); // never save the admin code as a remembered name
|
|
1751
|
-
const title = maskText($("chat-title").value.replace(/\s+/g, " ").trim()).slice(0, 20);
|
|
1752
|
-
store.set("rug-chat-title", title);
|
|
1753
1965
|
const db = app.database();
|
|
1754
1966
|
const key = db.ref(roomPath("messages")).push().key;
|
|
1755
1967
|
const TS = window.firebase.database.ServerValue.TIMESTAMP;
|
|
1756
1968
|
chat.lastSent = Date.now();
|
|
1757
1969
|
try {
|
|
1758
1970
|
await db.ref().update({
|
|
1759
|
-
[roomPath(`messages/${key}`)]: { name: n.name, ts: TS, uid: chat.uid, ...fields, ...(
|
|
1971
|
+
[roomPath(`messages/${key}`)]: { name: n.name, ts: TS, uid: chat.uid, ...fields, ...(chat.admin ? { admin: true } : {}) },
|
|
1760
1972
|
[`chat/last/${chat.uid}`]: TS,
|
|
1761
1973
|
});
|
|
1762
1974
|
stats.bump("chatSent");
|
|
@@ -1864,238 +2076,874 @@
|
|
|
1864
2076
|
$("quotes-approved").addEventListener("click", act);
|
|
1865
2077
|
}
|
|
1866
2078
|
|
|
1867
|
-
// ----------
|
|
1868
|
-
//
|
|
1869
|
-
//
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
const
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
2079
|
+
// ---------- Trivia: a quick quiz plus daily puzzle sites ----------
|
|
2080
|
+
// Questions come from Open Trivia Database (free, CC BY-SA 4.0). A session token stops repeats; if the
|
|
2081
|
+
// service can't be reached, a small built-in set is used instead.
|
|
2082
|
+
const TRIVIA_TOPICS = [["Anything", 0], ["NFL", "nfl"], ["NBA", "nba"], ["MLB", "mlb"], ["General", 9], ["Sports", 21], ["Video games", 15], ["Science", 17], ["Geography", 22],
|
|
2083
|
+
["History", 23], ["Movies", 11], ["Music", 12], ["Animals", 27], ["Computers", 18], ["TV", 14]];
|
|
2084
|
+
const TRIVIA_LEVELS = [["Any", ""], ["Easy", "easy"], ["Medium", "medium"], ["Hard", "hard"]];
|
|
2085
|
+
const TRIVIA_KINDS = [["All", "all"], ["Players only", "players"], ["Teams & rules", "teams"]];
|
|
2086
|
+
const TRIVIA_SECONDS = 15, TRIVIA_COUNT = 10, TRIVIA_BEST_KEY = "rug-trivia-best";
|
|
2087
|
+
// The fallback set: [question, right answer, wrong answers...]
|
|
2088
|
+
const TRIVIA_BACKUP = [
|
|
2089
|
+
["How many players does a football team have on the field at once?", "11", "9", "10", "12"],
|
|
2090
|
+
["Which planet is known as the Red Planet?", "Mars", "Venus", "Jupiter", "Mercury"],
|
|
2091
|
+
["What is the largest ocean on Earth?", "Pacific", "Atlantic", "Indian", "Arctic"],
|
|
2092
|
+
["How many sides does a hexagon have?", "6", "5", "7", "8"],
|
|
2093
|
+
["Which gas do plants take in from the air to make food?", "Carbon dioxide", "Oxygen", "Nitrogen", "Helium"],
|
|
2094
|
+
["What is the capital of Japan?", "Tokyo", "Kyoto", "Osaka", "Seoul"],
|
|
2095
|
+
["How many points is a touchdown worth (before the extra point)?", "6", "3", "7", "2"],
|
|
2096
|
+
["Which animal is the largest mammal?", "Blue whale", "Elephant", "Giraffe", "Orca"],
|
|
2097
|
+
["What is 12 × 12?", "144", "124", "132", "156"],
|
|
2098
|
+
["Which continent is Egypt in?", "Africa", "Asia", "Europe", "South America"],
|
|
2099
|
+
["How many minutes are in a day?", "1,440", "1,200", "2,400", "960"],
|
|
2100
|
+
["What is the freezing point of water in Fahrenheit?", "32°F", "0°F", "100°F", "12°F"],
|
|
2101
|
+
["Which country has the most people?", "India", "China", "USA", "Brazil"],
|
|
2102
|
+
["In basketball, how many points is a shot from behind the arc?", "3", "2", "4", "1"],
|
|
2103
|
+
["What is the hardest natural substance?", "Diamond", "Gold", "Iron", "Quartz"],
|
|
2104
|
+
];
|
|
2105
|
+
// League quizzes (written for this site, not from the question service).
|
|
2106
|
+
// Each: [level e/m/h, kind t (teams, rules, history) or p (players), question, right answer, wrong answers...]
|
|
2107
|
+
const TRIVIA_LEAGUES = {
|
|
2108
|
+
nfl: [
|
|
2109
|
+
["e", "t", "How many points is a field goal worth?", "3", "2", "1", "6"],
|
|
2110
|
+
["e", "t", "How many points is a touchdown worth, before the extra point?", "6", "7", "5", "3"],
|
|
2111
|
+
["e", "t", "How many yards are there between the two goal lines?", "100", "120", "110", "90"],
|
|
2112
|
+
["e", "t", "How many players does each team have on the field at once?", "11", "10", "12", "9"],
|
|
2113
|
+
["e", "t", "Which team plays its home games at Lambeau Field?", "Green Bay Packers", "Chicago Bears", "Minnesota Vikings", "Detroit Lions"],
|
|
2114
|
+
["e", "t", "Which city are the Chiefs from?", "Kansas City", "St. Louis", "Denver", "Oklahoma City"],
|
|
2115
|
+
["e", "t", "What are the NFL's two conferences called?", "AFC and NFC", "East and West", "American and National League", "Atlantic and Pacific"],
|
|
2116
|
+
["e", "t", "How many downs does the offense get to gain 10 yards?", "4", "3", "5", "6"],
|
|
2117
|
+
["e", "t", "What is it called when the quarterback is tackled behind the line of scrimmage?", "A sack", "A safety", "A fumble", "A blitz"],
|
|
2118
|
+
["e", "t", "Which NFL team plays in New Orleans?", "Saints", "Pelicans", "Jaguars", "Buccaneers"],
|
|
2119
|
+
["e", "t", "Which player snaps the ball to the quarterback?", "Center", "Guard", "Tackle", "Tight end"],
|
|
2120
|
+
["e", "t", "Which NFL team plays in Seattle?", "Seahawks", "Sonics", "Mariners", "Sounders"],
|
|
2121
|
+
["e", "t", "Which NFL team is from Buffalo?", "Bills", "Bisons", "Sabres", "Bulls"],
|
|
2122
|
+
["m", "t", "How many teams are in the NFL?", "32", "30", "28", "34"],
|
|
2123
|
+
["m", "t", "How many points is a safety worth?", "2", "1", "3", "6"],
|
|
2124
|
+
["m", "t", "Which team's defense was nicknamed the \"Steel Curtain\"?", "Pittsburgh Steelers", "Chicago Bears", "Baltimore Ravens", "Cleveland Browns"],
|
|
2125
|
+
["m", "t", "What trophy does the Super Bowl winner get?", "Vince Lombardi Trophy", "Stanley Cup", "Larry O'Brien Trophy", "Heisman Trophy"],
|
|
2126
|
+
["m", "t", "How many minutes long is a regulation NFL game?", "60", "48", "90", "40"],
|
|
2127
|
+
["m", "t", "Which team is nicknamed \"America's Team\"?", "Dallas Cowboys", "New York Giants", "Washington Commanders", "Pittsburgh Steelers"],
|
|
2128
|
+
["m", "t", "In football, what is a \"Hail Mary\"?", "A long, desperate pass", "A trick kick", "A two-point try", "A goal-line stand"],
|
|
2129
|
+
["m", "t", "How many timeouts does each team get per half?", "3", "2", "4", "5"],
|
|
2130
|
+
["m", "t", "What does PAT stand for?", "Point after touchdown", "Pass and tackle", "Penalty against team", "Play after timeout"],
|
|
2131
|
+
["m", "t", "In the NFL Draft, which team usually picks first?", "The team with the worst record", "The Super Bowl champion", "The team with the oldest roster", "Whoever wins a coin toss"],
|
|
2132
|
+
["m", "t", "How many points is a two-point conversion worth?", "2", "1", "3", "6"],
|
|
2133
|
+
["m", "t", "Which team moved from Oakland to Las Vegas?", "Raiders", "Chargers", "Rams", "Cardinals"],
|
|
2134
|
+
["h", "t", "Which team won Super Bowl I?", "Green Bay Packers", "Kansas City Chiefs", "New York Jets", "Dallas Cowboys"],
|
|
2135
|
+
["h", "t", "Which team had a perfect season, Super Bowl included, in 1972?", "Miami Dolphins", "New England Patriots", "Dallas Cowboys", "Oakland Raiders"],
|
|
2136
|
+
["h", "t", "In what year was the first Super Bowl played?", "1967", "1960", "1970", "1958"],
|
|
2137
|
+
["h", "t", "The Tennessee Titans used to be called what?", "Houston Oilers", "Memphis Showboats", "Nashville Stars", "Houston Texans"],
|
|
2138
|
+
["h", "t", "How wide is an NFL field, sideline to sideline?", "53⅓ yards", "50 yards", "60 yards", "45 yards"],
|
|
2139
|
+
["h", "t", "Which team has played in the most Super Bowls?", "New England Patriots", "Dallas Cowboys", "Pittsburgh Steelers", "Denver Broncos"],
|
|
2140
|
+
["h", "t", "Where did the Rams play before moving back to Los Angeles in 2016?", "St. Louis", "Anaheim", "San Diego", "Oakland"],
|
|
2141
|
+
["e", "p", "Which quarterback has won the most Super Bowls?", "Tom Brady", "Joe Montana", "Terry Bradshaw", "Patrick Mahomes"],
|
|
2142
|
+
["e", "p", "Patrick Mahomes plays quarterback for which team?", "Kansas City Chiefs", "Buffalo Bills", "Dallas Cowboys", "Cincinnati Bengals"],
|
|
2143
|
+
["e", "p", "What position does Travis Kelce play?", "Tight end", "Wide receiver", "Running back", "Linebacker"],
|
|
2144
|
+
["e", "p", "Aaron Rodgers spent most of his career with which team?", "Green Bay Packers", "New York Jets", "Chicago Bears", "Minnesota Vikings"],
|
|
2145
|
+
["e", "p", "Tom Brady won his first Super Bowl with which team?", "New England Patriots", "Tampa Bay Buccaneers", "Miami Dolphins", "New York Jets"],
|
|
2146
|
+
["e", "p", "What position does Josh Allen of the Bills play?", "Quarterback", "Running back", "Kicker", "Linebacker"],
|
|
2147
|
+
["e", "p", "Lamar Jackson plays for which team?", "Baltimore Ravens", "Pittsburgh Steelers", "Miami Dolphins", "Philadelphia Eagles"],
|
|
2148
|
+
["e", "p", "Joe Burrow plays quarterback for which team?", "Cincinnati Bengals", "Cleveland Browns", "Detroit Lions", "Houston Texans"],
|
|
2149
|
+
["e", "p", "Peyton Manning finished his career with which team?", "Denver Broncos", "Indianapolis Colts", "Tennessee Titans", "New York Giants"],
|
|
2150
|
+
["e", "p", "Eli Manning played his whole career for which team?", "New York Giants", "New York Jets", "Indianapolis Colts", "San Diego Chargers"],
|
|
2151
|
+
["m", "p", "Peyton Manning won his first Super Bowl with which team?", "Indianapolis Colts", "Denver Broncos", "Tennessee Titans", "New York Giants"],
|
|
2152
|
+
["m", "p", "Tom Brady finished his career with which team?", "Tampa Bay Buccaneers", "New England Patriots", "Miami Dolphins", "Las Vegas Raiders"],
|
|
2153
|
+
["m", "p", "Jerry Rice mostly played which position?", "Wide receiver", "Running back", "Quarterback", "Tight end"],
|
|
2154
|
+
["m", "p", "Which player was nicknamed \"Sweetness\"?", "Walter Payton", "Barry Sanders", "Emmitt Smith", "Jim Brown"],
|
|
2155
|
+
["m", "p", "Which quarterback led the 49ers to four Super Bowl wins in the 1980s?", "Joe Montana", "Steve Young", "Dan Marino", "John Elway"],
|
|
2156
|
+
["m", "p", "Which player was nicknamed \"Prime Time\"?", "Deion Sanders", "Randy Moss", "Michael Irvin", "Terrell Owens"],
|
|
2157
|
+
["m", "p", "Which running back was nicknamed \"Beast Mode\"?", "Marshawn Lynch", "Adrian Peterson", "LaDainian Tomlinson", "Derrick Henry"],
|
|
2158
|
+
["m", "p", "Ray Lewis spent his whole career with which team?", "Baltimore Ravens", "Cleveland Browns", "Pittsburgh Steelers", "Cincinnati Bengals"],
|
|
2159
|
+
["m", "p", "Which receiver was nicknamed \"Megatron\"?", "Calvin Johnson", "Randy Moss", "Julio Jones", "Larry Fitzgerald"],
|
|
2160
|
+
["m", "p", "J.J. Watt mainly played which position?", "Defensive end", "Linebacker", "Cornerback", "Offensive tackle"],
|
|
2161
|
+
["h", "p", "Who has the most career rushing yards in NFL history?", "Emmitt Smith", "Walter Payton", "Barry Sanders", "Jim Brown"],
|
|
2162
|
+
["h", "p", "Who has the most career receiving yards in NFL history?", "Jerry Rice", "Larry Fitzgerald", "Terrell Owens", "Randy Moss"],
|
|
2163
|
+
["h", "p", "Who has thrown the most career touchdown passes?", "Tom Brady", "Drew Brees", "Peyton Manning", "Brett Favre"],
|
|
2164
|
+
["h", "p", "Who has the most career sacks since sacks became official in 1982?", "Bruce Smith", "Reggie White", "Lawrence Taylor", "Michael Strahan"],
|
|
2165
|
+
["h", "p", "Who holds the single-season rushing record of 2,105 yards?", "Eric Dickerson", "Adrian Peterson", "Barry Sanders", "O.J. Simpson"],
|
|
2166
|
+
["h", "p", "Who holds the single-season passing yards record (5,477)?", "Peyton Manning", "Drew Brees", "Patrick Mahomes", "Tom Brady"],
|
|
2167
|
+
["h", "p", "Who was the first overall pick in the 2020 NFL Draft?", "Joe Burrow", "Justin Herbert", "Tua Tagovailoa", "Trevor Lawrence"],
|
|
2168
|
+
["h", "p", "Barry Sanders played his whole career for which team?", "Detroit Lions", "Chicago Bears", "Dallas Cowboys", "Minnesota Vikings"],
|
|
2169
|
+
["h", "p", "Who caught \"The Catch\" from Joe Montana in the 1982 NFC Championship?", "Dwight Clark", "Jerry Rice", "Roger Craig", "John Taylor"],
|
|
2170
|
+
["h", "p", "Who was the MVP of Super Bowl I?", "Bart Starr", "Johnny Unitas", "Joe Namath", "Vince Lombardi"],
|
|
2171
|
+
["h", "p", "Which defensive player won NFL MVP in 1986?", "Lawrence Taylor", "Reggie White", "Mike Singletary", "Howie Long"],
|
|
2172
|
+
],
|
|
2173
|
+
nba: [
|
|
2174
|
+
["e", "t", "How many players does each team have on the court at once?", "5", "6", "4", "7"],
|
|
2175
|
+
["e", "t", "How many points is a free throw worth?", "1", "2", "3", "0.5"],
|
|
2176
|
+
["e", "t", "How high is the rim off the floor?", "10 feet", "9 feet", "11 feet", "12 feet"],
|
|
2177
|
+
["e", "t", "Which team is from Golden State?", "Warriors", "Kings", "Clippers", "Suns"],
|
|
2178
|
+
["e", "t", "Which city are the Heat from?", "Miami", "Phoenix", "Houston", "Orlando"],
|
|
2179
|
+
["e", "t", "What is it called when a player moves their feet without dribbling?", "Traveling", "Double dribble", "Goaltending", "Carrying"],
|
|
2180
|
+
["e", "t", "Which NBA team plays in San Antonio?", "Spurs", "Rockets", "Mavericks", "Thunder"],
|
|
2181
|
+
["e", "t", "Which NBA team is from Toronto?", "Raptors", "Maple Leafs", "Blue Jays", "Huskies"],
|
|
2182
|
+
["e", "t", "Which team plays at Madison Square Garden?", "New York Knicks", "Brooklyn Nets", "Boston Celtics", "Philadelphia 76ers"],
|
|
2183
|
+
["e", "t", "Which NBA team is from Denver?", "Nuggets", "Broncos", "Rockies", "Avalanche"],
|
|
2184
|
+
["m", "t", "How many teams are in the NBA?", "30", "32", "28", "24"],
|
|
2185
|
+
["m", "t", "How many minutes long is an NBA quarter?", "12", "10", "15", "20"],
|
|
2186
|
+
["m", "t", "How many fouls does it take for a player to foul out?", "6", "5", "4", "7"],
|
|
2187
|
+
["m", "t", "How many seconds is the NBA shot clock?", "24", "30", "35", "20"],
|
|
2188
|
+
["m", "t", "Which team has won the most NBA championships?", "Boston Celtics", "Los Angeles Lakers", "Chicago Bulls", "Golden State Warriors"],
|
|
2189
|
+
["m", "t", "What is a triple-double?", "10 or more in three stat categories", "Three dunks in a row", "Scoring 30 points", "Three straight wins"],
|
|
2190
|
+
["m", "t", "How many wins does it take to win the NBA Finals?", "4", "3", "5", "7"],
|
|
2191
|
+
["m", "t", "In basketball, what is \"the paint\"?", "The lane near the basket", "The three-point line", "The center circle", "The bench area"],
|
|
2192
|
+
["m", "t", "The Larry O'Brien Trophy goes to whom?", "The NBA champion", "The MVP", "The top rookie", "The best defender"],
|
|
2193
|
+
["h", "t", "Which team won the first league title, in 1947?", "Philadelphia Warriors", "Boston Celtics", "Minneapolis Lakers", "New York Knicks"],
|
|
2194
|
+
["h", "t", "How far is the three-point line at the top of the arc?", "23 feet 9 inches", "22 feet", "25 feet", "20 feet 6 inches"],
|
|
2195
|
+
["h", "t", "Which team moved from Seattle to Oklahoma City in 2008?", "SuperSonics", "Kings", "Grizzlies", "Hornets"],
|
|
2196
|
+
["h", "t", "In what year did the NBA add the three-point line?", "1979", "1967", "1984", "1990"],
|
|
2197
|
+
["h", "t", "How many seconds does a player have to shoot a free throw?", "10", "5", "8", "15"],
|
|
2198
|
+
["h", "t", "Who did the Celtics beat in the 2008 NBA Finals?", "Los Angeles Lakers", "San Antonio Spurs", "Detroit Pistons", "Dallas Mavericks"],
|
|
2199
|
+
["e", "p", "Michael Jordan won all six of his titles with which team?", "Chicago Bulls", "Washington Wizards", "Detroit Pistons", "Boston Celtics"],
|
|
2200
|
+
["e", "p", "Kobe Bryant spent his whole career with which team?", "Los Angeles Lakers", "Los Angeles Clippers", "Charlotte Hornets", "Philadelphia 76ers"],
|
|
2201
|
+
["e", "p", "Stephen Curry is best known for what?", "Three-point shooting", "Blocking shots", "Dunking", "Rebounding"],
|
|
2202
|
+
["e", "p", "What position did Shaquille O'Neal play?", "Center", "Point guard", "Shooting guard", "Small forward"],
|
|
2203
|
+
["e", "p", "Which player was nicknamed \"The Black Mamba\"?", "Kobe Bryant", "Kevin Durant", "Allen Iverson", "Tim Duncan"],
|
|
2204
|
+
["e", "p", "Stephen Curry has played his whole career for which team?", "Golden State Warriors", "Charlotte Hornets", "Sacramento Kings", "Phoenix Suns"],
|
|
2205
|
+
["e", "p", "LeBron James is often called what?", "King James", "The Answer", "The Mailman", "The Dream"],
|
|
2206
|
+
["e", "p", "Who famously wore number 23 for the Chicago Bulls?", "Michael Jordan", "Scottie Pippen", "Dennis Rodman", "Derrick Rose"],
|
|
2207
|
+
["e", "p", "Victor Wembanyama plays for which team?", "San Antonio Spurs", "Houston Rockets", "Orlando Magic", "Detroit Pistons"],
|
|
2208
|
+
["e", "p", "Kevin Durant goes by which two letters?", "KD", "KG", "KB", "KT"],
|
|
2209
|
+
["m", "p", "Who is the NBA's all-time leading scorer?", "LeBron James", "Kareem Abdul-Jabbar", "Michael Jordan", "Kobe Bryant"],
|
|
2210
|
+
["m", "p", "Which team drafted LeBron James?", "Cleveland Cavaliers", "Miami Heat", "Los Angeles Lakers", "New York Knicks"],
|
|
2211
|
+
["m", "p", "Who is nicknamed \"The Greek Freak\"?", "Giannis Antetokounmpo", "Nikola Jokić", "Luka Dončić", "Joel Embiid"],
|
|
2212
|
+
["m", "p", "Magic Johnson played his whole career for which team?", "Los Angeles Lakers", "Orlando Magic", "Detroit Pistons", "Boston Celtics"],
|
|
2213
|
+
["m", "p", "Luka Dončić was traded in 2025 to which team?", "Los Angeles Lakers", "New York Knicks", "Miami Heat", "Boston Celtics"],
|
|
2214
|
+
["m", "p", "Kevin Durant won his first title with which team?", "Golden State Warriors", "Oklahoma City Thunder", "Brooklyn Nets", "Phoenix Suns"],
|
|
2215
|
+
["m", "p", "Tim Duncan spent his whole career with which team?", "San Antonio Spurs", "Houston Rockets", "Dallas Mavericks", "Utah Jazz"],
|
|
2216
|
+
["m", "p", "Dirk Nowitzki spent his whole career with which team?", "Dallas Mavericks", "San Antonio Spurs", "Sacramento Kings", "Milwaukee Bucks"],
|
|
2217
|
+
["m", "p", "Nikola Jokić plays for which team?", "Denver Nuggets", "Philadelphia 76ers", "Minnesota Timberwolves", "Utah Jazz"],
|
|
2218
|
+
["m", "p", "Larry Bird played his whole career for which team?", "Boston Celtics", "Indiana Pacers", "Los Angeles Lakers", "Detroit Pistons"],
|
|
2219
|
+
["h", "p", "How many points did Wilt Chamberlain score in his record single game?", "100", "81", "73", "92"],
|
|
2220
|
+
["h", "p", "Kareem Abdul-Jabbar's famous shot was called what?", "The skyhook", "The fadeaway", "The floater", "The alley-oop"],
|
|
2221
|
+
["h", "p", "Who has the most career assists in NBA history?", "John Stockton", "Chris Paul", "Jason Kidd", "Magic Johnson"],
|
|
2222
|
+
["h", "p", "Who has the most career rebounds in NBA history?", "Wilt Chamberlain", "Bill Russell", "Kareem Abdul-Jabbar", "Dennis Rodman"],
|
|
2223
|
+
["h", "p", "How many championships did Bill Russell win as a player?", "11", "8", "6", "10"],
|
|
2224
|
+
["h", "p", "Who was the first overall pick in the 2003 NBA Draft?", "LeBron James", "Carmelo Anthony", "Darko Miličić", "Dwyane Wade"],
|
|
2225
|
+
["h", "p", "Who scored 81 points in a single game in 2006?", "Kobe Bryant", "LeBron James", "Allen Iverson", "Tracy McGrady"],
|
|
2226
|
+
["h", "p", "Who has the most career blocked shots in NBA history?", "Hakeem Olajuwon", "Dikembe Mutombo", "Shaquille O'Neal", "Tim Duncan"],
|
|
2227
|
+
["h", "p", "Which player was nicknamed \"The Mailman\"?", "Karl Malone", "John Stockton", "Charles Barkley", "Patrick Ewing"],
|
|
2228
|
+
["h", "p", "Who was the 2023 NBA Finals MVP?", "Nikola Jokić", "Jimmy Butler", "Stephen Curry", "Jamal Murray"],
|
|
2229
|
+
],
|
|
2230
|
+
mlb: [
|
|
2231
|
+
["e", "t", "How many players does the fielding team have on the field?", "9", "10", "11", "8"],
|
|
2232
|
+
["e", "t", "How many innings are in a regulation game?", "9", "7", "8", "10"],
|
|
2233
|
+
["e", "t", "How many strikes make a strikeout?", "3", "2", "4", "5"],
|
|
2234
|
+
["e", "t", "How many balls make a walk?", "4", "3", "5", "6"],
|
|
2235
|
+
["e", "t", "Which team plays at Fenway Park?", "Boston Red Sox", "New York Yankees", "Chicago White Sox", "Baltimore Orioles"],
|
|
2236
|
+
["e", "t", "Which team plays at Wrigley Field?", "Chicago Cubs", "Chicago White Sox", "Milwaukee Brewers", "St. Louis Cardinals"],
|
|
2237
|
+
["e", "t", "What is a grand slam?", "A home run with the bases loaded", "Four home runs in a game", "A triple play", "Hitting for the cycle"],
|
|
2238
|
+
["e", "t", "What are MLB's two leagues?", "American League and National League", "East and West", "AFC and NFC", "Major and Minor League"],
|
|
2239
|
+
["e", "t", "How many outs are in each half-inning?", "3", "2", "4", "6"],
|
|
2240
|
+
["e", "t", "Which player crouches behind home plate and catches the pitches?", "Catcher", "Umpire", "Shortstop", "Pitcher"],
|
|
2241
|
+
["e", "t", "Which MLB team is from Toronto?", "Blue Jays", "Raptors", "Maple Leafs", "Argonauts"],
|
|
2242
|
+
["e", "t", "Which MLB team is from Houston?", "Astros", "Rangers", "Rockets", "Texans"],
|
|
2243
|
+
["m", "t", "How many teams are in MLB?", "30", "32", "28", "26"],
|
|
2244
|
+
["m", "t", "How far apart are the bases?", "90 feet", "60 feet", "100 feet", "75 feet"],
|
|
2245
|
+
["m", "t", "Which team has won the most World Series?", "New York Yankees", "St. Louis Cardinals", "Boston Red Sox", "Los Angeles Dodgers"],
|
|
2246
|
+
["m", "t", "In what year did the Cubs end their 108-year World Series drought?", "2016", "2004", "2010", "2019"],
|
|
2247
|
+
["m", "t", "What is \"the Green Monster\"?", "Fenway Park's left-field wall", "The Mariners' mascot", "A trick pitch", "The World Series trophy"],
|
|
2248
|
+
["m", "t", "Which team moved to Los Angeles from Brooklyn?", "Dodgers", "Angels", "Giants", "Padres"],
|
|
2249
|
+
["m", "t", "What does a pitcher's ERA measure?", "Earned runs allowed per 9 innings", "Errors per game", "Strikeouts per inning", "Pitches per at-bat"],
|
|
2250
|
+
["m", "t", "What song do fans sing during the seventh-inning stretch?", "Take Me Out to the Ball Game", "Sweet Caroline", "Centerfield", "We Will Rock You"],
|
|
2251
|
+
["m", "t", "What is a no-hitter?", "A game where a team gets no hits", "A game with no home runs", "A game with no runs", "A game with no errors"],
|
|
2252
|
+
["m", "t", "What is it called when a batter hits a single, double, triple and home run in one game?", "Hitting for the cycle", "A grand slam", "A golden sombrero", "A perfect game"],
|
|
2253
|
+
["m", "t", "What is a perfect game?", "No batter on the other team reaches base", "A game with no errors", "A shutout win", "Striking out every batter"],
|
|
2254
|
+
["m", "t", "Which team plays at Oracle Park?", "San Francisco Giants", "Oakland Athletics", "San Diego Padres", "Seattle Mariners"],
|
|
2255
|
+
["h", "t", "How far is the pitcher's rubber from home plate?", "60 feet 6 inches", "50 feet", "66 feet", "90 feet"],
|
|
2256
|
+
["h", "t", "Which team won the first World Series, in 1903?", "Boston Americans", "Pittsburgh Pirates", "New York Giants", "Chicago Cubs"],
|
|
2257
|
+
["h", "t", "In what year did the Red Sox end the \"Curse of the Bambino\"?", "2004", "1986", "2007", "2013"],
|
|
2258
|
+
["h", "t", "Which team moved from Montreal to Washington in 2005?", "Nationals", "Senators", "Orioles", "Marlins"],
|
|
2259
|
+
["h", "t", "How many stitches are on a baseball?", "108", "96", "120", "88"],
|
|
2260
|
+
["e", "p", "Who broke baseball's color barrier in 1947?", "Jackie Robinson", "Willie Mays", "Satchel Paige", "Larry Doby"],
|
|
2261
|
+
["e", "p", "Shohei Ohtani is famous for doing what at a top level?", "Both pitching and hitting", "Stealing bases", "Catching", "Switch-hitting"],
|
|
2262
|
+
["e", "p", "Babe Ruth is best remembered playing for which team?", "New York Yankees", "Boston Red Sox", "Boston Braves", "Chicago Cubs"],
|
|
2263
|
+
["e", "p", "Aaron Judge plays for which team?", "New York Yankees", "Boston Red Sox", "Los Angeles Dodgers", "Houston Astros"],
|
|
2264
|
+
["e", "p", "Shohei Ohtani signed with which team in 2023?", "Los Angeles Dodgers", "Los Angeles Angels", "San Diego Padres", "Toronto Blue Jays"],
|
|
2265
|
+
["e", "p", "Derek Jeter played his whole career for which team?", "New York Yankees", "New York Mets", "Boston Red Sox", "Miami Marlins"],
|
|
2266
|
+
["e", "p", "Mike Trout plays for which team?", "Los Angeles Angels", "Los Angeles Dodgers", "Philadelphia Phillies", "Seattle Mariners"],
|
|
2267
|
+
["e", "p", "Babe Ruth was nicknamed what?", "The Bambino", "The Iron Horse", "Mr. October", "The Say Hey Kid"],
|
|
2268
|
+
["e", "p", "Ken Griffey Jr. is best known for playing with which team?", "Seattle Mariners", "Cincinnati Reds", "Atlanta Braves", "Chicago White Sox"],
|
|
2269
|
+
["e", "p", "Albert Pujols became a star with which team?", "St. Louis Cardinals", "Chicago Cubs", "Los Angeles Angels", "Houston Astros"],
|
|
2270
|
+
["m", "p", "Who holds the record for most career home runs?", "Barry Bonds", "Hank Aaron", "Babe Ruth", "Alex Rodriguez"],
|
|
2271
|
+
["m", "p", "Cal Ripken Jr. spent his whole career with which team?", "Baltimore Orioles", "New York Yankees", "Boston Red Sox", "Texas Rangers"],
|
|
2272
|
+
["m", "p", "What number did Jackie Robinson wear, now retired by every MLB team?", "42", "24", "21", "44"],
|
|
2273
|
+
["m", "p", "Babe Ruth started his career as what kind of player?", "Pitcher", "Catcher", "Shortstop", "Center fielder"],
|
|
2274
|
+
["m", "p", "Which player was nicknamed \"Mr. October\"?", "Reggie Jackson", "Derek Jeter", "David Ortiz", "Mickey Mantle"],
|
|
2275
|
+
["m", "p", "In what year did Hank Aaron break Babe Ruth's home run record?", "1974", "1968", "1980", "1961"],
|
|
2276
|
+
["m", "p", "Who was nicknamed \"The Iron Horse\"?", "Lou Gehrig", "Cal Ripken Jr.", "Joe DiMaggio", "Ty Cobb"],
|
|
2277
|
+
["m", "p", "Mariano Rivera pitched his whole career for which team?", "New York Yankees", "Boston Red Sox", "Atlanta Braves", "Texas Rangers"],
|
|
2278
|
+
["m", "p", "How many home runs did Aaron Judge hit in 2022 to set the American League record?", "62", "61", "60", "65"],
|
|
2279
|
+
["m", "p", "Ichiro Suzuki started his MLB career with which team?", "Seattle Mariners", "New York Yankees", "Miami Marlins", "Los Angeles Dodgers"],
|
|
2280
|
+
["h", "p", "Who has the most career hits in MLB history?", "Pete Rose", "Ty Cobb", "Derek Jeter", "Ichiro Suzuki"],
|
|
2281
|
+
["h", "p", "Who holds the record for most home runs in one season?", "Barry Bonds", "Mark McGwire", "Aaron Judge", "Roger Maris"],
|
|
2282
|
+
["h", "p", "Who has the most career strikeouts as a pitcher?", "Nolan Ryan", "Randy Johnson", "Roger Clemens", "Walter Johnson"],
|
|
2283
|
+
["h", "p", "Who has the most career wins as a pitcher?", "Cy Young", "Walter Johnson", "Greg Maddux", "Warren Spahn"],
|
|
2284
|
+
["h", "p", "Who had a record 56-game hitting streak in 1941?", "Joe DiMaggio", "Ted Williams", "Ty Cobb", "Lou Gehrig"],
|
|
2285
|
+
["h", "p", "Who was the last player to hit .400 in a season?", "Ted Williams", "Tony Gwynn", "George Brett", "Rod Carew"],
|
|
2286
|
+
["h", "p", "How many games in a row did Cal Ripken Jr. play?", "2,632", "2,130", "2,000", "3,001"],
|
|
2287
|
+
["h", "p", "Who threw the only perfect game in World Series history?", "Don Larsen", "Sandy Koufax", "Roy Halladay", "Whitey Ford"],
|
|
2288
|
+
["h", "p", "Who has the most career stolen bases?", "Rickey Henderson", "Lou Brock", "Ty Cobb", "Tim Raines"],
|
|
2289
|
+
["h", "p", "Who has the most career saves?", "Mariano Rivera", "Trevor Hoffman", "Lee Smith", "Dennis Eckersley"],
|
|
2290
|
+
],
|
|
2291
|
+
};
|
|
2292
|
+
|
|
2293
|
+
// Team quizzes are built from these facts: [name, division, home field (null when it was just renamed or is
|
|
2294
|
+
// changing), two players most tied to the team, and optionally where the team played before]
|
|
2295
|
+
// ONE_TEAM: players who spent their whole career with one team; only they are used as wrong answers,
|
|
2296
|
+
// so a "wrong" choice can never secretly have played for the team being asked about.
|
|
2297
|
+
const TEAM_FACTS = {
|
|
2298
|
+
nfl: {
|
|
2299
|
+
venue: "stadium",
|
|
2300
|
+
teams: [
|
|
2301
|
+
["Buffalo Bills", "AFC East", "Highmark Stadium", ["Jim Kelly", "Bruce Smith"]],
|
|
2302
|
+
["Miami Dolphins", "AFC East", "Hard Rock Stadium", ["Dan Marino", "Bob Griese"]],
|
|
2303
|
+
["New England Patriots", "AFC East", "Gillette Stadium", ["Tom Brady", "Tedy Bruschi"]],
|
|
2304
|
+
["New York Jets", "AFC East", "MetLife Stadium", ["Joe Namath", "Curtis Martin"]],
|
|
2305
|
+
["Baltimore Ravens", "AFC North", "M&T Bank Stadium", ["Ray Lewis", "Ed Reed"], "Cleveland"],
|
|
2306
|
+
["Cincinnati Bengals", "AFC North", "Paycor Stadium", ["Ken Anderson", "Anthony Muñoz"]],
|
|
2307
|
+
["Cleveland Browns", "AFC North", "Huntington Bank Field", ["Jim Brown", "Otto Graham"]],
|
|
2308
|
+
["Pittsburgh Steelers", "AFC North", "Acrisure Stadium", ["Terry Bradshaw", "Joe Greene"]],
|
|
2309
|
+
["Houston Texans", "AFC South", "NRG Stadium", ["Andre Johnson", "J.J. Watt"]],
|
|
2310
|
+
["Indianapolis Colts", "AFC South", "Lucas Oil Stadium", ["Peyton Manning", "Johnny Unitas"], "Baltimore"],
|
|
2311
|
+
["Jacksonville Jaguars", "AFC South", "EverBank Stadium", ["Tony Boselli", "Fred Taylor"]],
|
|
2312
|
+
["Tennessee Titans", "AFC South", "Nissan Stadium", ["Eddie George", "Steve McNair"], "Houston"],
|
|
2313
|
+
["Denver Broncos", "AFC West", "Empower Field at Mile High", ["John Elway", "Terrell Davis"]],
|
|
2314
|
+
["Kansas City Chiefs", "AFC West", "Arrowhead Stadium", ["Patrick Mahomes", "Derrick Thomas"]],
|
|
2315
|
+
["Las Vegas Raiders", "AFC West", "Allegiant Stadium", ["Marcus Allen", "Tim Brown"], "Oakland"],
|
|
2316
|
+
["Los Angeles Chargers", "AFC West", "SoFi Stadium", ["LaDainian Tomlinson", "Junior Seau"], "San Diego"],
|
|
2317
|
+
["Dallas Cowboys", "NFC East", "AT&T Stadium", ["Troy Aikman", "Emmitt Smith"]],
|
|
2318
|
+
["New York Giants", "NFC East", "MetLife Stadium", ["Lawrence Taylor", "Eli Manning"]],
|
|
2319
|
+
["Philadelphia Eagles", "NFC East", "Lincoln Financial Field", ["Brian Dawkins", "Reggie White"]],
|
|
2320
|
+
["Washington Commanders", "NFC East", "Northwest Stadium", ["Darrell Green", "Joe Theismann"]],
|
|
2321
|
+
["Chicago Bears", "NFC North", "Soldier Field", ["Walter Payton", "Dick Butkus"]],
|
|
2322
|
+
["Detroit Lions", "NFC North", "Ford Field", ["Barry Sanders", "Calvin Johnson"]],
|
|
2323
|
+
["Green Bay Packers", "NFC North", "Lambeau Field", ["Brett Favre", "Bart Starr"]],
|
|
2324
|
+
["Minnesota Vikings", "NFC North", "U.S. Bank Stadium", ["Randy Moss", "Adrian Peterson"]],
|
|
2325
|
+
["Atlanta Falcons", "NFC South", "Mercedes-Benz Stadium", ["Matt Ryan", "Michael Vick"]],
|
|
2326
|
+
["Carolina Panthers", "NFC South", "Bank of America Stadium", ["Cam Newton", "Steve Smith Sr."]],
|
|
2327
|
+
["New Orleans Saints", "NFC South", "Caesars Superdome", ["Drew Brees", "Archie Manning"]],
|
|
2328
|
+
["Tampa Bay Buccaneers", "NFC South", "Raymond James Stadium", ["Derrick Brooks", "Warren Sapp"]],
|
|
2329
|
+
["Arizona Cardinals", "NFC West", "State Farm Stadium", ["Larry Fitzgerald", "Kurt Warner"], "St. Louis"],
|
|
2330
|
+
["San Francisco 49ers", "NFC West", "Levi's Stadium", ["Joe Montana", "Jerry Rice"]],
|
|
2331
|
+
["Seattle Seahawks", "NFC West", "Lumen Field", ["Steve Largent", "Russell Wilson"]],
|
|
2332
|
+
["Los Angeles Rams", "NFC West", "SoFi Stadium", ["Aaron Donald", "Eric Dickerson"], "St. Louis"],
|
|
2333
|
+
],
|
|
2334
|
+
// cities a team also played in long ago, never offered as wrong answers for it
|
|
2335
|
+
oldHomes: { "Arizona Cardinals": ["Chicago"], "Las Vegas Raiders": ["Los Angeles"], "Los Angeles Rams": ["Cleveland", "Anaheim"] },
|
|
2336
|
+
oneTeam: { "Dan Marino": "Miami Dolphins", "Bob Griese": "Miami Dolphins", "Jim Kelly": "Buffalo Bills", "Ray Lewis": "Baltimore Ravens",
|
|
2337
|
+
"Terry Bradshaw": "Pittsburgh Steelers", "Joe Greene": "Pittsburgh Steelers", "Walter Payton": "Chicago Bears", "Dick Butkus": "Chicago Bears",
|
|
2338
|
+
"Barry Sanders": "Detroit Lions", "Calvin Johnson": "Detroit Lions", "Bart Starr": "Green Bay Packers", "Troy Aikman": "Dallas Cowboys",
|
|
2339
|
+
"Lawrence Taylor": "New York Giants", "Eli Manning": "New York Giants", "Derrick Brooks": "Tampa Bay Buccaneers", "John Elway": "Denver Broncos",
|
|
2340
|
+
"Terrell Davis": "Denver Broncos", "Derrick Thomas": "Kansas City Chiefs", "Steve Largent": "Seattle Seahawks", "Darrell Green": "Washington Commanders",
|
|
2341
|
+
"Tedy Bruschi": "New England Patriots", "Larry Fitzgerald": "Arizona Cardinals", "Aaron Donald": "Los Angeles Rams", "Ken Anderson": "Cincinnati Bengals",
|
|
2342
|
+
"Anthony Muñoz": "Cincinnati Bengals", "Jim Brown": "Cleveland Browns", "Otto Graham": "Cleveland Browns", "Tony Boselli": "Jacksonville Jaguars" },
|
|
2343
|
+
},
|
|
2344
|
+
nba: {
|
|
2345
|
+
venue: "arena",
|
|
2346
|
+
teams: [
|
|
2347
|
+
["Boston Celtics", "Atlantic", "TD Garden", ["Larry Bird", "Bill Russell"]],
|
|
2348
|
+
["Brooklyn Nets", "Atlantic", "Barclays Center", ["Jason Kidd", "Vince Carter"], "New Jersey"],
|
|
2349
|
+
["New York Knicks", "Atlantic", "Madison Square Garden", ["Patrick Ewing", "Walt Frazier"]],
|
|
2350
|
+
["Philadelphia 76ers", "Atlantic", null, ["Allen Iverson", "Julius Erving"], "Syracuse"],
|
|
2351
|
+
["Toronto Raptors", "Atlantic", "Scotiabank Arena", ["Vince Carter", "Kyle Lowry"]],
|
|
2352
|
+
["Chicago Bulls", "Central", "United Center", ["Michael Jordan", "Scottie Pippen"]],
|
|
2353
|
+
["Cleveland Cavaliers", "Central", null, ["LeBron James", "Zydrunas Ilgauskas"]],
|
|
2354
|
+
["Detroit Pistons", "Central", "Little Caesars Arena", ["Isiah Thomas", "Joe Dumars"], "Fort Wayne"],
|
|
2355
|
+
["Indiana Pacers", "Central", "Gainbridge Fieldhouse", ["Reggie Miller", "Rik Smits"]],
|
|
2356
|
+
["Milwaukee Bucks", "Central", "Fiserv Forum", ["Giannis Antetokounmpo", "Kareem Abdul-Jabbar"]],
|
|
2357
|
+
["Atlanta Hawks", "Southeast", "State Farm Arena", ["Dominique Wilkins", "Trae Young"], "St. Louis"],
|
|
2358
|
+
["Charlotte Hornets", "Southeast", "Spectrum Center", ["Kemba Walker", "Muggsy Bogues"]],
|
|
2359
|
+
["Miami Heat", "Southeast", "Kaseya Center", ["Dwyane Wade", "Alonzo Mourning"]],
|
|
2360
|
+
["Orlando Magic", "Southeast", "Kia Center", ["Shaquille O'Neal", "Dwight Howard"]],
|
|
2361
|
+
["Washington Wizards", "Southeast", "Capital One Arena", ["Wes Unseld", "Elvin Hayes"], "Baltimore"],
|
|
2362
|
+
["Denver Nuggets", "Northwest", "Ball Arena", ["Nikola Jokić", "Alex English"]],
|
|
2363
|
+
["Minnesota Timberwolves", "Northwest", "Target Center", ["Kevin Garnett", "Anthony Edwards"]],
|
|
2364
|
+
["Oklahoma City Thunder", "Northwest", "Paycom Center", ["Shai Gilgeous-Alexander", "Kevin Durant"], "Seattle"],
|
|
2365
|
+
["Portland Trail Blazers", "Northwest", "Moda Center", ["Clyde Drexler", "Damian Lillard"]],
|
|
2366
|
+
["Utah Jazz", "Northwest", "Delta Center", ["Karl Malone", "John Stockton"], "New Orleans"],
|
|
2367
|
+
["Golden State Warriors", "Pacific", "Chase Center", ["Stephen Curry", "Wilt Chamberlain"], "Philadelphia"],
|
|
2368
|
+
["Los Angeles Clippers", "Pacific", "Intuit Dome", ["Blake Griffin", "Chris Paul"], "San Diego"],
|
|
2369
|
+
["Los Angeles Lakers", "Pacific", "Crypto.com Arena", ["Magic Johnson", "Kobe Bryant"], "Minneapolis"],
|
|
2370
|
+
["Phoenix Suns", "Pacific", null, ["Steve Nash", "Charles Barkley"]],
|
|
2371
|
+
["Sacramento Kings", "Pacific", "Golden 1 Center", ["Chris Webber", "Peja Stojaković"], "Kansas City"],
|
|
2372
|
+
["Dallas Mavericks", "Southwest", "American Airlines Center", ["Dirk Nowitzki", "Luka Dončić"]],
|
|
2373
|
+
["Houston Rockets", "Southwest", "Toyota Center", ["Hakeem Olajuwon", "Yao Ming"], "San Diego"],
|
|
2374
|
+
["Memphis Grizzlies", "Southwest", "FedExForum", ["Ja Morant", "Marc Gasol"], "Vancouver"],
|
|
2375
|
+
["New Orleans Pelicans", "Southwest", "Smoothie King Center", ["Anthony Davis", "Zion Williamson"]],
|
|
2376
|
+
["San Antonio Spurs", "Southwest", "Frost Bank Center", ["Tim Duncan", "David Robinson"]],
|
|
2377
|
+
],
|
|
2378
|
+
oldHomes: { "Golden State Warriors": ["San Francisco", "Oakland"], "Sacramento Kings": ["Cincinnati", "Rochester", "Omaha"], "Los Angeles Clippers": ["Buffalo"],
|
|
2379
|
+
"Atlanta Hawks": ["Milwaukee", "Tri-Cities"], "Washington Wizards": ["Chicago"], "Brooklyn Nets": ["New York"] },
|
|
2380
|
+
oneTeam: { "Larry Bird": "Boston Celtics", "Bill Russell": "Boston Celtics", "Kobe Bryant": "Los Angeles Lakers", "Magic Johnson": "Los Angeles Lakers",
|
|
2381
|
+
"Tim Duncan": "San Antonio Spurs", "David Robinson": "San Antonio Spurs", "Dirk Nowitzki": "Dallas Mavericks", "Reggie Miller": "Indiana Pacers",
|
|
2382
|
+
"Rik Smits": "Indiana Pacers", "John Stockton": "Utah Jazz", "Stephen Curry": "Golden State Warriors", "Isiah Thomas": "Detroit Pistons",
|
|
2383
|
+
"Joe Dumars": "Detroit Pistons", "Wes Unseld": "Washington Wizards", "Yao Ming": "Houston Rockets", "Nikola Jokić": "Denver Nuggets",
|
|
2384
|
+
"Giannis Antetokounmpo": "Milwaukee Bucks", "Anthony Edwards": "Minnesota Timberwolves" },
|
|
2385
|
+
},
|
|
2386
|
+
mlb: {
|
|
2387
|
+
venue: "ballpark",
|
|
2388
|
+
teams: [
|
|
2389
|
+
["Baltimore Orioles", "AL East", "Oriole Park at Camden Yards", ["Cal Ripken Jr.", "Brooks Robinson"], "St. Louis"],
|
|
2390
|
+
["Boston Red Sox", "AL East", "Fenway Park", ["Ted Williams", "David Ortiz"]],
|
|
2391
|
+
["New York Yankees", "AL East", "Yankee Stadium", ["Babe Ruth", "Derek Jeter"]],
|
|
2392
|
+
["Tampa Bay Rays", "AL East", null, ["Evan Longoria", "Carl Crawford"]],
|
|
2393
|
+
["Toronto Blue Jays", "AL East", "Rogers Centre", ["Roberto Alomar", "José Bautista"]],
|
|
2394
|
+
["Chicago White Sox", "AL Central", null, ["Frank Thomas", "Paul Konerko"]],
|
|
2395
|
+
["Cleveland Guardians", "AL Central", "Progressive Field", ["Bob Feller", "Jim Thome"]],
|
|
2396
|
+
["Detroit Tigers", "AL Central", "Comerica Park", ["Al Kaline", "Miguel Cabrera"]],
|
|
2397
|
+
["Kansas City Royals", "AL Central", "Kauffman Stadium", ["George Brett", "Salvador Pérez"]],
|
|
2398
|
+
["Minnesota Twins", "AL Central", "Target Field", ["Kirby Puckett", "Joe Mauer"], "Washington"],
|
|
2399
|
+
["Houston Astros", "AL West", null, ["Craig Biggio", "Jeff Bagwell"]],
|
|
2400
|
+
["Los Angeles Angels", "AL West", "Angel Stadium", ["Mike Trout", "Tim Salmon"]],
|
|
2401
|
+
["Athletics", "AL West", null, ["Rickey Henderson", "Reggie Jackson"], "Oakland"],
|
|
2402
|
+
["Seattle Mariners", "AL West", "T-Mobile Park", ["Ken Griffey Jr.", "Ichiro Suzuki"]],
|
|
2403
|
+
["Texas Rangers", "AL West", "Globe Life Field", ["Iván Rodríguez", "Nolan Ryan"]],
|
|
2404
|
+
["Atlanta Braves", "NL East", "Truist Park", ["Hank Aaron", "Chipper Jones"], "Milwaukee"],
|
|
2405
|
+
["Miami Marlins", "NL East", "loanDepot park", ["Giancarlo Stanton", "Jeff Conine"]],
|
|
2406
|
+
["New York Mets", "NL East", "Citi Field", ["Tom Seaver", "Mike Piazza"]],
|
|
2407
|
+
["Philadelphia Phillies", "NL East", "Citizens Bank Park", ["Mike Schmidt", "Bryce Harper"]],
|
|
2408
|
+
["Washington Nationals", "NL East", "Nationals Park", ["Ryan Zimmerman", "Max Scherzer"], "Montreal"],
|
|
2409
|
+
["Chicago Cubs", "NL Central", "Wrigley Field", ["Ernie Banks", "Ryne Sandberg"]],
|
|
2410
|
+
["Cincinnati Reds", "NL Central", "Great American Ball Park", ["Johnny Bench", "Pete Rose"]],
|
|
2411
|
+
["Milwaukee Brewers", "NL Central", "American Family Field", ["Robin Yount", "Ryan Braun"], "Seattle"],
|
|
2412
|
+
["Pittsburgh Pirates", "NL Central", "PNC Park", ["Roberto Clemente", "Willie Stargell"]],
|
|
2413
|
+
["St. Louis Cardinals", "NL Central", "Busch Stadium", ["Stan Musial", "Albert Pujols"]],
|
|
2414
|
+
["Arizona Diamondbacks", "NL West", "Chase Field", ["Randy Johnson", "Luis Gonzalez"]],
|
|
2415
|
+
["Colorado Rockies", "NL West", "Coors Field", ["Todd Helton", "Larry Walker"]],
|
|
2416
|
+
["Los Angeles Dodgers", "NL West", "Dodger Stadium", ["Sandy Koufax", "Clayton Kershaw"], "Brooklyn"],
|
|
2417
|
+
["San Diego Padres", "NL West", "Petco Park", ["Tony Gwynn", "Trevor Hoffman"]],
|
|
2418
|
+
["San Francisco Giants", "NL West", "Oracle Park", ["Willie Mays", "Barry Bonds"], "New York"],
|
|
2419
|
+
],
|
|
2420
|
+
oldHomes: { "Baltimore Orioles": ["Milwaukee"], "Atlanta Braves": ["Boston"], "Athletics": ["Kansas City", "Philadelphia"] },
|
|
2421
|
+
oneTeam: { "Cal Ripken Jr.": "Baltimore Orioles", "Brooks Robinson": "Baltimore Orioles", "Ted Williams": "Boston Red Sox", "Derek Jeter": "New York Yankees",
|
|
2422
|
+
"Lou Gehrig": "New York Yankees", "Mariano Rivera": "New York Yankees", "Al Kaline": "Detroit Tigers", "George Brett": "Kansas City Royals",
|
|
2423
|
+
"Salvador Pérez": "Kansas City Royals", "Kirby Puckett": "Minnesota Twins", "Joe Mauer": "Minnesota Twins", "Mike Trout": "Los Angeles Angels",
|
|
2424
|
+
"Tim Salmon": "Los Angeles Angels", "Chipper Jones": "Atlanta Braves", "Tony Gwynn": "San Diego Padres", "Ernie Banks": "Chicago Cubs",
|
|
2425
|
+
"Johnny Bench": "Cincinnati Reds", "Robin Yount": "Milwaukee Brewers", "Roberto Clemente": "Pittsburgh Pirates", "Willie Stargell": "Pittsburgh Pirates",
|
|
2426
|
+
"Stan Musial": "St. Louis Cardinals", "Sandy Koufax": "Los Angeles Dodgers", "Clayton Kershaw": "Los Angeles Dodgers", "Todd Helton": "Colorado Rockies",
|
|
2427
|
+
"Ryan Zimmerman": "Washington Nationals", "Bob Feller": "Cleveland Guardians", "Craig Biggio": "Houston Astros", "Jeff Bagwell": "Houston Astros",
|
|
2428
|
+
"Mike Schmidt": "Philadelphia Phillies", "Edgar Martínez": "Seattle Mariners", "Ryan Braun": "Milwaukee Brewers" },
|
|
2429
|
+
},
|
|
2430
|
+
};
|
|
2431
|
+
// First season of each franchise (wherever it started). Wrong year choices are always 8+ years away, so
|
|
2432
|
+
// franchises with two possible "start" years (a league switch, a renamed club) can't make a wrong answer right.
|
|
2433
|
+
const TEAM_FIRST_SEASON = {
|
|
2434
|
+
nfl: { "Buffalo Bills": 1960, "Miami Dolphins": 1966, "New England Patriots": 1960, "New York Jets": 1960, "Baltimore Ravens": 1996,
|
|
2435
|
+
"Cincinnati Bengals": 1968, "Cleveland Browns": 1946, "Pittsburgh Steelers": 1933, "Houston Texans": 2002, "Indianapolis Colts": 1953,
|
|
2436
|
+
"Jacksonville Jaguars": 1995, "Tennessee Titans": 1960, "Denver Broncos": 1960, "Kansas City Chiefs": 1960, "Las Vegas Raiders": 1960,
|
|
2437
|
+
"Los Angeles Chargers": 1960, "Dallas Cowboys": 1960, "New York Giants": 1925, "Philadelphia Eagles": 1933, "Washington Commanders": 1932,
|
|
2438
|
+
"Chicago Bears": 1920, "Detroit Lions": 1930, "Green Bay Packers": 1921, "Minnesota Vikings": 1961, "Atlanta Falcons": 1966,
|
|
2439
|
+
"Carolina Panthers": 1995, "New Orleans Saints": 1967, "Tampa Bay Buccaneers": 1976, "Arizona Cardinals": 1920, "San Francisco 49ers": 1946,
|
|
2440
|
+
"Seattle Seahawks": 1976, "Los Angeles Rams": 1937 },
|
|
2441
|
+
nba: { "Boston Celtics": 1946, "Brooklyn Nets": 1967, "New York Knicks": 1946, "Philadelphia 76ers": 1946, "Toronto Raptors": 1995,
|
|
2442
|
+
"Chicago Bulls": 1966, "Cleveland Cavaliers": 1970, "Detroit Pistons": 1941, "Indiana Pacers": 1967, "Milwaukee Bucks": 1968,
|
|
2443
|
+
"Atlanta Hawks": 1946, "Charlotte Hornets": 1988, "Miami Heat": 1988, "Orlando Magic": 1989, "Washington Wizards": 1961,
|
|
2444
|
+
"Denver Nuggets": 1967, "Minnesota Timberwolves": 1989, "Oklahoma City Thunder": 1967, "Portland Trail Blazers": 1970, "Utah Jazz": 1974,
|
|
2445
|
+
"Golden State Warriors": 1946, "Los Angeles Clippers": 1970, "Los Angeles Lakers": 1947, "Phoenix Suns": 1968, "Sacramento Kings": 1945,
|
|
2446
|
+
"Dallas Mavericks": 1980, "Houston Rockets": 1967, "Memphis Grizzlies": 1995, "New Orleans Pelicans": 2002, "San Antonio Spurs": 1967 },
|
|
2447
|
+
mlb: { "Baltimore Orioles": 1901, "Boston Red Sox": 1901, "New York Yankees": 1903, "Tampa Bay Rays": 1998, "Toronto Blue Jays": 1977,
|
|
2448
|
+
"Chicago White Sox": 1901, "Cleveland Guardians": 1901, "Detroit Tigers": 1901, "Kansas City Royals": 1969, "Minnesota Twins": 1901,
|
|
2449
|
+
"Houston Astros": 1962, "Los Angeles Angels": 1961, "Athletics": 1901, "Seattle Mariners": 1977, "Texas Rangers": 1961,
|
|
2450
|
+
"Atlanta Braves": 1876, "Miami Marlins": 1993, "New York Mets": 1962, "Philadelphia Phillies": 1883, "Washington Nationals": 1969,
|
|
2451
|
+
"Chicago Cubs": 1876, "Cincinnati Reds": 1882, "Milwaukee Brewers": 1969, "Pittsburgh Pirates": 1882, "St. Louis Cardinals": 1882,
|
|
2452
|
+
"Arizona Diamondbacks": 1998, "Colorado Rockies": 1993, "Los Angeles Dodgers": 1884, "San Diego Padres": 1969, "San Francisco Giants": 1883 },
|
|
2453
|
+
};
|
|
2454
|
+
const NBA_EAST = ["Atlantic", "Central", "Southeast"];
|
|
2455
|
+
const conferenceOf = (league, div) => (league === "nba" ? (NBA_EAST.includes(div) ? "East" : "West") : div.split(" ")[0]);
|
|
2456
|
+
// Turns one team's facts into a quiz at the chosen level ("" mixes all three):
|
|
2457
|
+
// easy: its division, its best-known legend, a division rival and its home field, each against choices from the other conference
|
|
2458
|
+
// medium: the same facts against close choices (same conference), plus its second legend
|
|
2459
|
+
// hard: its first season, where it used to play, the odd one out of its division, and stars against same-conference stars
|
|
2460
|
+
function teamQuestions(league, teamName, level = "") {
|
|
2461
|
+
const L = TEAM_FACTS[league], teams = L.teams, t = teams.find((x) => x[0] === teamName);
|
|
2462
|
+
const [name, div, venue, stars, oldCity] = t;
|
|
2463
|
+
const conf = conferenceOf(league, div);
|
|
2464
|
+
const pick = (list, n) => shuffle(list.slice()).slice(0, n);
|
|
2465
|
+
const sameConf = (x) => conferenceOf(league, x[1]) === conf, otherConf = (x) => !sameConf(x);
|
|
2466
|
+
const teamOf = (n) => teams.find((x) => x[0] === n);
|
|
2467
|
+
const qs = [];
|
|
2468
|
+
const add = (lv, q, right, wrong) => { if (wrong.length >= 3) qs.push({ lv, q, right, topic: name, answers: shuffle([right, ...wrong.slice(0, 3)]) }); };
|
|
2469
|
+
// stars that only ever played for some other team (so they can't be right by accident)
|
|
2470
|
+
const otherStars = (filter) => Object.entries(L.oneTeam)
|
|
2471
|
+
.filter(([p, team]) => team !== name && !stars.includes(p) && filter(teamOf(team))).map(([p]) => p);
|
|
2472
|
+
const rivals = teams.filter((x) => x[1] === div && x[0] !== name);
|
|
2473
|
+
const divisions = [...new Set(teams.map((x) => x[1]))].filter((d) => d !== div);
|
|
2474
|
+
const venues = (filter) => [...new Set(teams.filter((x) => x[2] && x[2] !== venue && filter(x)).map((x) => x[2]))];
|
|
2475
|
+
|
|
2476
|
+
// easy
|
|
2477
|
+
add("e", `Which division do the ${name} play in?`, div, pick(divisions.filter((d) => conferenceOf(league, d) !== conf), 3));
|
|
2478
|
+
add("e", `Which of these players is a ${name} legend?`, stars[0], pick(otherStars(otherConf), 3));
|
|
2479
|
+
add("e", `Which team is in the same division as the ${name}?`, pick(rivals, 1)[0][0], pick(teams.filter(otherConf), 3).map((x) => x[0]));
|
|
2480
|
+
if (venue) add("e", `Which team plays its home games at ${venue}?`, name, pick(teams.filter((x) => otherConf(x) && x[2] !== venue), 3).map((x) => x[0]));
|
|
2481
|
+
// medium
|
|
2482
|
+
add("m", `Which division do the ${name} play in?`, div, pick(divisions.filter((d) => conferenceOf(league, d) === conf), 3).concat(pick(divisions, 3)).filter((d, i, all) => all.indexOf(d) === i));
|
|
2483
|
+
add("m", `Which of these players is a ${name} legend?`, stars[1], pick(otherStars(() => true), 3));
|
|
2484
|
+
if (venue) add("m", `What is the ${name}' home ${L.venue}?`, venue, pick(venues(() => true), 3));
|
|
2485
|
+
add("m", `Which team is in the same division as the ${name}?`, pick(rivals, 1)[0][0], pick(teams.filter((x) => sameConf(x) && x[1] !== div), 3).map((x) => x[0]));
|
|
2486
|
+
// hard
|
|
2487
|
+
const year = TEAM_FIRST_SEASON[league][name];
|
|
2488
|
+
if (year) {
|
|
2489
|
+
const years = [...new Set(Object.values(TEAM_FIRST_SEASON[league]))].filter((y) => Math.abs(y - year) >= 8);
|
|
2490
|
+
const wrong = [];
|
|
2491
|
+
for (const y of shuffle(years)) if (wrong.every((w) => Math.abs(w - y) >= 4) && wrong.length < 3) wrong.push(y);
|
|
2492
|
+
add("h", `In what year did the ${name} franchise play its first season?`, String(year), wrong.map(String));
|
|
2493
|
+
}
|
|
2494
|
+
if (oldCity) {
|
|
2495
|
+
const avoid = [oldCity, ...((L.oldHomes || {})[name] || [])];
|
|
2496
|
+
const cities = [...new Set(teams.map((x) => x[4]).filter(Boolean).concat(["Kansas City", "Seattle", "Montreal", "Oakland", "St. Louis", "Baltimore", "San Diego"]))]
|
|
2497
|
+
.filter((c) => !avoid.includes(c) && !name.startsWith(c));
|
|
2498
|
+
add("h", `The ${name} franchise used to play in which city?`, oldCity, pick(cities, 3));
|
|
2499
|
+
}
|
|
2500
|
+
const outsider = pick(teams.filter((x) => sameConf(x) && x[1] !== div), 1)[0];
|
|
2501
|
+
if (rivals.length >= 3) add("h", `Which of these teams is NOT in the same division as the ${name}?`, outsider[0], pick(rivals, 3).map((x) => x[0]));
|
|
2502
|
+
add("h", `Which of these players is a ${name} legend?`, stars[1], pick(otherStars(sameConf), 3));
|
|
2503
|
+
if (venue) add("h", `What is the ${name}' home ${L.venue}?`, venue, pick(venues(sameConf), 3));
|
|
2504
|
+
|
|
2505
|
+
// plus any regular league question that's about this team ("Steel Curtain" for the Steelers), at its own level
|
|
2506
|
+
const words = name.split(" "), two = /^(Sox|Jays|Blazers)$/.test(words.at(-1));
|
|
2507
|
+
const nick = words.slice(two ? -2 : -1).join(" ");
|
|
2508
|
+
const about = new RegExp(`\\b${nick.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\b`);
|
|
2509
|
+
for (const [l, , q, right, ...wrong] of TRIVIA_LEAGUES[league]) {
|
|
2510
|
+
if ((about.test(q) || about.test(right)) && !(venue && q.includes(venue))) // its home field is asked about already
|
|
2511
|
+
qs.push({ lv: l, q, right, topic: name, answers: shuffle([right, ...wrong]) });
|
|
2512
|
+
}
|
|
2513
|
+
const lv = level ? level[0] : "";
|
|
2514
|
+
let out = qs.filter((q) => !lv || q.lv === lv);
|
|
2515
|
+
if (!lv) out = shuffle(out).filter((q, i, all) => all.findIndex((o) => o.q === q.q) === i); // "Any": each kind of question once
|
|
2516
|
+
return shuffle(out).slice(0, TRIVIA_COUNT);
|
|
2517
|
+
}
|
|
2518
|
+
|
|
2519
|
+
// Puzzle sites: "embed" ones play inside the page; the rest refuse to be framed and open in a new tab
|
|
2520
|
+
const TRIVIA_SITES = [
|
|
2521
|
+
{ id: "worldle", name: "Worldle", icon: "🌍", url: "https://worldle.teuteuf.fr/", desc: "Guess the country from its shape" }, // its makers ask not to be shown inside other sites
|
|
2522
|
+
{ id: "globle", name: "Globle", icon: "🌐", url: "https://globle-game.com/", desc: "Find the mystery country on the globe", embed: true },
|
|
2523
|
+
{ id: "travle", name: "Travle", icon: "🧭", url: "https://travle.earth/", desc: "Travel between two countries" }, // same makers as Worldle, same request
|
|
2524
|
+
{ id: "triviaplaza", name: "TriviaPlaza", icon: "❓", url: "https://www.triviaplaza.com/", desc: "Quizzes by topic", embed: true },
|
|
2525
|
+
{ id: "funtrivia", name: "FunTrivia", icon: "🎲", url: "https://www.funtrivia.com/", desc: "Huge trivia library and games", embed: true },
|
|
2526
|
+
{ id: "grid-football", name: "Immaculate Grid: Football", icon: "🏈", url: "https://www.sports-reference.com/immaculate-grid/football/", desc: "Name players who fit the row and column" },
|
|
2527
|
+
{ id: "grid-baseball", name: "Immaculate Grid: Baseball", icon: "⚾", url: "https://www.sports-reference.com/immaculate-grid/", desc: "The baseball version" },
|
|
2528
|
+
{ id: "krillion", name: "Krillion", icon: "🦐", url: "https://krillion.io/", desc: "Daily puzzle" },
|
|
2529
|
+
{ id: "wordle", name: "Wordle", icon: "🟨", url: "https://www.nytimes.com/games/wordle/index.html", desc: "The daily five-letter word" },
|
|
2530
|
+
{ id: "connections", name: "Connections (NYT)", icon: "🟪", url: "https://www.nytimes.com/games/connections", desc: "Sort 16 words into 4 groups" },
|
|
2531
|
+
];
|
|
2532
|
+
const trivia = { topic: 0, level: "", kind: "all", team: "", qs: [], i: 0, score: 0, right: 0, streak: 0, best: 0, timer: 0, ends: 0, locked: true, token: null, started: false };
|
|
2533
|
+
|
|
2534
|
+
const triviaBestKey = () => (TRIVIA_LEAGUES[trivia.topic] && trivia.team ? `${trivia.topic}-team-${trivia.team}-${trivia.level}`
|
|
2535
|
+
: `${trivia.topic}-${trivia.level}` + (TRIVIA_LEAGUES[trivia.topic] ? `-${trivia.kind}` : ""));
|
|
2536
|
+
function renderTriviaChoices() {
|
|
2537
|
+
const tab = (label, val, on, kind) => `<button class="trivia-opt" role="tab" type="button" data-${kind}="${val}" aria-selected="${on}">${escapeHtml(label)}</button>`;
|
|
2538
|
+
$("trivia-cats").innerHTML = TRIVIA_TOPICS.map(([l, v]) => tab(l, v, v === trivia.topic, "topic")).join("");
|
|
2539
|
+
$("trivia-diff").innerHTML = TRIVIA_LEVELS.map(([l, v]) => tab(l, v, v === trivia.level, "level")).join("");
|
|
2540
|
+
$("trivia-kind").innerHTML = TRIVIA_KINDS.map(([l, v]) => tab(l, v, v === trivia.kind, "kind")).join("");
|
|
2541
|
+
const league = TRIVIA_LEAGUES[trivia.topic] ? trivia.topic : null;
|
|
2542
|
+
$("trivia-team-row").hidden = !league;
|
|
2543
|
+
if (league && $("trivia-team").dataset.league !== league) {
|
|
2544
|
+
$("trivia-team").dataset.league = league;
|
|
2545
|
+
$("trivia-team").innerHTML = `<option value="">All teams</option>` + TEAM_FACTS[league].teams.map((t) => t[0]).sort()
|
|
2546
|
+
.map((n) => `<option value="${escapeHtml(n)}">${escapeHtml(n)}</option>`).join("");
|
|
2547
|
+
}
|
|
2548
|
+
if (league) $("trivia-team").value = trivia.team;
|
|
2549
|
+
$("trivia-kind-row").hidden = !league || !!trivia.team;
|
|
2550
|
+
const best = store.get(TRIVIA_BEST_KEY, {})[triviaBestKey()];
|
|
2551
|
+
$("trivia-best").textContent = best ? `Your best here: ${best.toLocaleString()} points` : "";
|
|
2552
|
+
}
|
|
2553
|
+
function renderTriviaSites() {
|
|
2554
|
+
// the ones that play here first
|
|
2555
|
+
$("trivia-sites").innerHTML = [...TRIVIA_SITES].sort((a, b) => !!b.embed - !!a.embed).map((s) => `<button class="trivia-site" type="button" data-site="${s.id}">` +
|
|
2556
|
+
`<span class="trivia-site-art"><img src="logos/trivia-${s.id}.webp" alt="" loading="lazy" decoding="async" onerror="this.remove()"></span>` +
|
|
2557
|
+
`<span class="trivia-site-text"><b>${escapeHtml(s.name)}</b><small>${escapeHtml(s.desc)}</small></span>` +
|
|
2558
|
+
`<span class="trivia-site-how">${s.embed ? "Play" : "New tab ↗"}</span></button>`).join("");
|
|
2559
|
+
}
|
|
2560
|
+
function openTriviaSite(site) {
|
|
2561
|
+
if (!site.embed) { window.open(site.url, "_blank", "noopener"); return; }
|
|
2562
|
+
stopTriviaTimer();
|
|
2563
|
+
$("trivia-home").hidden = true;
|
|
2564
|
+
$("trivia-viewer").hidden = false;
|
|
2565
|
+
$("trivia-site-name").textContent = site.name;
|
|
2566
|
+
$("trivia-frame").src = site.url;
|
|
2567
|
+
track(`Trivia site: ${site.name}`);
|
|
2568
|
+
}
|
|
2569
|
+
function closeTriviaSite() {
|
|
2570
|
+
if ($("trivia-viewer").hidden) return;
|
|
2571
|
+
$("trivia-frame").src = "about:blank";
|
|
2572
|
+
$("trivia-viewer").hidden = true;
|
|
2573
|
+
$("trivia-home").hidden = false;
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2576
|
+
const decode = (s) => { try { return decodeURIComponent(s); } catch { return s; } };
|
|
2577
|
+
const shuffle = (a) => { for (let i = a.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [a[i], a[j]] = [a[j], a[i]]; } return a; };
|
|
2578
|
+
const fromSet = (set, topic) => shuffle(set.slice()).slice(0, TRIVIA_COUNT).map(([q, right, ...wrong]) =>
|
|
2579
|
+
({ q, right, topic, answers: shuffle([right, ...wrong]) }));
|
|
2580
|
+
async function triviaQuestions() {
|
|
2581
|
+
if (TRIVIA_LEAGUES[trivia.topic] && trivia.team) return teamQuestions(trivia.topic, trivia.team, trivia.level);
|
|
2582
|
+
if (TRIVIA_LEAGUES[trivia.topic]) {
|
|
2583
|
+
const lv = trivia.level ? trivia.level[0] : "", kind = { players: "p", teams: "t" }[trivia.kind];
|
|
2584
|
+
const pool = TRIVIA_LEAGUES[trivia.topic].filter(([l, k]) => (!lv || l === lv) && (!kind || k === kind)).map((q) => q.slice(2));
|
|
2585
|
+
return fromSet(pool, trivia.topic.toUpperCase() + (kind === "p" ? " players" : ""));
|
|
2586
|
+
}
|
|
2587
|
+
const get = async (url) => (await fetch(url, { signal: AbortSignal.timeout(8000) })).json();
|
|
1909
2588
|
try {
|
|
1910
|
-
|
|
1911
|
-
const
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
$("live-screen").srcObject = screenOut;
|
|
1922
|
-
$("live-cam").srcObject = camOut;
|
|
1923
|
-
$("live-cam").hidden = !camOut;
|
|
1924
|
-
screen?.getVideoTracks()[0]?.addEventListener("ended", endLive); // "Stop sharing" in the browser bar
|
|
1925
|
-
const db = (await getFirebase()).database();
|
|
1926
|
-
await db.ref("live/viewers").remove();
|
|
1927
|
-
db.ref("live/state").onDisconnect().remove();
|
|
1928
|
-
db.ref("live/viewers").onDisconnect().remove();
|
|
1929
|
-
await db.ref("live/state").set({ on: true, main: screenOut.id, cam: camOut ? camOut.id : null, ts: window.firebase.database.ServerValue.TIMESTAMP });
|
|
1930
|
-
db.ref("live/viewers").on("child_added", (s) => connectViewer(db, s.key));
|
|
1931
|
-
db.ref("live/viewers").on("child_removed", (s) => { live.peers.get(s.key)?.close(); live.peers.delete(s.key); updateViewerCount(); });
|
|
1932
|
-
renderLive();
|
|
2589
|
+
if (!trivia.token) trivia.token = (await get("https://opentdb.com/api_token.php?command=request")).token;
|
|
2590
|
+
const url = () => `https://opentdb.com/api.php?amount=${TRIVIA_COUNT}&encode=url3986&token=${trivia.token}` +
|
|
2591
|
+
(trivia.topic ? `&category=${trivia.topic}` : "") + (trivia.level ? `&difficulty=${trivia.level}` : "");
|
|
2592
|
+
let d = await get(url());
|
|
2593
|
+
if (d.response_code === 4) { await get(`https://opentdb.com/api_token.php?command=reset&token=${trivia.token}`); d = await get(url()); } // seen them all: start over
|
|
2594
|
+
if (d.response_code === 5) { await new Promise((r) => setTimeout(r, 5200)); d = await get(url()); } // one request per 5s
|
|
2595
|
+
if (d.response_code !== 0 || !d.results?.length) throw new Error(`code ${d.response_code}`);
|
|
2596
|
+
return d.results.map((q) => ({
|
|
2597
|
+
q: decode(q.question), right: decode(q.correct_answer), topic: decode(q.category),
|
|
2598
|
+
answers: q.type === "boolean" ? ["True", "False"] : shuffle([q.correct_answer, ...q.incorrect_answers].map(decode)),
|
|
2599
|
+
}));
|
|
1933
2600
|
} catch (err) {
|
|
1934
|
-
console.warn(err);
|
|
1935
|
-
|
|
1936
|
-
live.streams = null;
|
|
1937
|
-
toast("Couldn't start the stream (screen, camera or mic was blocked).");
|
|
2601
|
+
console.warn("Trivia questions unavailable, using the built-in set:", err.message);
|
|
2602
|
+
return fromSet(TRIVIA_BACKUP, "Mixed");
|
|
1938
2603
|
}
|
|
1939
2604
|
}
|
|
1940
|
-
function
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
if (el.srcObject !== stream) el.srcObject = stream;
|
|
1985
|
-
if (isCam) { $("live-cam").hidden = false; return; }
|
|
1986
|
-
// sound needs a tap first on some browsers: try with sound, else start muted and offer the button
|
|
1987
|
-
el.muted = false;
|
|
1988
|
-
el.play().catch(() => { el.muted = true; el.play().catch(() => {}); $("live-unmute").hidden = false; });
|
|
1989
|
-
};
|
|
1990
|
-
pc.onicecandidate = (e) => { if (e.candidate) ref.child("vice").push(JSON.stringify(e.candidate)); };
|
|
1991
|
-
pc.onconnectionstatechange = () => {
|
|
1992
|
-
if (pc.connectionState === "failed") { toast("Couldn't connect to the stream (your network may block it)."); stopWatching(); renderLive(); }
|
|
1993
|
-
};
|
|
1994
|
-
await ref.remove().catch(() => {});
|
|
1995
|
-
ref.onDisconnect().remove();
|
|
1996
|
-
await ref.set({ join: window.firebase.database.ServerValue.TIMESTAMP });
|
|
1997
|
-
ref.child("offer").on("value", async (s) => {
|
|
1998
|
-
const o = s.val();
|
|
1999
|
-
if (!o || pc.currentRemoteDescription) return;
|
|
2000
|
-
await pc.setRemoteDescription(o);
|
|
2001
|
-
const ans = await pc.createAnswer();
|
|
2002
|
-
await pc.setLocalDescription(ans);
|
|
2003
|
-
await ref.child("answer").set({ type: ans.type, sdp: ans.sdp });
|
|
2605
|
+
function triviaScreen(which) {
|
|
2606
|
+
for (const id of ["setup", "play", "done"]) $(`trivia-${id}`).hidden = id !== which;
|
|
2607
|
+
}
|
|
2608
|
+
async function startTrivia() {
|
|
2609
|
+
triviaScreen("play");
|
|
2610
|
+
Object.assign(trivia, { qs: [], i: 0, score: 0, right: 0, streak: 0, best: 0, locked: true });
|
|
2611
|
+
$("trivia-q").textContent = "Getting questions…";
|
|
2612
|
+
$("trivia-answers").innerHTML = "";
|
|
2613
|
+
$("trivia-note").textContent = "";
|
|
2614
|
+
$("trivia-count").textContent = $("trivia-topic").textContent = $("trivia-score").textContent = "";
|
|
2615
|
+
$("trivia-time").style.width = "100%";
|
|
2616
|
+
trivia.qs = await triviaQuestions();
|
|
2617
|
+
if ($("view-trivia").hidden) return; // left the page while loading
|
|
2618
|
+
showTriviaQuestion();
|
|
2619
|
+
}
|
|
2620
|
+
function showTriviaQuestion() {
|
|
2621
|
+
const q = trivia.qs[trivia.i];
|
|
2622
|
+
trivia.locked = false;
|
|
2623
|
+
$("trivia-count").textContent = `Question ${trivia.i + 1} of ${trivia.qs.length}`;
|
|
2624
|
+
$("trivia-topic").textContent = q.topic;
|
|
2625
|
+
$("trivia-score").textContent = `${trivia.score.toLocaleString()} pts${trivia.streak >= 2 ? ` · ${trivia.streak} in a row` : ""}`;
|
|
2626
|
+
$("trivia-q").textContent = q.q;
|
|
2627
|
+
$("trivia-answers").innerHTML = q.answers.map((a, i) =>
|
|
2628
|
+
`<button class="trivia-answer" type="button" data-i="${i}"><kbd>${i + 1}</kbd>${escapeHtml(a)}</button>`).join("");
|
|
2629
|
+
$("trivia-note").textContent = "";
|
|
2630
|
+
trivia.ends = Date.now() + TRIVIA_SECONDS * 1000;
|
|
2631
|
+
stopTriviaTimer();
|
|
2632
|
+
trivia.timer = setInterval(() => {
|
|
2633
|
+
const left = Math.max(0, trivia.ends - Date.now());
|
|
2634
|
+
$("trivia-time").style.width = `${(left / (TRIVIA_SECONDS * 1000)) * 100}%`;
|
|
2635
|
+
if (!left) answerTrivia(-1);
|
|
2636
|
+
}, 100);
|
|
2637
|
+
}
|
|
2638
|
+
function stopTriviaTimer() { clearInterval(trivia.timer); trivia.timer = 0; }
|
|
2639
|
+
function answerTrivia(i) {
|
|
2640
|
+
if (trivia.locked) return;
|
|
2641
|
+
trivia.locked = true;
|
|
2642
|
+
stopTriviaTimer();
|
|
2643
|
+
const q = trivia.qs[trivia.i], picked = q.answers[i], ok = picked === q.right;
|
|
2644
|
+
const left = Math.max(0, trivia.ends - Date.now()) / 1000;
|
|
2645
|
+
$("trivia-answers").querySelectorAll(".trivia-answer").forEach((b, j) => {
|
|
2646
|
+
b.disabled = true;
|
|
2647
|
+
if (q.answers[j] === q.right) b.classList.add("right");
|
|
2648
|
+
else if (j === i) b.classList.add("wrong");
|
|
2004
2649
|
});
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2650
|
+
if (ok) {
|
|
2651
|
+
trivia.streak++;
|
|
2652
|
+
trivia.right++;
|
|
2653
|
+
const pts = 100 + Math.round((left / TRIVIA_SECONDS) * 100) + Math.min(50, (trivia.streak - 1) * 10); // speed + streak bonus
|
|
2654
|
+
trivia.score += pts;
|
|
2655
|
+
trivia.best = Math.max(trivia.best, trivia.streak);
|
|
2656
|
+
$("trivia-note").textContent = `Right! +${pts}`;
|
|
2657
|
+
} else {
|
|
2658
|
+
trivia.streak = 0;
|
|
2659
|
+
$("trivia-note").textContent = i < 0 ? `Time's up! It was ${q.right}.` : `Not quite. It was ${q.right}.`;
|
|
2660
|
+
}
|
|
2661
|
+
$("trivia-score").textContent = `${trivia.score.toLocaleString()} pts`;
|
|
2662
|
+
setTimeout(() => {
|
|
2663
|
+
if ($("view-trivia").hidden) return;
|
|
2664
|
+
trivia.i++;
|
|
2665
|
+
if (trivia.i < trivia.qs.length) showTriviaQuestion(); else finishTrivia();
|
|
2666
|
+
}, ok ? 1100 : 1900);
|
|
2667
|
+
}
|
|
2668
|
+
function finishTrivia() {
|
|
2669
|
+
triviaScreen("done");
|
|
2670
|
+
const key = triviaBestKey(), bests = store.get(TRIVIA_BEST_KEY, {});
|
|
2671
|
+
const record = trivia.score > (bests[key] || 0);
|
|
2672
|
+
if (record) { bests[key] = trivia.score; store.set(TRIVIA_BEST_KEY, bests); }
|
|
2673
|
+
$("trivia-final").textContent = `${trivia.score.toLocaleString()} points`;
|
|
2674
|
+
$("trivia-summary").textContent = `${trivia.right} of ${trivia.qs.length} right` +
|
|
2675
|
+
(trivia.best >= 3 ? `, best streak ${trivia.best}` : "") + (record && trivia.score ? ". New personal best!" : ".");
|
|
2676
|
+
}
|
|
2677
|
+
function bindTrivia() {
|
|
2678
|
+
renderTriviaChoices();
|
|
2679
|
+
renderTriviaSites();
|
|
2680
|
+
$("trivia-cats").addEventListener("click", (e) => { const b = e.target.closest("[data-topic]"); if (b) { const v = b.dataset.topic; trivia.topic = /^\d+$/.test(v) ? Number(v) : v; trivia.team = ""; renderTriviaChoices(); } });
|
|
2681
|
+
$("trivia-diff").addEventListener("click", (e) => { const b = e.target.closest("[data-level]"); if (b) { trivia.level = b.dataset.level; renderTriviaChoices(); } });
|
|
2682
|
+
$("trivia-team").addEventListener("change", (e) => { trivia.team = e.target.value; renderTriviaChoices(); });
|
|
2683
|
+
$("trivia-kind").addEventListener("click", (e) => { const b = e.target.closest("[data-kind]"); if (b) { trivia.kind = b.dataset.kind; renderTriviaChoices(); } });
|
|
2684
|
+
$("trivia-start").addEventListener("click", startTrivia);
|
|
2685
|
+
$("trivia-again").addEventListener("click", startTrivia);
|
|
2686
|
+
$("trivia-change").addEventListener("click", () => { renderTriviaChoices(); triviaScreen("setup"); });
|
|
2687
|
+
$("trivia-answers").addEventListener("click", (e) => { const b = e.target.closest("[data-i]"); if (b) answerTrivia(Number(b.dataset.i)); });
|
|
2688
|
+
$("trivia-sites").addEventListener("click", (e) => { const b = e.target.closest("[data-site]"); if (b) openTriviaSite(TRIVIA_SITES.find((s) => s.id === b.dataset.site)); });
|
|
2689
|
+
$("trivia-back").addEventListener("click", closeTriviaSite);
|
|
2690
|
+
$("trivia-full").addEventListener("click", () => { const f = $("trivia-frame"); (f.requestFullscreen || f.webkitRequestFullscreen)?.call(f); });
|
|
2691
|
+
// number keys 1-4 answer while a question is up
|
|
2692
|
+
document.addEventListener("keydown", (e) => {
|
|
2693
|
+
if ($("view-trivia").hidden || $("trivia-play").hidden || trivia.locked || e.ctrlKey || e.metaKey || e.altKey) return;
|
|
2694
|
+
if (/^(INPUT|TEXTAREA|SELECT)$/.test(document.activeElement?.tagName || "")) return;
|
|
2695
|
+
const n = Number(e.key);
|
|
2696
|
+
if (n >= 1 && n <= trivia.qs[trivia.i].answers.length) { e.preventDefault(); answerTrivia(n - 1); }
|
|
2697
|
+
});
|
|
2698
|
+
}
|
|
2699
|
+
|
|
2700
|
+
// ---------- AI chat ----------
|
|
2701
|
+
// One chatbot backed by several free AI services. It tries them in order (Gemini, Groq, OpenRouter,
|
|
2702
|
+
// Mistral); when one is out of free messages, down or missing a key, it moves to the next.
|
|
2703
|
+
// Keys go in config.js (ai: { gemini, groq, openrouter, mistral }). Models are picked from each service's
|
|
2704
|
+
// own current list, so renamed models don't break it. The conversation is kept in this browser only.
|
|
2705
|
+
const AI_KEY = "rug-ai-chat";
|
|
2706
|
+
const AI_SYSTEM = "You are the helpful AI on richardwho, a games site used by students. Be friendly, clear and fairly short. " +
|
|
2707
|
+
"Help with homework by explaining how to solve things, not just giving answers. Keep everything appropriate for school: " +
|
|
2708
|
+
"no sexual content, no graphic violence, nothing hateful, nothing dangerous or illegal. Use Markdown for lists and code. " +
|
|
2709
|
+
"Never use LaTeX; write math in plain text (like CO2, x^2, 6CO2 + 6H2O -> C6H12O6 + 6O2).";
|
|
2710
|
+
const ai = { busy: false, models: {}, chats: [], currentId: null, pendingImg: null };
|
|
2711
|
+
const aiKeys = () => CFG.ai || {};
|
|
2712
|
+
const AI_SERVICES = [
|
|
2713
|
+
{ id: "gemini", name: "Gemini",
|
|
2714
|
+
async pickModel(key) {
|
|
2715
|
+
const r = await fetch("https://generativelanguage.googleapis.com/v1beta/models?pageSize=200", { headers: { "x-goog-api-key": key } });
|
|
2716
|
+
const list = (await r.json()).models || [];
|
|
2717
|
+
const ok = list.filter((m) => (m.supportedGenerationMethods || []).includes("generateContent") && /gemini/.test(m.name) && !/(image|tts|audio|embedding|live|preview-tts|robotics)/.test(m.name));
|
|
2718
|
+
// newest first, full flash before lite; the newest often has no free messages, so ask() walks down the list
|
|
2719
|
+
const rank = (m) => (/flash/.test(m.name) ? 0 : 2) + (/lite/.test(m.name) ? 1 : 0);
|
|
2720
|
+
const names = ok.filter((m) => !/preview|latest|omni/.test(m.name))
|
|
2721
|
+
.sort((a, b) => rank(a) - rank(b) || b.name.localeCompare(a.name, undefined, { numeric: true })).map((m) => m.name);
|
|
2722
|
+
// the model that worked last time goes first, so only the very first visit has to search
|
|
2723
|
+
let good = null;
|
|
2724
|
+
try { good = localStorage.getItem("rug-ai-gemini"); } catch {}
|
|
2725
|
+
// the model set in config.js first, then the one that worked last time, then the rest
|
|
2726
|
+
for (const want of [good, aiKeys().geminiModel && "models/" + aiKeys().geminiModel]) {
|
|
2727
|
+
if (want && names.includes(want)) names.unshift(...names.splice(names.indexOf(want), 1));
|
|
2728
|
+
}
|
|
2729
|
+
return names.length ? names : null;
|
|
2730
|
+
},
|
|
2731
|
+
async ask(key, models, msgs) {
|
|
2732
|
+
let good = null;
|
|
2733
|
+
try { good = localStorage.getItem("rug-ai-gemini"); } catch {}
|
|
2734
|
+
for (const model of [...models]) {
|
|
2735
|
+
// an untested model gets 8s (overloaded ones just hang); a known-good one gets time for long answers
|
|
2736
|
+
const r = await fetch(`https://generativelanguage.googleapis.com/v1beta/${model}:generateContent`, {
|
|
2737
|
+
method: "POST", headers: { "Content-Type": "application/json", "x-goog-api-key": key }, signal: AbortSignal.timeout(model === good ? 45000 : 8000),
|
|
2738
|
+
body: JSON.stringify({ systemInstruction: { parts: [{ text: AI_SYSTEM }] },
|
|
2739
|
+
contents: msgs.map((m) => ({ role: m.role === "assistant" ? "model" : "user", parts: [{ text: m.text },
|
|
2740
|
+
...(m.img ? [{ inline_data: { mime_type: m.img.slice(5, m.img.indexOf(";")), data: m.img.slice(m.img.indexOf(",") + 1) } }] : [])] })) }),
|
|
2741
|
+
}).catch(() => ({ ok: false, status: "timeout" }));
|
|
2742
|
+
if (!r.ok) { models.splice(models.indexOf(model), 1); continue; } // out of free messages for this model: next one
|
|
2743
|
+
try { localStorage.setItem("rug-ai-gemini", model); } catch {}
|
|
2744
|
+
const d = await r.json();
|
|
2745
|
+
return (d.candidates?.[0]?.content?.parts || []).map((p) => p.text || "").join("").trim();
|
|
2746
|
+
}
|
|
2747
|
+
throw new Error("gemini: no model with free messages left");
|
|
2748
|
+
} },
|
|
2749
|
+
{ id: "groq", name: "Groq", base: "https://api.groq.com/openai/v1",
|
|
2750
|
+
prefer: [/llama.*70b/, /llama/, /qwen/, /gpt-oss/], avoid: /(whisper|guard|tts|vision|embed)/ },
|
|
2751
|
+
{ id: "openrouter", name: "OpenRouter", base: "https://openrouter.ai/api/v1",
|
|
2752
|
+
prefer: [/llama/, /gemma/, /qwen/, /mistral/, /nemotron.*super/, /./], avoid: /(content-safety|code|coder|guard|vision|vl|embed)/, freeOnly: true },
|
|
2753
|
+
{ id: "mistral", name: "Mistral", base: "https://api.mistral.ai/v1",
|
|
2754
|
+
prefer: [/mistral-small-latest/, /mistral-medium-latest/, /mistral-large-latest/, /mistral/], avoid: /(embed|ocr|moderation|codestral|pixtral)/ },
|
|
2033
2755
|
];
|
|
2034
|
-
|
|
2035
|
-
const
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
if (chat.banned) { toast("You can't send gifts right now."); return; }
|
|
2049
|
-
const n = chat.admin ? { name: ADMIN_NAME } : cleanName($("chat-name").value);
|
|
2050
|
-
if (n.error) { toast("Type a nickname in the chat box first, so everyone knows who sent it."); $("chat-name").focus(); return; }
|
|
2051
|
-
const app = await getFirebase();
|
|
2052
|
-
if (!app || !chat.uid) return;
|
|
2053
|
-
const db = app.database(), TS = window.firebase.database.ServerValue.TIMESTAMP;
|
|
2054
|
-
try {
|
|
2055
|
-
await db.ref().update({
|
|
2056
|
-
[`live/gifts/${db.ref("live/gifts").push().key}`]: { name: n.name, gift: g.id, uid: chat.uid, ts: TS },
|
|
2057
|
-
[`live/giftLast/${chat.uid}`]: TS,
|
|
2756
|
+
// Groq, OpenRouter and Mistral all speak the same (OpenAI-style) format
|
|
2757
|
+
const openAiStyle = {
|
|
2758
|
+
async pickModel(key, svc) {
|
|
2759
|
+
const r = await fetch(`${svc.base}/models`, { headers: { Authorization: `Bearer ${key}` } });
|
|
2760
|
+
let ids = ((await r.json()).data || []).map((m) => m.id).filter((id) => !svc.avoid.test(id));
|
|
2761
|
+
if (svc.freeOnly) ids = ids.filter((id) => id.endsWith(":free"));
|
|
2762
|
+
for (const re of svc.prefer) { const hit = ids.find((id) => re.test(id)); if (hit) return hit; }
|
|
2763
|
+
return ids[0];
|
|
2764
|
+
},
|
|
2765
|
+
async ask(key, model, msgs, svc) {
|
|
2766
|
+
const r = await fetch(`${svc.base}/chat/completions`, {
|
|
2767
|
+
method: "POST",
|
|
2768
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${key}`, ...(svc.id === "openrouter" ? { "X-Title": "richardwho" } : {}) },
|
|
2769
|
+
body: JSON.stringify({ model, messages: [{ role: "system", content: AI_SYSTEM }, ...msgs.map((m) => ({ role: m.role, content: m.img ? m.text + "\n\n(The user attached a picture, but you can't see pictures. Say so if it matters.)" : m.text }))], max_tokens: 1200 }),
|
|
2058
2770
|
});
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2771
|
+
if (!r.ok) throw new Error(`${svc.id} ${r.status}`);
|
|
2772
|
+
const d = await r.json();
|
|
2773
|
+
return (d.choices?.[0]?.message?.content || "").trim();
|
|
2774
|
+
},
|
|
2775
|
+
};
|
|
2776
|
+
function aiReady() { return AI_SERVICES.some((s) => aiKeys()[s.id]); }
|
|
2777
|
+
async function askAi(msgs) {
|
|
2778
|
+
const order = msgs.some((m) => m.img) ? [...AI_SERVICES].sort((x) => (x.id === "gemini" ? -1 : 0)) : AI_SERVICES;
|
|
2779
|
+
for (const svc of order) {
|
|
2780
|
+
const key = aiKeys()[svc.id];
|
|
2781
|
+
if (!key) continue;
|
|
2782
|
+
const impl = svc.ask ? svc : openAiStyle;
|
|
2783
|
+
try {
|
|
2784
|
+
ai.models[svc.id] ||= (aiKeys().models || {})[svc.id] || await impl.pickModel(key, svc);
|
|
2785
|
+
if (!ai.models[svc.id]) throw new Error("no model");
|
|
2786
|
+
const text = await impl.ask(key, ai.models[svc.id], msgs, svc);
|
|
2787
|
+
if (text) return { text, by: svc.name };
|
|
2788
|
+
} catch (err) {
|
|
2789
|
+
console.warn("AI service skipped:", svc.name, err.message); // out of free messages, down, or bad key: try the next
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
throw new Error("all busy");
|
|
2793
|
+
}
|
|
2794
|
+
// Light Markdown: code blocks, inline code, bold, italics, lists, links (everything escaped first)
|
|
2795
|
+
function aiFormat(text) {
|
|
2796
|
+
const blocks = [];
|
|
2797
|
+
let h = escapeHtml(text).replace(/```[a-z0-9+-]*\n?([\s\S]*?)```/gi, (m, code) => { blocks.push(code.replace(/\n$/, "")); return `\u0000${blocks.length - 1}\u0000`; });
|
|
2798
|
+
h = h.replace(/`([^`\n]+)`/g, "<code>$1</code>")
|
|
2799
|
+
.replace(/\*\*([^*\n]+)\*\*/g, "<strong>$1</strong>")
|
|
2800
|
+
.replace(/(^|[\s(])\*([^*\n]+)\*(?=[\s).,!?:;]|$)/g, "$1<em>$2</em>")
|
|
2801
|
+
.replace(/\[([^\]\n]+)\]\((https?:\/\/[^)\s]+)\)/g, '<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>');
|
|
2802
|
+
// line by line; runs of "- item" become a bullet list, runs of "1. item" a numbered list
|
|
2803
|
+
const out = [];
|
|
2804
|
+
let list = null;
|
|
2805
|
+
for (const line of h.split("\n")) {
|
|
2806
|
+
const bullet = line.match(/^\s*[-*•] (.*)/), num = line.match(/^\s*\d+[.)] (.*)/);
|
|
2807
|
+
const kind = bullet ? "ul" : num ? "ol" : null;
|
|
2808
|
+
if (list && list !== kind) { out.push(`</${list}>`); list = null; }
|
|
2809
|
+
if (kind) { if (!list) { out.push(`<${kind}>`); list = kind; } out.push(`<li>${(bullet || num)[1]}</li>`); continue; }
|
|
2810
|
+
if (/^\s*([-*_])\1{2,}\s*$/.test(line)) out.push("<hr>");
|
|
2811
|
+
else if (/^#{1,6} /.test(line)) out.push(`<p class="ai-h">${line.replace(/^#+ /, "")}</p>`);
|
|
2812
|
+
else if (line.trim()) out.push(`<p>${line}</p>`);
|
|
2813
|
+
}
|
|
2814
|
+
if (list) out.push(`</${list}>`);
|
|
2815
|
+
return out.join("").replace(/\u0000(\d+)\u0000/g, (m, i) => `<pre><code>${blocks[i]}</code></pre>`);
|
|
2816
|
+
}
|
|
2817
|
+
// -- AI page: several saved chats (this browser only), search, suggestions, pictures, daily usage --
|
|
2818
|
+
const AI_CHATS_KEY = "rug-ai-chats", AI_USAGE_KEY = "rug-ai-usage", AI_DAILY = 100;
|
|
2819
|
+
const AI_SUGGESTIONS = [
|
|
2820
|
+
["🍝", "What should I make for dinner?"], ["😂", "Tell me a joke"],
|
|
2821
|
+
["🎬", "Recommend a movie to watch"], ["💡", "Give me a fun fact"],
|
|
2822
|
+
];
|
|
2823
|
+
function aiLoadChats() {
|
|
2824
|
+
const old = store.get(AI_KEY, null); // the first version kept one chat; bring it over
|
|
2825
|
+
let chats = store.get(AI_CHATS_KEY, []);
|
|
2826
|
+
if (Array.isArray(old) && old.length && !chats.length) chats = [{ id: Date.now().toString(36), title: aiTitle(old[0].text), ts: Date.now(), messages: old }];
|
|
2827
|
+
store.set(AI_KEY, null);
|
|
2828
|
+
return Array.isArray(chats) ? chats : [];
|
|
2829
|
+
}
|
|
2830
|
+
function aiTitle(text) { const t = String(text || "").replace(/\s+/g, " ").trim(); return t.length > 40 ? t.slice(0, 40) + "…" : t || "New chat"; }
|
|
2831
|
+
function aiSave() {
|
|
2832
|
+
// pictures are kept for this visit only (they'd fill the browser's storage)
|
|
2833
|
+
const slim = ai.chats.slice(0, 50).map((c) => ({ ...c, messages: c.messages.slice(-60).map(({ img, ...m }) => (img ? { ...m, hadImg: true } : m)) }));
|
|
2834
|
+
store.set(AI_CHATS_KEY, slim);
|
|
2835
|
+
}
|
|
2836
|
+
const aiCurrent = () => ai.chats.find((c) => c.id === ai.currentId) || null;
|
|
2837
|
+
// Usage: AI_DAILY messages a day on this device, starting fresh at midnight
|
|
2838
|
+
function aiUsage() {
|
|
2839
|
+
const today = new Date().toDateString(), u = store.get(AI_USAGE_KEY, {});
|
|
2840
|
+
return u.day === today ? u : { day: today, used: 0 };
|
|
2841
|
+
}
|
|
2842
|
+
function renderAiUsage() {
|
|
2843
|
+
const u = aiUsage(), left = Math.max(0, AI_DAILY - u.used);
|
|
2844
|
+
$("ai-usage-used").textContent = `${u.used}/${AI_DAILY}`;
|
|
2845
|
+
$("ai-usage-left").textContent = `${left} left`;
|
|
2846
|
+
$("ai-usage-fill").style.width = `${Math.min(100, (u.used / AI_DAILY) * 100)}%`;
|
|
2847
|
+
$("ai-foot").textContent = `${u.used}/${AI_DAILY} today · ${left} remaining · resets at midnight`;
|
|
2848
|
+
}
|
|
2849
|
+
function aiGroup(ts) {
|
|
2850
|
+
const d = new Date(ts), now = new Date(), day = 86400000;
|
|
2851
|
+
const start = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();
|
|
2852
|
+
return ts >= start ? "Today" : ts >= start - day ? "Yesterday" : ts >= start - 7 * day ? "Last 7 days" : "Older";
|
|
2853
|
+
}
|
|
2854
|
+
function renderAiChats() {
|
|
2855
|
+
const q = $("ai-search").value.trim().toLowerCase();
|
|
2856
|
+
const list = ai.chats.filter((c) => !q || c.title.toLowerCase().includes(q) || c.messages.some((m) => m.text.toLowerCase().includes(q)));
|
|
2857
|
+
let html = "", last = "";
|
|
2858
|
+
for (const c of list) {
|
|
2859
|
+
const g = aiGroup(c.ts);
|
|
2860
|
+
if (g !== last) { html += `<p class="ai-group">${g}</p>`; last = g; }
|
|
2861
|
+
html += `<button class="ai-chat-item${c.id === ai.currentId ? " on" : ""}" type="button" data-chat="${escapeHtml(c.id)}">💬 <span>${escapeHtml(c.title)}</span></button>`;
|
|
2862
|
+
}
|
|
2863
|
+
$("ai-chats").innerHTML = html || `<p class="ai-group">${q ? "No chats match." : "No chats yet."}</p>`;
|
|
2864
|
+
}
|
|
2865
|
+
function renderAi() {
|
|
2866
|
+
const ready = aiReady(), c = aiCurrent(), msgs = c?.messages || [];
|
|
2867
|
+
$("ai-off").hidden = ready;
|
|
2868
|
+
$("ai-form").hidden = !ready;
|
|
2869
|
+
$("ai-title").textContent = c ? c.title : "New chat";
|
|
2870
|
+
$("ai-delete").hidden = !c;
|
|
2871
|
+
const log = $("ai-log");
|
|
2872
|
+
if (!msgs.length) {
|
|
2873
|
+
log.innerHTML = ready ? `<div class="ai-welcome"><h2>What can I help you with today?</h2><div class="ai-suggest">` +
|
|
2874
|
+
AI_SUGGESTIONS.map(([icon, text]) => `<button type="button" data-suggest="${escapeHtml(text)}"><span aria-hidden="true">${icon}</span>${escapeHtml(text)}</button>`).join("") + `</div></div>` : "";
|
|
2875
|
+
} else {
|
|
2876
|
+
log.innerHTML = msgs.map((m) => m.role === "assistant"
|
|
2877
|
+
? `<div class="ai-msg assistant">${aiFormat(m.text)}${m.by ? `<span class="ai-by">${escapeHtml(m.by)}</span>` : ""}</div>`
|
|
2878
|
+
: `<div class="ai-msg user">${m.img ? `<img class="ai-msg-img" src="${m.img}" alt="Picture you sent">` : m.hadImg ? `<p class="ai-img-note">📷 picture</p>` : ""}<p>${escapeHtml(m.text)}</p></div>`).join("");
|
|
2879
|
+
if (ai.busy) log.insertAdjacentHTML("beforeend", `<div class="ai-msg assistant thinking"><span></span><span></span><span></span></div>`);
|
|
2880
|
+
}
|
|
2881
|
+
log.scrollTop = log.scrollHeight;
|
|
2882
|
+
renderAiChats();
|
|
2883
|
+
renderAiUsage();
|
|
2884
|
+
}
|
|
2885
|
+
async function sendAi(e, preset) {
|
|
2886
|
+
e?.preventDefault();
|
|
2887
|
+
const box = $("ai-input"), text = (preset ?? box.value).trim();
|
|
2888
|
+
if ((!text && !ai.pendingImg) || ai.busy) return;
|
|
2889
|
+
const u = aiUsage();
|
|
2890
|
+
if (u.used >= AI_DAILY) { toast(`You've used all ${AI_DAILY} AI messages today. They reset at midnight.`); return; }
|
|
2891
|
+
let c = aiCurrent();
|
|
2892
|
+
if (!c) { c = { id: Date.now().toString(36), title: aiTitle(text || "Picture"), ts: Date.now(), messages: [] }; ai.chats.unshift(c); ai.currentId = c.id; }
|
|
2893
|
+
c.messages.push({ role: "user", text: text.slice(0, 4000) || "What's in this picture?", ...(ai.pendingImg ? { img: ai.pendingImg } : {}) });
|
|
2894
|
+
c.ts = Date.now();
|
|
2895
|
+
ai.chats = [c, ...ai.chats.filter((x) => x !== c)]; // most recent chat on top
|
|
2896
|
+
box.value = "";
|
|
2897
|
+
clearAiPicture();
|
|
2898
|
+
store.set(AI_USAGE_KEY, { day: u.day, used: u.used + 1 });
|
|
2899
|
+
ai.busy = true;
|
|
2900
|
+
renderAi();
|
|
2901
|
+
try {
|
|
2902
|
+
const reply = await askAi(c.messages.slice(-16)); // the last few turns, so it remembers the conversation
|
|
2903
|
+
c.messages.push({ role: "assistant", text: reply.text, by: reply.by });
|
|
2062
2904
|
} catch {
|
|
2063
|
-
|
|
2905
|
+
c.messages.push({ role: "assistant", text: "The AI is busy right now (the free limits ran out). Try again in a bit." });
|
|
2064
2906
|
}
|
|
2907
|
+
ai.busy = false;
|
|
2908
|
+
aiSave();
|
|
2909
|
+
renderAi();
|
|
2910
|
+
box.focus();
|
|
2065
2911
|
}
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
if (
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
$("
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
$("
|
|
2912
|
+
async function pickAiPicture(file) {
|
|
2913
|
+
if (!file || !/^image\//.test(file.type)) return;
|
|
2914
|
+
try {
|
|
2915
|
+
ai.pendingImg = await shrinkPhoto(await createImageBitmap(file));
|
|
2916
|
+
$("ai-attach-img").src = ai.pendingImg;
|
|
2917
|
+
$("ai-attach").hidden = false;
|
|
2918
|
+
$("ai-input").focus();
|
|
2919
|
+
} catch { toast("Couldn't read that picture."); }
|
|
2920
|
+
}
|
|
2921
|
+
function clearAiPicture() { ai.pendingImg = null; $("ai-attach").hidden = true; $("ai-attach-img").removeAttribute("src"); $("ai-pic-input").value = ""; }
|
|
2922
|
+
function bindAi() {
|
|
2923
|
+
ai.chats = aiLoadChats();
|
|
2924
|
+
ai.currentId = null;
|
|
2925
|
+
$("ai-form").addEventListener("submit", (e) => sendAi(e));
|
|
2926
|
+
$("ai-input").addEventListener("keydown", (e) => { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); $("ai-form").requestSubmit(); } });
|
|
2927
|
+
$("ai-input").addEventListener("input", () => { const t = $("ai-input"); t.style.height = "auto"; t.style.height = Math.min(t.scrollHeight, 180) + "px"; });
|
|
2928
|
+
$("ai-input").addEventListener("paste", (e) => { const f = [...(e.clipboardData?.files || [])].find((x) => x.type.startsWith("image/")); if (f) { e.preventDefault(); pickAiPicture(f); } });
|
|
2929
|
+
$("ai-new").addEventListener("click", () => { ai.currentId = null; renderAi(); $("ai-input").focus(); });
|
|
2930
|
+
$("ai-chats").addEventListener("click", (e) => { const b = e.target.closest("[data-chat]"); if (b) { ai.currentId = b.dataset.chat; renderAi(); } });
|
|
2931
|
+
$("ai-search").addEventListener("input", renderAiChats);
|
|
2932
|
+
$("ai-delete").addEventListener("click", () => {
|
|
2933
|
+
const c = aiCurrent();
|
|
2934
|
+
if (!c || !confirm(`Delete “${c.title}”?`)) return;
|
|
2935
|
+
ai.chats = ai.chats.filter((x) => x !== c); ai.currentId = null; aiSave(); renderAi();
|
|
2936
|
+
});
|
|
2937
|
+
$("ai-log").addEventListener("click", (e) => { const b = e.target.closest("[data-suggest]"); if (b) sendAi(null, b.dataset.suggest); });
|
|
2938
|
+
$("ai-pic").addEventListener("click", () => $("ai-pic-input").click());
|
|
2939
|
+
$("ai-pic-input").addEventListener("change", () => pickAiPicture($("ai-pic-input").files[0]));
|
|
2940
|
+
$("ai-attach-x").addEventListener("click", clearAiPicture);
|
|
2941
|
+
const phone = () => innerWidth <= 800; // on phones the list slides over the chat, so it starts closed
|
|
2942
|
+
const side = (open) => { $("ai-app").classList.toggle("side-closed", !open); if (!phone()) store.set("rug-ai-side", open); };
|
|
2943
|
+
$("ai-collapse").addEventListener("click", () => side(false));
|
|
2944
|
+
$("ai-expand").addEventListener("click", () => side(true));
|
|
2945
|
+
for (const id of ["ai-new", "ai-chats"]) $(id).addEventListener("click", (e) => { if (phone() && e.target.closest("button")) side(false); });
|
|
2946
|
+
side(!phone() && store.get("rug-ai-side", true));
|
|
2099
2947
|
}
|
|
2100
2948
|
|
|
2101
2949
|
// ---------- Emoji picker and stickers ----------
|
|
@@ -2287,15 +3135,13 @@
|
|
|
2287
3135
|
// There's one chat box: it sits on the Chat page, or in the player's side dock while that's open.
|
|
2288
3136
|
const CHAT_SEEN_KEY = "rug-chat-seen", CHAT_DOCK_KEY = "rug-chat-dock";
|
|
2289
3137
|
function dockOpen() { return !els.player.hidden && store.get(CHAT_DOCK_KEY, false); }
|
|
2290
|
-
function
|
|
2291
|
-
function chatShowing() { return dockOpen() || (els.player.hidden && !$("view-chat").hidden) || liveShowing(); }
|
|
3138
|
+
function chatShowing() { return dockOpen() || (els.player.hidden && !$("view-chat").hidden); }
|
|
2292
3139
|
function placeChatBox() {
|
|
2293
3140
|
const docked = dockOpen();
|
|
2294
3141
|
$("chat-dock").hidden = !docked;
|
|
2295
3142
|
$("dock-btn").setAttribute("aria-pressed", docked);
|
|
2296
|
-
// the one chat box sits beside a game
|
|
2297
|
-
const home = docked ? $("chat-dock") :
|
|
2298
|
-
switchRoom(liveShowing() && !docked ? "live" : "main");
|
|
3143
|
+
// the one chat box sits beside a game or on the Chat page
|
|
3144
|
+
const home = docked ? $("chat-dock") : $("view-chat");
|
|
2299
3145
|
if ($("chat-box").parentNode !== home) home.appendChild($("chat-box"));
|
|
2300
3146
|
if (!chatShowing() && $("chat-box").classList.contains("full")) setChatFull(false);
|
|
2301
3147
|
if (chatShowing()) markChatSeen();
|
|
@@ -2539,8 +3385,8 @@
|
|
|
2539
3385
|
if (!deleting) {
|
|
2540
3386
|
shown++;
|
|
2541
3387
|
input.placeholder = text.slice(0, shown) + "▍";
|
|
2542
|
-
if (shown >= text.length) { deleting = true; input.placeholder = text; timer = setTimeout(tick,
|
|
2543
|
-
timer = setTimeout(tick,
|
|
3388
|
+
if (shown >= text.length) { deleting = true; input.placeholder = text; timer = setTimeout(tick, 4000); return; }
|
|
3389
|
+
timer = setTimeout(tick, 90 + Math.random() * 90); // uneven, like a real person typing
|
|
2544
3390
|
} else {
|
|
2545
3391
|
shown--;
|
|
2546
3392
|
input.placeholder = text.slice(0, shown) + "▍";
|
|
@@ -2548,59 +3394,29 @@
|
|
|
2548
3394
|
deleting = false;
|
|
2549
3395
|
line = (line + 1) % fixed.length;
|
|
2550
3396
|
text = fixed[line]();
|
|
2551
|
-
timer = setTimeout(tick,
|
|
3397
|
+
timer = setTimeout(tick, 900);
|
|
2552
3398
|
return;
|
|
2553
3399
|
}
|
|
2554
|
-
timer = setTimeout(tick,
|
|
3400
|
+
timer = setTimeout(tick, 40);
|
|
2555
3401
|
}
|
|
2556
3402
|
}
|
|
2557
3403
|
tick();
|
|
2558
3404
|
}
|
|
2559
3405
|
|
|
2560
3406
|
// ---------- Boot screen + auto-update ----------
|
|
2561
|
-
const BOOT_LINES = [
|
|
2562
|
-
"Loading… about 3 hours left", "Downloading more RAM…", "Calculating time left: 7 years…",
|
|
2563
|
-
"Loading 99%… still 99%…", "Estimated time: yes", "Skill issue detected, loading anyway…",
|
|
2564
|
-
"Installing 47 browser toolbars…", "Running on 3 megabytes and a dream…", "Buffering… (it's not the wifi, it's you)",
|
|
2565
|
-
"Spawning in…", "Respawning in 3… 2… 9…", "Rendering grass you'll never touch…",
|
|
2566
|
-
"Loading the loading screen…", "Downloading lag…", "Speedrunning the loading bar…",
|
|
2567
|
-
"Turning it off and on again…", "Searching for the any key…", "Patching bugs, adding new ones…",
|
|
2568
|
-
];
|
|
2569
|
-
// Football jokes are mixed in, but never two in a row
|
|
2570
|
-
const TEAM_LINES = [
|
|
2571
|
-
"The Cowboys suck. Loading anyway…", "Loading… unlike the Cowboys in January",
|
|
2572
|
-
"This bar has more wins than the Cowboys…", "Giants are good. Loading respectfully…",
|
|
2573
|
-
"Loading at Giants speed (fast, obviously)…", "Buffering like a Browns offense…",
|
|
2574
|
-
"Searching for a Browns quarterback… still searching…", "Eagles fans booing the loading bar…",
|
|
2575
|
-
"Loading… quieter than Philly after a loss", "Steelers: 8-9 and somehow still loading…",
|
|
2576
|
-
"Loading with a Steelers-level 'we'll get 'em next year'…", "Ravens up big… loading the 4th-quarter collapse…",
|
|
2577
|
-
"Loading faster than a Ravens playoff exit…",
|
|
2578
|
-
];
|
|
2579
3407
|
const boot = { el: $("boot"), fill: $("boot-fill"), msg: $("boot-msg"), ver: $("boot-ver"), timer: 0, pct: 0 };
|
|
2580
3408
|
function startBoot() {
|
|
2581
|
-
|
|
2582
|
-
let lastWasTeam = false;
|
|
2583
|
-
const next = () => {
|
|
2584
|
-
// ~1 in 3 lines is a team joke, but never right after another one
|
|
2585
|
-
const team = !lastWasTeam && Math.random() < 0.35;
|
|
2586
|
-
const pool = (team ? TEAM_LINES : BOOT_LINES).filter((l) => !used.has(l));
|
|
2587
|
-
const line = pool[Math.floor(Math.random() * pool.length)] || BOOT_LINES[0];
|
|
2588
|
-
used.add(line);
|
|
2589
|
-
lastWasTeam = team;
|
|
2590
|
-
return line;
|
|
2591
|
-
};
|
|
2592
|
-
boot.msg.textContent = next();
|
|
3409
|
+
boot.msg.textContent = "Loading…";
|
|
2593
3410
|
boot.timer = setInterval(() => {
|
|
2594
|
-
boot.msg.textContent = next();
|
|
2595
3411
|
boot.pct = Math.min(90, boot.pct + 8 + Math.random() * 14); // creeps up, saves the last bit for "done"
|
|
2596
3412
|
boot.fill.style.width = `${boot.pct}%`;
|
|
2597
|
-
},
|
|
3413
|
+
}, 120);
|
|
2598
3414
|
}
|
|
2599
3415
|
function finishBoot(text) {
|
|
2600
3416
|
clearInterval(boot.timer);
|
|
2601
3417
|
boot.fill.style.width = "100%";
|
|
2602
3418
|
if (text) boot.msg.textContent = text;
|
|
2603
|
-
setTimeout(() => boot.el.classList.add("done"),
|
|
3419
|
+
setTimeout(() => boot.el.classList.add("done"), 120);
|
|
2604
3420
|
}
|
|
2605
3421
|
|
|
2606
3422
|
// When opened from a versioned unpkg link (e.g. an old bookmark), jump to the newest version.
|
|
@@ -2626,9 +3442,19 @@
|
|
|
2626
3442
|
|
|
2627
3443
|
async function init() {
|
|
2628
3444
|
loadSettings();
|
|
2629
|
-
|
|
2630
|
-
else boot.el.classList.add("done"); // loading screen turned off in Settings
|
|
3445
|
+
startBoot();
|
|
2631
3446
|
initTheme();
|
|
3447
|
+
// the side bar can be tucked away (remembered); a small tab on the left edge brings it back
|
|
3448
|
+
const railHidden = (h) => { document.documentElement.classList.toggle("rail-hidden", h); store.set("rug-rail-hidden", h); };
|
|
3449
|
+
document.documentElement.classList.toggle("rail-hidden", store.get("rug-rail-hidden", false));
|
|
3450
|
+
const peek = (on) => document.documentElement.classList.toggle("rail-peek", on);
|
|
3451
|
+
$("rail-hide").addEventListener("click", () => { peek(false); railHidden(true); });
|
|
3452
|
+
$("rail-show").addEventListener("click", () => { peek(false); railHidden(false); });
|
|
3453
|
+
// While hidden, pointing at the left edge slides it back out over the page; moving away tucks it in again
|
|
3454
|
+
$("rail-zone").addEventListener("mouseenter", () => peek(true));
|
|
3455
|
+
document.querySelector(".rail").addEventListener("mouseleave", () => peek(false));
|
|
3456
|
+
$("soundboard-btn").addEventListener("click", () => play("gn-179")); // the soundboard: in the side bar, not the game list
|
|
3457
|
+
for (const id of ["home-apps", "gotd"]) $(id).addEventListener("click", (e) => { const b = e.target.closest("[data-id]"); if (b) play(b.dataset.id); });
|
|
2632
3458
|
startClock();
|
|
2633
3459
|
startGamepad();
|
|
2634
3460
|
setPerRow(store.get(PER_ROW_KEY, 6));
|
|
@@ -2644,24 +3470,26 @@
|
|
|
2644
3470
|
bindAdmin();
|
|
2645
3471
|
bindChatTools();
|
|
2646
3472
|
bindChatExtras();
|
|
3473
|
+
bindPolls();
|
|
2647
3474
|
bindQuotes();
|
|
2648
|
-
|
|
2649
|
-
|
|
3475
|
+
bindAi();
|
|
3476
|
+
bindTrivia();
|
|
2650
3477
|
bindReports();
|
|
2651
3478
|
startAnalytics();
|
|
2652
3479
|
startPresence();
|
|
2653
3480
|
// Listen to chat from the start so the chat buttons can show a dot for new messages.
|
|
2654
3481
|
// First visit: only messages from now on count as new.
|
|
2655
3482
|
if (store.get(CHAT_SEEN_KEY, null) === null) store.set(CHAT_SEEN_KEY, Date.now());
|
|
2656
|
-
if (CFG.firebase) { openChat(); startQuotes();
|
|
2657
|
-
// long enough
|
|
2658
|
-
const minShow = new Promise((r) => setTimeout(r,
|
|
3483
|
+
if (CFG.firebase) { openChat(); startQuotes(); }
|
|
3484
|
+
// just long enough that the loading screen doesn't flash
|
|
3485
|
+
const minShow = new Promise((r) => setTimeout(r, 300));
|
|
2659
3486
|
const update = newerVersionUrl(2500);
|
|
2660
3487
|
try {
|
|
2661
3488
|
const res = await fetch("games.json", { cache: "no-cache" });
|
|
2662
3489
|
const data = await res.json();
|
|
2663
|
-
|
|
2664
|
-
|
|
3490
|
+
// "hidden" entries (the soundboard) can be opened by id but aren't listed with the games
|
|
3491
|
+
games = data.games.filter((g) => !g.hidden).sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true }));
|
|
3492
|
+
byId = new Map(data.games.map((g) => [g.id, g]));
|
|
2665
3493
|
cdnPins = data.cdnPins || {};
|
|
2666
3494
|
} catch (err) {
|
|
2667
3495
|
console.error(err);
|
|
@@ -2680,11 +3508,13 @@
|
|
|
2680
3508
|
await minShow;
|
|
2681
3509
|
startTypingPlaceholder();
|
|
2682
3510
|
els.homeSub.innerHTML = `${games.length} games · press <kbd>/</kbd> to search`;
|
|
2683
|
-
els.footerCount.textContent = `${games.length} games`;
|
|
2684
3511
|
renderChips();
|
|
2685
3512
|
renderRecent();
|
|
2686
3513
|
renderGrid();
|
|
2687
3514
|
startMarquee();
|
|
3515
|
+
renderHomeApps();
|
|
3516
|
+
renderGameOfDay();
|
|
3517
|
+
startCommunity();
|
|
2688
3518
|
route();
|
|
2689
3519
|
finishBoot("Done");
|
|
2690
3520
|
}
|