@@ -71,6 +71,16 @@ <h1>Choose a table to join</h1>
7171 headerRow . appendChild ( th ) ;
7272 } ) ;
7373
74+ // Define status codes mapping
75+ const statusMap = {
76+ '0' : 'Empty' ,
77+ '1' : 'Full' ,
78+ '2' : 'Waiting' ,
79+ '3' : 'Playing' ,
80+ '4' : 'Round Over' ,
81+ '5' : 'Game Over'
82+ } ;
83+
7484 // Populate table rows with click functionality
7585 data . forEach ( item => {
7686 const row = document . createElement ( 'tr' ) ;
@@ -81,10 +91,10 @@ <h1>Choose a table to join</h1>
8191 updateJoinButton ( item . n ) ;
8292 } ) ;
8393
84- // Skip first value when creating cells
85- Object . values ( item ) . slice ( 1 ) . forEach ( value => {
94+ // Create cells with status conversion
95+ Object . entries ( item ) . slice ( 1 ) . forEach ( ( [ key , value ] ) => {
8696 const td = document . createElement ( 'td' ) ;
87- td . textContent = value ;
97+ td . textContent = key === 's' ? statusMap [ value ] || value : value ;
8898 row . appendChild ( td ) ;
8999 } ) ;
90100
@@ -131,9 +141,10 @@ <h1>Choose a table to join</h1>
131141 var tableId = document . getElementById ( 'tableID' ) . value ;
132142 var playerName = document . getElementById ( 'playerName' ) . value ;
133143 fetch ( 'https://fuji-llama-971660789205.asia-southeast1.run.app/join?table=' + tableId + '&player=' + playerName )
134- . then ( response => {
144+ . then ( async response => {
135145 if ( ! response . ok ) {
136- throw new Error ( `HTTP error! status: ${ response . status } ` ) ;
146+ const errorData = await response . text ( ) ;
147+ throw new Error ( `HTTP error! status: ${ response . status } , message: ${ errorData } ` ) ;
137148 }
138149 return response . json ( ) ;
139150 } )
0 commit comments