Spacebar now pauses automatic page refreshing

This commit is contained in:
Seednode 2023-10-08 17:38:09 -05:00
parent cf5fa04432
commit f36c0cc999
3 changed files with 3 additions and 3 deletions

View File

@ -53,7 +53,7 @@ The remaining four endpoints—`/available_extensions`, `/enabled_extensions`, `
## Refresh
If the `--refresh` flag is passed and a positive-value `refresh=<integer><unit>` query parameter is provided, the page will reload after that interval.
This can be used to generate a sort of slideshow of files.
This can be used to generate a sort of slideshow of files. Pressing Space will pause automatic refreshing until the page is manually refreshed or a new page is loaded.
Minimum accepted value is 500ms, as anything lower seems to cause inconsistent behavior. This might be changed in a future release.

View File

@ -12,7 +12,7 @@ import (
)
const (
ReleaseVersion string = "2.7.2"
ReleaseVersion string = "2.8.0"
)
var (

View File

@ -325,7 +325,7 @@ func serveMedia(paths []string, regexes *regexes, index *fileIndex, formats type
htmlBody.WriteString(title)
htmlBody.WriteString(`</head><body>`)
if refreshInterval != "0ms" {
htmlBody.WriteString(fmt.Sprintf("<script>window.onload = function(){setInterval(function(){window.location.href = '%s';}, %d);};</script>",
htmlBody.WriteString(fmt.Sprintf("<script>window.onload = function(){clear = setInterval(function(){window.location.href = '%s';}, %d); document.body.onkeyup = function(e) { if (e.key == \"\" || e.code == \"Space\" || e.keyCode == 32){clearInterval(clear)}}};</script>",
rootUrl,
refreshTimer))
}