Disable prev/next buttons when at beginning/end of debug lists
This commit is contained in:
parent
51971feb87
commit
189b7d269c
44
cmd/debug.go
44
cmd/debug.go
|
@ -68,22 +68,42 @@ func serveDebugHtml(args []string, index *Index, paginate bool) httprouter.Handl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if pageLength != 0 {
|
if pageLength != 0 {
|
||||||
nextPage := page + 1
|
var lastPage int
|
||||||
|
|
||||||
if nextPage > (fileCount/int(pageLength)) && fileCount%int(pageLength) == 0 {
|
if fileCount%int(pageLength) == 0 {
|
||||||
nextPage = fileCount / int(pageLength)
|
lastPage = fileCount / int(pageLength)
|
||||||
} else if nextPage > (fileCount / int(pageLength)) {
|
} else {
|
||||||
nextPage = (fileCount / int(pageLength)) + 1
|
lastPage = (fileCount / int(pageLength)) + 1
|
||||||
}
|
|
||||||
|
|
||||||
prevPage := page - 1
|
|
||||||
if prevPage < 1 {
|
|
||||||
prevPage = 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if paginate {
|
if paginate {
|
||||||
htmlBody.WriteString(fmt.Sprintf("<button onclick=\"window.location.href = '/html/%d';\">Prev</button>", prevPage))
|
var prevStatus, nextStatus string = "", ""
|
||||||
htmlBody.WriteString(fmt.Sprintf("<button onclick=\"window.location.href = '/html/%d';\">Next</button>", nextPage))
|
|
||||||
|
if page <= 1 {
|
||||||
|
prevStatus = "disabled"
|
||||||
|
}
|
||||||
|
|
||||||
|
if page >= lastPage {
|
||||||
|
nextStatus = "disabled"
|
||||||
|
}
|
||||||
|
|
||||||
|
prevPage := page - 1
|
||||||
|
if prevPage < 1 {
|
||||||
|
prevPage = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
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 (
|
const (
|
||||||
Version string = "0.65.0"
|
Version string = "0.66.1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
Loading…
Reference in New Issue