commit f2f9073ea76d21a544890fd01d3957a71fa6ecf3
parent 6af8cca6bb64272a65431633e21b9ea3d0fb1bc9
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Tue, 19 Dec 2023 02:34:49 -0500
template
Diffstat:
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go
@@ -1,6 +1,7 @@
package poker
import (
+ "bytes"
"dkforest/pkg/database"
"dkforest/pkg/pubsub"
"dkforest/pkg/utils"
@@ -9,6 +10,7 @@ import (
"fmt"
"github.com/chehsunliu/poker"
"github.com/sirupsen/logrus"
+ "html/template"
"math"
"math/rand"
"sort"
@@ -1730,21 +1732,20 @@ func buildCountdownsHtml() (html string) {
}
func buildActionsDiv(roomID RoomID) (html string) {
- roomIDStr := roomID.String()
- html += `
+ htmlTmpl := `
<table id="actionsDiv">
<tr>
<td>
- <iframe src="/poker/` + roomIDStr + `/deal" id="dealBtn"></iframe>
- <iframe src="/poker/` + roomIDStr + `/unsit" id="unSitBtn"></iframe>
+ <iframe src="/poker/{{ .RoomID }}/deal" id="dealBtn"></iframe>
+ <iframe src="/poker/{{ .RoomID }}/unsit" id="unSitBtn"></iframe>
</td>
<td style="vertical-align: top;" rowspan="2">
- <iframe src="/poker/` + roomIDStr + `/bet" id="betBtn"></iframe>
+ <iframe src="/poker/{{ .RoomID }}/bet" id="betBtn"></iframe>
</td>
<td>
- <iframe src="/poker/` + roomIDStr + `/call" id="callBtn"></iframe>
- <iframe src="/poker/` + roomIDStr + `/check" id="checkBtn"></iframe>
- <iframe src="/poker/` + roomIDStr + `/fold" id="foldBtn"></iframe>
+ <iframe src="/poker/{{ .RoomID }}/call" id="callBtn"></iframe>
+ <iframe src="/poker/{{ .RoomID }}/check" id="checkBtn"></iframe>
+ <iframe src="/poker/{{ .RoomID }}/fold" id="foldBtn"></iframe>
</td>
</tr>
<tr>
@@ -1755,7 +1756,14 @@ func buildActionsDiv(roomID RoomID) (html string) {
<td colspan="3"><div id="errorMsg"></div></td>
</tr>
</table>`
- return
+ data := map[string]any{
+ "RoomID": roomID.String(),
+ }
+ var buf bytes.Buffer
+ if err := utils.Must(template.New("").Parse(htmlTmpl)).Execute(&buf, data); err != nil {
+ logrus.Error(err)
+ }
+ return buf.String()
}
func buildSeatsHtml(g *PokerGame, authUser *database.User) (html string) {