Disable prev/next buttons when at beginning/end of debug lists
This commit is contained in:
parent
51971feb87
commit
189b7d269c
36
cmd/debug.go
36
cmd/debug.go
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
Version string = "0.65.0"
|
||||
Version string = "0.66.1"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
Loading…
Reference in New Issue