Disable prev/next buttons when at beginning/end of debug lists

This commit is contained in:
Seednode 2023-09-11 14:09:12 -05:00
parent 51971feb87
commit 189b7d269c
2 changed files with 33 additions and 13 deletions

View File

@ -68,12 +68,23 @@ func serveDebugHtml(args []string, index *Index, paginate bool) httprouter.Handl
}
}
if pageLength != 0 {
nextPage := page + 1
var lastPage int
if nextPage > (fileCount/int(pageLength)) && fileCount%int(pageLength) == 0 {
nextPage = fileCount / int(pageLength)
} else if nextPage > (fileCount / int(pageLength)) {
nextPage = (fileCount / int(pageLength)) + 1
if fileCount%int(pageLength) == 0 {
lastPage = fileCount / int(pageLength)
} else {
lastPage = (fileCount / int(pageLength)) + 1
}
if paginate {
var prevStatus, nextStatus string = "", ""
if page <= 1 {
prevStatus = "disabled"
}
if page >= lastPage {
nextStatus = "disabled"
}
prevPage := page - 1
@ -81,9 +92,18 @@ func serveDebugHtml(args []string, index *Index, paginate bool) httprouter.Handl
prevPage = 1
}
if paginate {
htmlBody.WriteString(fmt.Sprintf("<button onclick=\"window.location.href = '/html/%d';\">Prev</button>", prevPage))
htmlBody.WriteString(fmt.Sprintf("<button onclick=\"window.location.href = '/html/%d';\">Next</button>", nextPage))
nextPage := page + 1
if nextPage > lastPage {
nextPage = fileCount / int(pageLength)
}
htmlBody.WriteString(fmt.Sprintf("<button onclick=\"window.location.href = '/html/%d';\" %s>Prev</button>",
prevPage,
prevStatus))
htmlBody.WriteString(fmt.Sprintf("<button onclick=\"window.location.href = '/html/%d';\" %s>Next</button>",
nextPage,
nextStatus))
}
}

View File

@ -12,7 +12,7 @@ import (
)
const (
Version string = "0.65.0"
Version string = "0.66.1"
)
var (