dkforest

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

commit 4f73cd833637b37c80ac0a4df46f5db8abe70a92
parent b10ed9d632b9610e934a7f2f7e2b76805993cdd5
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Tue,  5 Dec 2023 16:19:16 -0500

cleanup

Diffstat:
Mpkg/web/handlers/poker.go | 30++++++++++++------------------
1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/pkg/web/handlers/poker.go b/pkg/web/handlers/poker.go @@ -611,6 +611,15 @@ func PokerSitHandler(c echo.Context) error { return c.HTML(http.StatusOK, `<form method="post"><button>SIT</button></form>`) } +func colorForCard(name string) string { + color := "black" + if strings.Contains(name, "♥") || + strings.Contains(name, "♦") { + color = "darkred" + } + return color +} + func buildYourCardsHtml(authUser *database.User, g *PokerGame) string { html := `<div style="position: absolute; top: 450px; left: 200px;"><div id="yourCard1"></div><div id="yourCard2"></div></div>` if g.Ongoing != nil { @@ -623,20 +632,10 @@ func buildYourCardsHtml(authUser *database.User, g *PokerGame) string { } html += `<style>` if len(cards) >= 1 { - color := "black" - if strings.Contains(cards[0].Name, "♥") || - strings.Contains(cards[0].Name, "♦") { - color = "darkred" - } - html += `#yourCard1:before { content: "` + cards[0].Name + `"; color: ` + color + `; }` + html += `#yourCard1:before { content: "` + cards[0].Name + `"; color: ` + colorForCard(cards[0].Name) + `; }` } if len(cards) == 2 { - color := "black" - if strings.Contains(cards[1].Name, "♥") || - strings.Contains(cards[1].Name, "♦") { - color = "darkred" - } - html += `#yourCard2:before { content: "` + cards[1].Name + `"; color: ` + color + `; }` + html += `#yourCard2:before { content: "` + cards[1].Name + `"; color: ` + colorForCard(cards[1].Name) + `; }` } html += `</style>` } @@ -977,12 +976,7 @@ Loop: continue } else if evt, ok := payload.(YourCardEvent); ok { - color := "black" - if strings.Contains(evt.Name, "♥") || - strings.Contains(evt.Name, "♦") { - color = "darkred" - } - send(`<style>#yourCard` + strconv.Itoa(evt.Idx) + `:before { content: "` + evt.Name + `"; color: ` + color + `; }</style>`) + send(`<style>#yourCard` + strconv.Itoa(evt.Idx) + `:before { content: "` + evt.Name + `"; color: ` + colorForCard(evt.Name) + `; }</style>`) c.Response().Flush() continue