dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit e548cf6c2a6f63a16841ac9206e1202a2f92de85
parent 34ecb0708e35e0b1db4e318f1a8f3e2b87abe2fb
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Mon,  4 Dec 2023 17:37:30 -0500

trash

Diffstat:
Mpkg/web/handlers/handlers.go | 44+++++++++++++++++++++++---------------------
1 file changed, 23 insertions(+), 21 deletions(-)

diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go @@ -1045,17 +1045,16 @@ func PokerSitHandler(c echo.Context) error { g, found := PokerInstance.Games[roomID] PokerInstance.Unlock() if !found { - return c.NoContent(http.StatusNotFound) + return c.HTML(http.StatusOK, `<form method="post"><button>SIT</button></form>`) } if c.Request().Method == http.MethodPost { if g.Players[pos] != "" { fmt.Println("seat already taken") - return c.NoContent(http.StatusNotFound) + return c.HTML(http.StatusOK, `<form method="post"><button>SIT</button></form>`) } myTopic := "room_" + roomID g.Players[pos] = authUser.Username.String() PokerPubSub.Pub(myTopic, PokerSeatTakenEvent{}) - return c.HTML(http.StatusOK, ``) } return c.HTML(http.StatusOK, `<form method="post"><button>SIT</button></form>`) } @@ -1180,8 +1179,8 @@ body { border:1px solid black; } .takeSeat { - width: 100px; - height: 50px; + width: 40px; + height: 30px; } #seat1 { position: absolute; top: 80px; left: 700px; } #seat2 { position: absolute; top: 200px; left: 670px; } @@ -1189,13 +1188,13 @@ body { .takeSeat1 { position: absolute; top: 80px; left: 700px; } .takeSeat2 { position: absolute; top: 200px; left: 670px; } .takeSeat3 { position: absolute; top: 300px; left: 610px; } -.takeSeat4 { position: absolute; top: 300px; left: 610px; display: none; } -.takeSeat5 { position: absolute; top: 300px; left: 610px; display: none; } -.takeSeat6 { position: absolute; top: 300px; left: 610px; display: none; } -.takeSeat7 { position: absolute; top: 300px; left: 610px; display: none; } -.takeSeat8 { position: absolute; top: 300px; left: 610px; display: none; } -.takeSeat9 { position: absolute; top: 300px; left: 610px; display: none; } -.takeSeat10 { position: absolute; top: 300px; left: 610px; display: none; } +.takeSeat4 { position: absolute; top: 300px; left: 550px; } +.takeSeat5 { position: absolute; top: 300px; left: 500px; } +.takeSeat6 { position: absolute; top: 300px; left: 450px; } +.takeSeat7 { position: absolute; top: 300px; left: 400px; } +.takeSeat8 { position: absolute; top: 300px; left: 350px; } +.takeSeat9 { position: absolute; top: 300px; left: 300px; } +.takeSeat10 { position: absolute; top: 300px; left: 250px; } #dealBtn { position: absolute; top: 400px; left: 50px; } #unSitBtn { position: absolute; top: 430px; left: 50px; } </style>`) @@ -1237,14 +1236,15 @@ Loop: continue } - if evt, ok := payload.(PokerSeatLeftEvent); ok { + if _, ok := payload.(PokerSeatLeftEvent); ok { seated, _ := g.IsSeated(authUser.Username.String()) - if !seated { - send(`<style>.takeSeat` + strconv.Itoa(evt.Idx) + ` { display: block; }</style>`) - } for i, p := range g.Players { - if p != "" { + if p != "" || seated { send(`<style>.takeSeat` + strconv.Itoa(i+1) + ` { display: none; }</style>`) + } else { + send(`<style>.takeSeat` + strconv.Itoa(i+1) + ` { display: block; }</style>`) + } + if p != "" { send(`<style>#seat` + strconv.Itoa(i+1) + `:before { content: "` + p + `"; }</style>`) } else { send(`<style>#seat` + strconv.Itoa(i+1) + `:before { content: ""; }</style>`) @@ -1255,13 +1255,15 @@ Loop: } else if _, ok := payload.(PokerSeatTakenEvent); ok { - if seated, _ := g.IsSeated(authUser.Username.String()); seated { - send(`<style>.takeSeat { display: none; }</style>`) - } + seated, _ := g.IsSeated(authUser.Username.String()) for i, p := range g.Players { - if p != "" { + if p != "" || seated { send(`<style>.takeSeat` + strconv.Itoa(i+1) + ` { display: none; }</style>`) + } else { + send(`<style>.takeSeat` + strconv.Itoa(i+1) + ` { display: block; }</style>`) + } + if p != "" { send(`<style>#seat` + strconv.Itoa(i+1) + `:before { content: "` + p + `"; }</style>`) } else { send(`<style>#seat` + strconv.Itoa(i+1) + `:before { content: ""; }</style>`)