Refresh now happens X seconds after page finishes completely loading, not X seconds after the initial request is sent
This commit is contained in:
parent
b6a46a63b6
commit
28af94cba3
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var Version = "0.25.1"
|
||||
var Version = "0.25.2"
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
|
|
15
cmd/web.go
15
cmd/web.go
|
@ -195,22 +195,23 @@ func serveHtml(w http.ResponseWriter, r *http.Request, filePath string, dimensio
|
|||
dimensions.Width,
|
||||
dimensions.Height))
|
||||
htmlBody.WriteString(`</head><body>`)
|
||||
htmlBody.WriteString(fmt.Sprintf(`<a href="/%v"><img src="%v" width="%v" height="%v" alt="Roulette selected: %v"></a>`,
|
||||
queryParams,
|
||||
generateFilePath(filePath),
|
||||
dimensions.Width,
|
||||
dimensions.Height,
|
||||
fileName))
|
||||
if refreshInterval != "0" {
|
||||
r, err := strconv.Atoi(refreshInterval)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
refreshTimer := strconv.Itoa(r * 1000)
|
||||
htmlBody.WriteString(fmt.Sprintf(`<script>setTimeout(function(){window.location.href = '/%v';},%v);</script>`,
|
||||
|
||||
htmlBody.WriteString(fmt.Sprintf("<script>window.onload = function(){setInterval(function(){window.location.href = '/%v';}, %v);};</script>",
|
||||
queryParams,
|
||||
refreshTimer))
|
||||
}
|
||||
htmlBody.WriteString(fmt.Sprintf(`<a href="/%v"><img src="%v" width="%v" height="%v" alt="Roulette selected: %v"></a>`,
|
||||
queryParams,
|
||||
generateFilePath(filePath),
|
||||
dimensions.Width,
|
||||
dimensions.Height,
|
||||
fileName))
|
||||
htmlBody.WriteString(`</body></html>`)
|
||||
|
||||
_, err := io.WriteString(w, gohtml.Format(htmlBody.String()))
|
||||
|
|
Loading…
Reference in New Issue