Skip to content

Commit d4e6ea9

Browse files
committed
added error message to index.html join fetch
changed all fetch URLs from local IP to cloud run URL
1 parent d7d07f4 commit d4e6ea9

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

Client/Web/index.html

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
})

server/main.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ func main() {
128128

129129
// Set up router and start server
130130
router.SetTrustedProxies(nil) // Disable trusted proxies because Gin told me to do it.. (neeed to investigate this further)
131-
//router.Run("localhost:8080")
132-
//router.Run("192.168.68.100:8080") // put your server address here
133-
//router.Run("https://fuji-llama-971660789205.asia-southeast1.run.app") // put your server address here") // put your server address here
131+
134132
router.Run(":" + port)
135133
}
136134

0 commit comments

Comments
 (0)