11let selectedBooth = null ;
22let selectedVibe = null ;
33
4- function setActive ( containerId , key , value ) {
4+ function setActive ( containerId , datasetKey , value ) {
55 const container = document . getElementById ( containerId ) ;
6- [ ...container . querySelectorAll ( "button" ) ] . forEach ( btn => {
7- btn . classList . toggle ( "active" , btn . dataset [ key ] === value ) ;
6+ const buttons = container . querySelectorAll ( "button" ) ;
7+ buttons . forEach ( btn => {
8+ btn . classList . toggle ( "active" , btn . dataset [ datasetKey ] === value ) ;
89 } ) ;
910}
1011
1112document . getElementById ( "booths" ) . addEventListener ( "click" , ( e ) => {
12- if ( e . target . tagName !== "BUTTON" ) return ;
13- selectedBooth = e . target . dataset . booth ;
13+ const btn = e . target . closest ( "button" ) ;
14+ if ( ! btn ) return ;
15+ selectedBooth = btn . dataset . booth ;
1416 setActive ( "booths" , "booth" , selectedBooth ) ;
1517} ) ;
1618
1719document . getElementById ( "vibes" ) . addEventListener ( "click" , ( e ) => {
18- if ( e . target . tagName !== "BUTTON" ) return ;
19- selectedVibe = e . target . dataset . vibe ;
20+ const btn = e . target . closest ( "button" ) ;
21+ if ( ! btn ) return ;
22+ selectedVibe = btn . dataset . vibe ;
2023 setActive ( "vibes" , "vibe" , selectedVibe ) ;
2124} ) ;
2225
@@ -33,15 +36,17 @@ document.getElementById("placeOrder").addEventListener("click", () => {
3336Vibe: ${ selectedVibe }
3437Detail: ${ detail } ` ;
3538
36- const ticket = document . getElementById ( "ticket" ) ;
37- ticket . textContent = ticketText ;
38-
39- const copyBtn = document . getElementById ( "copyBtn" ) ;
40- copyBtn . style . display = "inline-block" ;
39+ document . getElementById ( "ticket" ) . textContent = ticketText ;
40+ document . getElementById ( "copyBtn" ) . style . display = "inline-block" ;
41+ document . getElementById ( "status" ) . style . display = "block" ;
4142} ) ;
4243
4344document . getElementById ( "copyBtn" ) . addEventListener ( "click" , async ( ) => {
4445 const text = document . getElementById ( "ticket" ) . textContent ;
45- await navigator . clipboard . writeText ( text ) ;
46- alert ( "Ticket copied. Paste it into the Bronzed Derby chat." ) ;
46+ try {
47+ await navigator . clipboard . writeText ( text ) ;
48+ alert ( "Ticket copied. Paste it into the Bronzed Derby chat." ) ;
49+ } catch {
50+ alert ( "Couldn’t auto-copy. Manually select the ticket text and copy it." ) ;
51+ }
4752} ) ;
0 commit comments