diff --git a/chatcommands.go b/chatcommands.go index a3560ba..bf6f8ac 100644 --- a/chatcommands.go +++ b/chatcommands.go @@ -40,6 +40,14 @@ var commands = &CommandControl{ Function: cmdHelp, }, + common.CNEmotes.String(): Command{ + HelpText: "Display a list of available emotes.", + Function: func(client *Client, args []string) (string, error) { + client.SendChatData(common.NewChatCommand(common.CmdEmotes, []string{"/emotes"})) + return "Opening emote list in new window.", nil + }, + }, + common.CNCount.String(): Command{ HelpText: "Display number of users in chat.", Function: func(client *Client, args []string) (string, error) { diff --git a/common/chatcommands.go b/common/chatcommands.go index 6ffb52d..8e9abc5 100644 --- a/common/chatcommands.go +++ b/common/chatcommands.go @@ -23,6 +23,7 @@ var ( CNNick ChatCommandNames = []string{"nick", "name"} CNStats ChatCommandNames = []string{"stats"} CNPin ChatCommandNames = []string{"pin", "password"} + CNEmotes ChatCommandNames = []string{"emotes"} // Mod Commands CNSv ChatCommandNames = []string{"sv"} CNPlaying ChatCommandNames = []string{"playing"} @@ -53,6 +54,7 @@ var ChatCommands = []ChatCommandNames{ CNNick, CNStats, CNPin, + CNEmotes, // Mod CNSv, diff --git a/common/constants.go b/common/constants.go index a96d25c..56aebc5 100644 --- a/common/constants.go +++ b/common/constants.go @@ -34,6 +34,7 @@ const ( CmdRefreshPlayer CmdPurgeChat CmdHelp + CmdEmotes ) type CommandLevel int diff --git a/common/templates.go b/common/templates.go index 1bc7ed8..e8b3abb 100644 --- a/common/templates.go +++ b/common/templates.go @@ -18,9 +18,10 @@ var isServer bool = false // keys and files to load for that template var serverTemplateDefs map[string][]string = map[string][]string{ - "pin": []string{"./static/base.html", "./static/thedoor.html"}, - "main": []string{"./static/base.html", "./static/main.html"}, - "help": []string{"./static/base.html", "./static/help.html"}, + "pin": []string{"./static/base.html", "./static/thedoor.html"}, + "main": []string{"./static/base.html", "./static/main.html"}, + "help": []string{"./static/base.html", "./static/help.html"}, + "emotes": []string{"./static/base.html", "./static/emotes.html"}, } var chatTemplateDefs map[string]string = map[string]string{ diff --git a/handlers.go b/handlers.go index fbbcc41..3cdbfad 100644 --- a/handlers.go +++ b/handlers.go @@ -271,6 +271,23 @@ func handleHelpTemplate(w http.ResponseWriter, r *http.Request) { } } +func handleEmoteTemplate(w http.ResponseWriter, r *http.Request) { + type Data struct { + Title string + Emotes map[string]string + } + + data := Data{ + Title: "Available Emotes", + Emotes: common.Emotes, + } + + err := common.ExecuteServerTemplate(w, "emotes", data) + if err != nil { + common.LogErrorf("Error executing file, %v", err) + } +} + func handlePin(w http.ResponseWriter, r *http.Request) { session, err := sstore.Get(r, "moviesession") if err != nil { diff --git a/main.go b/main.go index ab013ff..1db444a 100644 --- a/main.go +++ b/main.go @@ -130,6 +130,7 @@ func startServer() { http.HandleFunc("/video", handleIndexTemplate) http.HandleFunc("/help", handleHelpTemplate) http.HandleFunc("/pin", handlePin) + http.HandleFunc("/emotes", handleEmoteTemplate) http.HandleFunc("/", handleDefault) diff --git a/static/css/site.css b/static/css/site.css index 4a9b33c..67517b4 100644 --- a/static/css/site.css +++ b/static/css/site.css @@ -109,6 +109,19 @@ input[type=text] { color: white; } +#emotesbody { + color: var(--var-message-color); +} + +.emotedef { + display: flex; + flex-direction: row; +} + +.emotedef div { + padding: 5px; +} + .notice { color: #595959; font-size: 75%; diff --git a/static/emotes.html b/static/emotes.html new file mode 100644 index 0000000..d4d2f93 --- /dev/null +++ b/static/emotes.html @@ -0,0 +1,14 @@ +{{define "header"}} +{{end}} + +{{define "body"}} +
+

Available Emotes

+ {{range $k, $v := .Emotes}} +
+
+
{{$k}}
+
+ {{end}} +
+{{end}} diff --git a/wasm/main.go b/wasm/main.go index 31032e9..18e6b37 100644 --- a/wasm/main.go +++ b/wasm/main.go @@ -148,6 +148,10 @@ func recieve(v []js.Value) { } appendMessage(d.HTML()) global.Get("window").Call("open", url, "_blank", "menubar=0,status=0,toolbar=0,width=300,height=600") + case common.CmdEmotes: + url := "/emotes" + appendMessage(d.HTML()) + global.Get("window").Call("open", url, "_blank", "menubar=0,status=0,toolbar=0,width=300,height=600") } } }