Either I'm working on new features or the server decided it wanted a nap.
24 |
25 |
26 |
27 |
Connection Error
28 |
This isn't supposed to happen.
29 |
30 |
31 |
32 |
33 |
What would you like to do?
34 |
35 |
36 |
39 |
40 |
41 |
42 |
Create Room
43 |
What would you like to call yourself?
44 |
45 |
What packs would you like to play with?
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
Add Your Own Cards
55 |
56 |
57 |
Questions:
58 |
Click "Add Question" to add your own questions to the deck. Underscores will automatically replaced by blanks.
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
Answers:
71 |
Click "Add Answer" to add your own answers to the deck.
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
Lobby
88 |
Your room's code is . The people here besides you are:
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
Join Room
99 |
What is the code of the room you are trying to join (six digits)?
100 |
101 |
What would you like to call yourself?
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
Lobby
111 |
You've joined a lobby with:
112 |
113 |
The room creator will start the game soon.
114 |
115 |
116 |
117 |
The Room Creator Left
118 |
119 |
120 |
121 |
122 |
Preparing Game...
123 |
Hang tight
124 |
125 |
126 |
127 |
The judge for this round is .
128 |
Question:
129 |
130 |
131 |
132 |
Answers:
133 |
134 |
135 |
136 |
137 |
Waiting for everyone else to submit...
138 |
Your selection was:
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
You're the Judge: Pick the best answer to this question:
147 |
148 |
149 |
150 |
... From these answers:
151 |
152 |
153 |
154 |
155 |
Your Judge, , is deliberating...
156 |
Question:
157 |
158 |
159 |
160 |
Answers submitted:
161 |
162 |
163 |
164 |
165 |
The judge has decided!
166 |
won this round with:
167 |
168 |
169 |
170 |
171 |
Next round coming in 5 seconds...
172 |
173 |
174 |
175 |
You are the judge this round.
176 |
Waiting for your friends to submit their answers...
177 |
Question:
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 | Chat
186 |
187 |
188 |
189 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
--------------------------------------------------------------------------------
/iic_cards.json:
--------------------------------------------------------------------------------
1 | {"PG-13": {"answers": ["My crippling loneliness ", "The auto-immune deficiency syndrome", "A pubic hair", "My hairy palms", "Ticks all over your body", "A paper cut on the tip of my penis", "Stepping in a dog turd", "Pierced nipples", "Urine", "Having my blood harvested by our mosquito overlords", "Turd graffiti", "An inopportune sharting", "The purge", "Pooping on the streets", "Virginity", "Penis enlargement pills", "Making my anus bleed", "Kidney stones", "Taking off my pants in a shopping mall", "Yellow stained underwear ", "My scrotum sticking to the inside of my leg", "Biggus Dickus", "Semen", "Urinating all over my house", "Shaving my grandma\u2019s legs", "A poodle eating my insides", "Opioids ", "Killing someone with a spoon", "Eclairs filled with diarrhea instead of chocolate", "Stabbing myself with a butter knife ", "Depression ", "A jockstrap with bells on it", "Nonstop diarrhea ", "Making a dog eat dark chocolate", "Drinking toilet water", "An ova", "Sprite Cranberry", "Meat shafts", "Picking boogers and licking them", "Lice in my pubic hair", "Projectile diarrhea", "Staring at the sun until my eyes melt", "Sperm", "Colonoscopies", "Xi Jinping's left testicle", "Zoom dating", "My questionable sexuality", "Hitler\u2019s missing ball", "Killing EVERYONE!!!", "Man spreading", "18 naked cowboys in the showers", "The hostages", "N95 masks laced with chloroform", "High resolution 3D scans of people's feet", "Extra Chromosomes", "My Gandalf the Grey body pillow", "Lack of rights ", "The hole that I somehow burned in crotch of my pants that I wear to Boy Scout meetings", "Unfortunately, Zeus was horny", "My \"Fun Sized\" Penis.", "The STDs that I gave to your mom", "The penis veins on Snickers bars.", "Giving guns human rights", "Airborne AIDS", "Pepperoni nips", "Illumination Studio's worst movie \"HOP\"", "Robert E Lee", "Communism done right", "There is no meme. Uhh. Take off your clothes.", "3 gallons of milk, 2 gallons of gasoline, and above the legal limit of alcohol", "September 11th, 2001", "Inbreeding", "Unjust suffering", "Glands", "Abortion", "My body, my choice", "Sempai", "Survivor's guilt", "Florida man", "Viscous fluid"], "questions": ["This quarantine really got me horny for [[BLANK]].", "Most people use their pantry to store food, I use mine to store [[BLANK]].", "Ew, I just stepped in [[BLANK]].", "While I was in the bathroom I saw [[BLANK]].", "When living with [[BLANK]] i want to die.", "I found the Hulk doing terrible things to [[BLANK]].", "If I had to get an STD I would like it to be [[BLANK]].", "Before I die I want to see [[BLANK]].", "A RPG loaded with [[BLANK]].", "The house next door to me was sold to [[BLANK]].", "If I could I would kill my [[BLANK]].", "Like shooting [[BLANK]] in a barrel.", "Doctor! Come quick, it's my [[BLANK]].", "Oh my god, that [[BLANK]] is so big!", "The 10th circle of Hell contains [[BLANK]].", "Damnit, the internet went out! What am I supposed to do without [[BLANK]]?", "Mom says it's my turn on the [[BLANK]].", "If you were any more inbred you'd be [[BLANK]].", "Does the name [[BLANK]] mean anything to you?", "Mom, Dad, there's something I need to tell you: I'm [[BLANK]].", "We will build a great, great, [[BLANK]].", "Lets get ready for [[BLANK]].", "The only thing better then the third reich would be [[BLANK]].", "I did not have sexual relations with [[BLANK]]", "I drink to forget [[BLANK]]", "Go commit [[BLANK]].", "Do you like the [[BLANK]] fanfic I just made?"]}, "PG": {"answers": ["Copious amounts of milk", "Shrek 2", "Coronacation ", "A dead meme", "A stockpile of N95 masks", "Baking cookies in calculus", "A sentient pineapple", "University of Maryland \u2014 College Park", "The plague", "One million ants", "A smelly fart", "Grandma", "Girl Scout cookies", "Listerine and 7 tongue depressors ", "Autocorrect", "A pillow fight", "237 Cats", "Extreme nose hair", "Boogers smeared under the desk", "Public defecation", "Being covered in dirty underpants", "A pervert looking at you", "Eggs", "A terrorist", "Fruit Loops", "Stuttering", "Elephant toothpaste ", "A trash panda", "Jelly filled doughnut", "My personal Thanos glove", "Toenail fungus", "Bavarian cream", "Fuzzy bunny slippers", "My LEGO collection ", "Having knives for hands", "The sharpest tool in the shed", "A stack of 23 deflated bouncy houses", "Raging", "Double dipping", "Literally giving someone a hand", "The 95 theses", "Bacon", "Trees", "Planet", "Throwing yourself into a fireplace", "The Harlem Renaissance ", "WAFFLES!", "Thinking you are a salad so you pour dressing and lettuce on yourself ", "Breaking eggs all over yourself and saying,\u201dI am eggcellent!\u201d", "Pure nothingness", "Pollution", "Dancing zombies ", "Plastic water bottles", "Disappointing cinnamon rolls", "The Fire Nation", "Online school...", "50 kilograms of kinetic sand", "The attack", "Play Doh, lots of Play Doh", "87 cubic meters of chopped almonds", "Gangster Spongebob shirts from the early 2000's", "My therapist", "Projectile Vomit", "A poor Nigerian prince waiting for an email reply", "The Pentagon", "The 2 x 4's that I got at Home Depot", "A Barbershop Quartet", "Michael Jordan", "Breakfast cereals", "Danny DeVito", "Bubble Guppies", "_____, that was a mistake.", "Being wanted in every state but North Dakota, Idaho, and Illinois.", "The fourth reich", "Zits... EVERYWHERE!", "Your Mom", "Walking like an Egyptian", "Kool-Aid", "Ben Shapiro", "Diary of a Wimpy Kid", "I am a farmer", "Fart", "Barry Benson", "Grunting noises", "Egg Sandwich ", "The Kool-Aid Man", "Jefferson Davis", "A 3D jigsaw puzzle shaped mysteriously like a kidney ", "My dog", "My cat", "My gerbil", "My mid-life crisis"], "questions": ["I studied for 2 weeks straight for the AP [[BLANK]] exam only to get a 3. I might as well drop out.", "I can\u2019t send my son to school, he\u2019s allergic to [[BLANK]].", "My teacher promised me extra credit as long as I give him/her [[BLANK]]", "May I speak to the manager? I found [[BLANK]] in my salad.", "Don\u2019t ask me why, but I\u2019ve got [[BLANK]].", "Under the couch cushions I found [[BLANK]].", "I sprayed my cat with [[BLANK]].", "I've reached enlightenment, my secret is to [[BLANK]].", "My car crashed because of [[BLANK]].", "My water bottle is filled with [[BLANK]].", "What is this mysterious liquid?", "Imagine my surprise when [[BLANK]].", "Should I ask my parents for [[BLANK]]?", "Welcome to the new game show, \"Who wants to be a [[BLANK]]?\"", "Why I hate the school bathroom.", "Wearing shorts in winter is like [[BLANK]].", "The box was filled with [[BLANK]].", "My mailbox was stuffed with [[BLANK]].", "When I look down I see [[BLANK]].", "TV's favorite reality show, \"Chasing [[BLANK]].\"", "I went on vacation and I saw [[BLANK]].", "I cleaned out my attic and found [[BLANK]].", "Thinking of ideas for Ian\u2019s internet cards is like [[BLANK]].", "The Earth will explode in 24 hours because of [[BLANK]].", "At last, I have found my long lost [[BLANK]].", "I was walking down the street and ran into [[BLANK]].", "For Lent, I gave up [[BLANK]].", "My birthday consisted of [[BLANK]].", "I love [[BLANK]].", "When I die, I would like to be buried with [[BLANK]].", "What makes me laugh?", "My superpower is [[BLANK]].", "When I grow up, I want to be a [[BLANK]]!", "There are too many [[BLANK]].", "This thing is too fast for [[BLANK]].", "The greatest thing in life is [[BLANK]].", "[[BLANK]] is why I\u2019m dropping out of school.", "I was arrested because of [[BLANK]]. ", "During my morning meditation, I realized it would be a great idea to [[BLANK]].", "There\u2019s nothing better than a clown car filled with [[BLANK]].", "Drop your weapon and put your [[BLANK]] up!", "Once upon a time in [[BLANK]]", "It doesn\u2019t get any better than [[BLANK]] on a cold night.", "It\u2019s as if the [[BLANK]] was sucked out of me.", "I hate [[BLANK]].", "Africa is on fire because they found [[BLANK]].", "If Coronavirus doesn't kill me, [[BLANK]] will.", "Greek mythology and [[BLANK]] are my two favorite things.", "It will be the end of the world when [[BLANK]] happens.", "Why is my favorite chair wet?", "It burns when I [[BLANK]].", "[[BLANK]] roasting on an open fire.", "www.[[BLANK]].com", "I can\u2019t hold back any longer I have to [[BLANK]].", "A magician made [[BLANK]] blank appear.", "Ted Shecker\u2019s [[BLANK]] emporium.", "It was as if the earth opened up and [[BLANK]] me.", "My sweatshirt has [[BLANK]] stains.", "I don\u2019t want to eat any more [[BLANK]].", "Thanos had the infinity gauntlet, I have the infinity [[BLANK]].", "The best part of my day is [[BLANK]].", "They won\u2019t take me, I have [[BLANK]].", "When my toilet paper runs out I use [[BLANK]].", "What is that weird sound?", "A text book case of [[BLANK]].", "Super Mario's newest enemy, [[BLANK]].", "It's the newest Mario Kart item, [[BLANK]].", "What is that horrid smell?", "As supreme leader of Earth, my first order of business is to outlaw [[BLANK]].", "With my new time machine, I shall bring [[BLANK]] back from the past.", "My new invention creates [[BLANK]].", "The orcs are invading, launch the [[BLANK]]!", "Breaking news: historians have discovered that [[BLANK]] was the true cause of the Dark Ages.", "When I looked out the window I saw [[BLANK]].", "I [[BLANK]] to school every day.", "I use my phone for [[BLANK]].", "When I grow up I want to be [[BLANK]]!", "While sitting on the toilet I like to think about [[BLANK]].", "I opened my present but instead of something nice I got [[BLANK]].", "[[BLANK]] really rocks.", "Off in the distance, you can see a wild [[BLANK]] in its natural habitat.", "BREAKING NEWS: US Government announces that [[BLANK]] is now illegal nation-wide!", "And the last thing I said to her was: \u201cIt\u2019s either me or [[BLANK]].\u201d Now I\u2019m single.", "[[BLANK]] are like onions. They have layers.", "I\u2019m certain the reason I got into Harvard on a full ride was due to my essay about [[BLANK]]. ", "But everything changed when [[BLANK]] attacked.", "The United States is no more. What happened?", "What did the boomers leave us?", "I cannot stand [[BLANK]].", "The thing I fear most has to be [[BLANK]].", "Rome wasn't built in a day, but [[BLANK]] sure was.", "I, [[BLANK]], have a dream.", "If I was in Avatar, I would be a [[BLANK]] bender.", "To keep my mind sharp in social isolation, I have been [[BLANK]]."]}, "R": {"answers": ["The purple crayon I used as a dildo when I was homeless ", "Nut sock", "Your brother\u2019s homemade fleshlight ", "Party balloons and ribbed condoms", "Anime tities", "Self-mutalation", "My prolapsed anus", "Smegma", "Ice Age Baby", "The passion of Christ", "Cowboys getting fucked in their sleep", "Taking 31 Tylenol to numb the pain", "A nut that travels at the speed of sound", "Accidental circumcision", "A condom, a Wii remote, and a lot of lube", "One little, two little, three little penises, Four little, five little, six little penises, Seven little, eight little, nine little penises, Ten little penises", "The day that Pornhub Premium was free for everyone", "My 20 Terabyte homework folder", "Jared from Subway", "Wearing your boyfriends circumcised foreskin as a promise ring", "The fact that I know that it is not a beach, but it is a bathtub", "The fact that gen Z will be known as the generation that wanted to die mutually ", "Those 'play this and you will cum in 5 seconds' ads ", "Hentai", "1 man, 1 jar", "\"Fingerpainting\"", "2 girls, 1 cup", "A homemade fleshlight with two sponges and a rubber glove", "If you like PornHub Premium than you'll love _______.", "A pair of Switch joycons attached to my chode", "Sideboob", "Boob sweat", "Beastiality", "Shoving the skinny end of a screwdriver up my urethra", "Inflation, not the economic principle, but the fetish", "Ludwig van Beethoven's fucked up eardrums ", "The Buzz Lightyear x Jessie fanfic I made", "Sex Addiction ", "Unbirth", "The Velcro strap-on my girlfriend pegs me with ", "Vaginal Worms", "Dat Ass", "Rule 34", "Fucking poopy head"], "questions": ["Breaking news: A sex tape has surfaced where President Obama is seen having sex with [[BLANK]].", "What made my cousin horny?", "So I was sitting there, [[BLANK]] on my titties.", "Oh god, I think I have a [[BLANK]] fetish.", "My crew is big and it keeps getting bigger. That's cuz Jesus Christ is my [[BLANK]].", "Stepbro, stop [[BLANK]].", "Last night I got [[BLANK]] stuck in my rectum ", "[[BLANK]] really turns me on."]}}
--------------------------------------------------------------------------------
/script.js:
--------------------------------------------------------------------------------
1 | const isProduction = location.origin === "https://internetcards.ianmorrill.com"
2 |
3 | const $ = q => document.querySelector(q)
4 |
5 | let ws = new WebSocket(isProduction ? "wss://internetcards.ianmorrill.com/ws" : "ws://127.0.0.1:8765")
6 |
7 | function sendObj(obj) {
8 | ws.send(JSON.stringify(obj))
9 | }
10 |
11 | function showScene(scene) {
12 | document.querySelectorAll(".scene").forEach(el => {
13 | if (el.getAttribute("data-scene") === scene) {
14 | el.setAttribute("data-active-scene", "")
15 | }else{
16 | el.removeAttribute("data-active-scene")
17 | }
18 | })
19 | }
20 |
21 | function setNavbar(left, right) {
22 | if (left) $("#nav-left").textContent = left
23 | $("#nav-right").textContent = right
24 | }
25 |
26 | function copyText(text) {
27 | let textbox = document.createElement("input")
28 | textbox.style.position = "fixed"
29 | textbox.style.top = "0"
30 | textbox.style.left = "0"
31 | textbox.style.opacity = "0"
32 | document.body.appendChild(textbox)
33 |
34 | textbox.value = text
35 | textbox.select()
36 | document.execCommand("copy")
37 | textbox.remove()
38 | }
39 |
40 | function addChatMessage(sender, content, color) {
41 | let msg = document.createElement("div")
42 | msg.title = "Sent " + (new Date()).toLocaleString()
43 | msg.className = "message"
44 |
45 | let senderText = document.createElement("b")
46 | senderText.textContent = sender + ": "
47 | senderText.style.color = color ? color : "#000000"
48 |
49 | let contentText = document.createTextNode(content)
50 |
51 | msg.appendChild(senderText)
52 | msg.appendChild(contentText)
53 | $("#message-list").appendChild(msg)
54 |
55 | $("#message-list").scrollTop = $("#message-list").scrollHeight - $("#message-list").clientHeight
56 | }
57 |
58 | function setUpPacks(packs) {
59 | return packs.map(pack => {
60 | let packLabel = document.createElement("label")
61 | packLabel.htmlFor = "select-pack-" + pack
62 |
63 | let packLabelText = document.createTextNode(pack)
64 | packLabel.appendChild(packLabelText)
65 |
66 | let packCheckbox = document.createElement("input")
67 | packCheckbox.type = "checkbox"
68 | packCheckbox.id = "select-pack-" + pack
69 | packLabel.appendChild(packCheckbox)
70 |
71 | $("#mr-packs").appendChild(packLabel)
72 |
73 | return {name: pack, checkbox: packCheckbox}
74 | })
75 | }
76 | let packs = setUpPacks(["PG", "PG-13", "R"])
77 | let customQuestions = []
78 | let customAnswers = []
79 |
80 | function updateCustomCardsEditor() {
81 | $("#ayoc-questions").textContent = ""
82 | $("#ayoc-answers").textContent = ""
83 |
84 | customQuestions.forEach((q, i) => {
85 | const questionRow = document.createElement("tr")
86 |
87 | const questionTextContainer = document.createElement("td")
88 | const questionText = document.createElement("input")
89 | questionText.value = q
90 | questionText.addEventListener("input", e => {
91 | customQuestions[i] = questionText.value
92 | })
93 | questionTextContainer.appendChild(questionText)
94 | questionRow.appendChild(questionTextContainer)
95 |
96 | const questionRemoverContainer = document.createElement("td")
97 | const questionRemover = document.createElement("button")
98 | questionRemover.textContent = "Remove"
99 | questionRemover.className = "btn danger"
100 | questionRemover.addEventListener("click", e => {
101 | customQuestions.splice(i, 1)
102 | updateCustomCardsEditor()
103 | })
104 | questionRemoverContainer.appendChild(questionRemover)
105 | questionRow.appendChild(questionRemoverContainer)
106 |
107 | $("#ayoc-questions").appendChild(questionRow)
108 | })
109 |
110 | customAnswers.forEach((q, i) => {
111 | const answerRow = document.createElement("tr")
112 |
113 | const answerTextContainer = document.createElement("td")
114 | const answerText = document.createElement("input")
115 | answerText.value = q
116 | answerText.addEventListener("input", e => {
117 | customAnswers[i] = answerText.value
118 | })
119 | answerTextContainer.appendChild(answerText)
120 | answerRow.appendChild(answerTextContainer)
121 |
122 | const answerRemoverContainer = document.createElement("td")
123 | const answerRemover = document.createElement("button")
124 | answerRemover.textContent = "Remove"
125 | answerRemover.className = "btn danger"
126 | answerRemover.addEventListener("click", e => {
127 | customAnswers.splice(i, 1)
128 | updateCustomCardsEditor()
129 | })
130 | answerRemoverContainer.appendChild(answerRemover)
131 | answerRow.appendChild(answerRemoverContainer)
132 |
133 | $("#ayoc-answers").appendChild(answerRow)
134 | })
135 | }
136 |
137 | let addCustomCardsButton = document.createElement("button")
138 | addCustomCardsButton.className = "btn"
139 | addCustomCardsButton.addEventListener("click", e => {
140 | updateCustomCardsEditor()
141 | showScene("add-your-own-cards")
142 | })
143 | $("#mr-packs").appendChild(addCustomCardsButton)
144 |
145 | let score = 0
146 |
147 | $("#make-room").addEventListener("click", e => {
148 | customQuestions = []
149 | customAnswers = []
150 | addCustomCardsButton.textContent = "Add Your Own Cards..."
151 | showScene("make-room")
152 | })
153 |
154 | $("#ayoc-add-question").addEventListener("click", e => {
155 | customQuestions.push("")
156 | updateCustomCardsEditor()
157 | })
158 |
159 | $("#ayoc-add-answer").addEventListener("click", e => {
160 | customAnswers.push("")
161 | updateCustomCardsEditor()
162 | })
163 |
164 | $("#ayoc-back").addEventListener("click", e => {
165 | if (customAnswers.length > 0 || customQuestions.length > 0) {
166 | addCustomCardsButton.textContent = "Edit Your Cards..."
167 | }else{
168 | addCustomCardsButton.textContent = "Add Your Own Cards..."
169 | }
170 | showScene("make-room")
171 | })
172 |
173 | $("#join-room").addEventListener("click", e => {
174 | showScene("join-room")
175 | })
176 |
177 | $("#mr-back").addEventListener("click", e => {
178 | showScene("start")
179 | })
180 |
181 | $("#jr-back").addEventListener("click", e => {
182 | showScene("start")
183 | })
184 |
185 | $("#hl-back").addEventListener("click", e => {
186 | showScene("start")
187 | })
188 |
189 | $("#rcl-cancel").addEventListener("click", e => {
190 | window.location.reload()
191 | })
192 |
193 | $("#mr-submit").addEventListener("click", e => {
194 | const name = $("#mr-name").value
195 | const packsSelected = packs.map(({name, checkbox}) => {
196 | if (checkbox.checked) {
197 | return name
198 | }
199 | }).filter(pack => !!pack)
200 |
201 | if (name.trim() !== "") {
202 | sendObj({
203 | action: "makeRoom",
204 | name,
205 | packs: packsSelected,
206 | questions: customQuestions.map(q => q.replace(/_+/, "[[BLANK]]")),
207 | answers: customAnswers
208 | })
209 | }
210 | })
211 |
212 | $("#jr-submit").addEventListener("click", e => {
213 | const name = $("#jr-name").value
214 | const joinCode = $("#jr-code").value
215 |
216 | if (name.trim() !== "") {
217 | if (joinCode.length === 6 && /[0-9]+/.test(joinCode)) {
218 | sendObj({action: "joinRoom", name, joinCode})
219 | }
220 | }
221 | })
222 |
223 | $("#rcl-start-game").addEventListener("click", e => {
224 | sendObj({action: "startGame"})
225 | })
226 |
227 | $("#open-chat").addEventListener("click", e => {
228 | $(".bottom-bar").classList.add("hidden")
229 | $(".content").classList.remove("sidebar-hidden")
230 | })
231 |
232 | $("#close-chat").addEventListener("click", e => {
233 | $(".bottom-bar").classList.remove("hidden")
234 | $(".content").classList.add("sidebar-hidden")
235 | })
236 |
237 | $("#msg-form").addEventListener("submit", e => {
238 | e.preventDefault()
239 | const content = $("#msg-content").value
240 |
241 | if (content.trim() !== "") {
242 | sendObj({action: "sendChat", content})
243 | addChatMessage("You", content, "#0000ff")
244 | $("#msg-content").value = ""
245 | }
246 | })
247 |
248 | ws.addEventListener("open", () => {
249 | if (/#j\-([0-9]{6})/.test(location.hash)) {
250 | $("#jr-code").value = location.hash.match(/#j\-([0-9]{6})/)[1]
251 | location.hash = ""
252 | showScene("join-room")
253 | }else{
254 | showScene("start")
255 | }
256 | })
257 |
258 | ws.addEventListener("close", () => {
259 | showScene("closed")
260 | })
261 |
262 | ws.addEventListener("message", e => {
263 | const msgObj = JSON.parse(e.data)
264 | console.log(msgObj)
265 | if (msgObj.action === "roomMade") {
266 | score = 0
267 | setNavbar(msgObj.setName, "Room #" + msgObj.joinCode)
268 |
269 | $("#rcl-code").textContent = msgObj.joinCode
270 | $("#rcl-members").textContent = ""
271 |
272 | $("#rcl-copy-invite").addEventListener("click", () => {
273 | copyText(location.origin + location.pathname + "#j-" + msgObj.joinCode)
274 | })
275 |
276 | showScene("room-creator-lobby")
277 | }else if (msgObj.action === "roomJoined") {
278 | score = 0
279 | setNavbar(msgObj.setName, "Room #" + msgObj.joinCode)
280 |
281 | $("#rjl-members").textContent = ""
282 | msgObj.members.forEach(m => {
283 | const memberItem = document.createElement("li")
284 | memberItem.textContent = m
285 | $("#rjl-members").appendChild(memberItem)
286 | })
287 | showScene("room-joiner-lobby")
288 | }else if (msgObj.action === "memberJoined") {
289 | const rjlMemberItem = document.createElement("li")
290 | rjlMemberItem.textContent = msgObj.name
291 | $("#rjl-members").appendChild(rjlMemberItem)
292 |
293 | const rclMemberItem = document.createElement("li")
294 | rclMemberItem.textContent = msgObj.name
295 | $("#rcl-members").appendChild(rclMemberItem)
296 | }else if (msgObj.action === "memberLeft") {
297 | ["#rcl-members", "#rjl-members"].forEach(q => {
298 | $(q).childNodes[msgObj.id].remove()
299 | })
300 | }else if (msgObj.action === "gameStart") {
301 | $(".bottom-bar").classList.remove("hidden")
302 | }else if (msgObj.action === "newQuestion") {
303 | setNavbar(null, score + " Point" + (score == 1 ? "" : "s"))
304 | $("#q-question").textContent = msgObj.question
305 | $("#q-answers").textContent = ""
306 | $("#q-judge").textContent = msgObj.judge
307 | msgObj.hand.forEach(a => {
308 | const answerContent = document.createElement("div")
309 | answerContent.textContent = a
310 |
311 | const answerButton = document.createElement("button")
312 | answerButton.appendChild(answerContent)
313 | answerButton.addEventListener("click", () => {
314 | sendObj({action: "answerSubmission", answer: a})
315 | $("#wfo-question").textContent = msgObj.question
316 | $("#wfo-answer").textContent = a
317 | showScene("waiting-for-others")
318 | })
319 |
320 | $("#q-answers").appendChild(answerButton)
321 | })
322 | showScene("question")
323 | }else if (msgObj.action === "showAnswers") {
324 | $("#wfj-question").textContent = msgObj.question
325 | $("#wfj-answers").textContent = ""
326 | $("#wfj-judge").textContent = msgObj.judge
327 | msgObj.answers.forEach(a => {
328 | const answerItem = document.createElement("div")
329 |
330 | const answerCard = document.createElement("div")
331 | answerCard.classList.add("card")
332 | answerCard.classList.add("red")
333 | answerCard.textContent = a
334 |
335 | answerItem.appendChild(answerCard)
336 |
337 | $("#wfj-answers").appendChild(answerItem)
338 | })
339 | showScene("waiting-for-judge")
340 | }else if (msgObj.action === "selectAnswer") {
341 | $("#j-question").textContent = msgObj.question
342 | $("#j-answers").textContent = ""
343 | msgObj.answers.forEach(a => {
344 | const answerContent = document.createElement("div")
345 | answerContent.textContent = a
346 |
347 | const answerButton = document.createElement("button")
348 | answerButton.appendChild(answerContent)
349 | answerButton.addEventListener("click", () => {
350 | sendObj({action: "selectedAnswer", answer: a})
351 | })
352 |
353 | $("#j-answers").appendChild(answerButton)
354 | })
355 | showScene("judging")
356 | }else if (msgObj.action === "chatMessage") {
357 | addChatMessage(msgObj.from, msgObj.content, "#000000")
358 | }else if (msgObj.action === "updateScore") {
359 | score = msgObj.score
360 | setNavbar(null, score + " Point" + (score == 1 ? "" : "s"))
361 | }else if (msgObj.action === "judgeSelected") {
362 | $("#js-question").textContent = msgObj.question
363 | $("#js-answer").textContent = msgObj.answer
364 | $("#js-submitted-by").textContent = msgObj.submittedBy
365 | showScene("judge-selected")
366 | }else if (msgObj.action === "youAreTheJudge") {
367 | $("#yatj-question").textContent = msgObj.question
368 | showScene("you-are-the-judge")
369 | }else if (msgObj.action === "hostLeft") {
370 | setNavbar("Ian's Internet Cards", "")
371 | showScene("host-left")
372 | }else if (msgObj.action === "preparingGame") {
373 | showScene("preparing-game")
374 | }else if (msgObj.action === "error") {
375 | alert(msgObj.content)
376 | }
377 | })
--------------------------------------------------------------------------------