Add an emote list

It's ugly, but it get's the job done.  This list will need to be
improved a lot (ie, make it searchable and maybe even clickable
emotes?).  This is for #99, but should not be considered fixed yet.
This commit is contained in:
Zorchenhimer 2019-11-29 12:48:17 -05:00
parent 528b29e0ff
commit 8fc3f86135
9 changed files with 64 additions and 3 deletions

View File

@ -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) {

View File

@ -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,

View File

@ -34,6 +34,7 @@ const (
CmdRefreshPlayer
CmdPurgeChat
CmdHelp
CmdEmotes
)
type CommandLevel int

View File

@ -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{

View File

@ -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 {

View File

@ -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)

View File

@ -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%;

14
static/emotes.html Normal file
View File

@ -0,0 +1,14 @@
{{define "header"}}
{{end}}
{{define "body"}}
<div id="emotesbody">
<h2>Available Emotes</h2>
{{range $k, $v := .Emotes}}
<div class="emotedef">
<div><img src="{{$v}}" /></div>
<div>{{$k}}</div>
</div>
{{end}}
</div>
{{end}}

View File

@ -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")
}
}
}