commit e6289f9fe6deb91ad8bfb9a6a79fc6f9be1fb224
parent a7795c25d99df78bf786775deda44b9f6b441d05
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Tue, 19 Dec 2023 12:46:32 -0500
cleanup
Diffstat:
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go
@@ -1937,8 +1937,8 @@ func drawYourTurnHtml(authUser *database.User) (html string) {
func drawCountDownStyle(evt PokerWaitTurnEvent) string {
html := "<style>"
- html += `#countdown1, #countdown2, #countdown3, #countdown4, #countdown5, #countdown6 { display: none; }`
- html += `#seat1, #seat2, #seat3, #seat4, #seat5, #seat6 { background-color: rgba(45, 45, 45, 0.4); }`
+ html += hideCountdowns()
+ html += resetSeatsBackgroundColor()
remainingSecs := int((MaxUserCountdown*time.Second - time.Since(evt.CreatedAt)).Seconds())
if evt.Idx >= 0 && evt.Idx <= 5 {
idxStr := itoa(evt.Idx + 1)
@@ -1949,9 +1949,29 @@ func drawCountDownStyle(evt PokerWaitTurnEvent) string {
return html
}
+func createCssIDList(idFmt string) (out string) {
+ cssIDList := make([]string, 0)
+ for i := 1; i <= NbPlayers; i++ {
+ cssIDList = append(cssIDList, fmt.Sprintf(idFmt, itoa(i)))
+ }
+ return strings.Join(cssIDList, ", ")
+}
+
+func hideCountdowns() (out string) {
+ return createCssIDList("#countdown%s") + ` { display: none; }`
+}
+
+func resetSeatsBackgroundColor() (out string) {
+ return createCssIDList("#seat%s") + ` { background-color: rgba(45, 45, 45, 0.4); }`
+}
+
+func resetSeatsPot() (out string) {
+ return createCssIDList("#seat%sPot:before") + ` { content: ""; }`
+}
+
func drawMainPotHtml(evt PokerMainPotUpdatedEvent) (html string) {
html += `<style>`
- html += `#seat1Pot:before, #seat2Pot:before, #seat3Pot:before, #seat4Pot:before, #seat5Pot:before, #seat6Pot:before { content: ""; }`
+ html += resetSeatsPot()
html += `#mainPot:before { content: "Pot: ` + itoa2(evt.MainPot) + `"; }`
html += `</style>`
return