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 {
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
if paginate {
|
||||||
|
var prevStatus, nextStatus string = "", ""
|
||||||
|
|
||||||
|
if page <= 1 {
|
||||||
|
prevStatus = "disabled"
|
||||||
|
}
|
||||||
|
|
||||||
|
if page >= lastPage {
|
||||||
|
nextStatus = "disabled"
|
||||||
}
|
}
|
||||||
|
|
||||||
prevPage := page - 1
|
prevPage := page - 1
|
||||||
|
@ -81,9 +92,18 @@ func serveDebugHtml(args []string, index *Index, paginate bool) httprouter.Handl
|
||||||
prevPage = 1
|
prevPage = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if paginate {
|
nextPage := page + 1
|
||||||
htmlBody.WriteString(fmt.Sprintf("<button onclick=\"window.location.href = '/html/%d';\">Prev</button>", prevPage))
|
if nextPage > lastPage {
|
||||||
htmlBody.WriteString(fmt.Sprintf("<button onclick=\"window.location.href = '/html/%d';\">Next</button>", nextPage))
|
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