Feat: show colors by pressing words
This commit is contained in:
		| @@ -1,6 +1,7 @@ | ||||
| package handlers | ||||
|  | ||||
| import ( | ||||
| 	"golias/models" | ||||
| 	"html/template" | ||||
| 	"net/http" | ||||
| ) | ||||
| @@ -24,3 +25,24 @@ func HandleHideCreateForm(w http.ResponseWriter, r *http.Request) { | ||||
| 	} | ||||
| 	tmpl.ExecuteTemplate(w, "createform", show) | ||||
| } | ||||
|  | ||||
| func HandleShowColor(w http.ResponseWriter, r *http.Request) { | ||||
| 	word := r.URL.Query().Get("word") | ||||
| 	color, exists := roundWords[word] | ||||
| 	log.Debug("got show-color request", "word", word, "color", color) | ||||
| 	if !exists { | ||||
| 		abortWithError(w, "word is not found") | ||||
| 		return | ||||
| 	} | ||||
| 	tmpl, err := template.ParseGlob("components/*.html") | ||||
| 	if err != nil { | ||||
| 		abortWithError(w, err.Error()) | ||||
| 		return | ||||
| 	} | ||||
| 	cardword := models.WordCard{ | ||||
| 		Word:     word, | ||||
| 		Color:    models.StrToWordColor(color), | ||||
| 		Revealed: true, | ||||
| 	} | ||||
| 	tmpl.ExecuteTemplate(w, "cardword", cardword) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder