diff --git a/cmd/debug.go b/cmd/debug.go index 25d9d8f..e462950 100644 --- a/cmd/debug.go +++ b/cmd/debug.go @@ -68,22 +68,42 @@ 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 - } - - prevPage := page - 1 - if prevPage < 1 { - prevPage = 1 + if fileCount%int(pageLength) == 0 { + lastPage = fileCount / int(pageLength) + } else { + lastPage = (fileCount / int(pageLength)) + 1 } if paginate { - htmlBody.WriteString(fmt.Sprintf("", prevPage)) - htmlBody.WriteString(fmt.Sprintf("", nextPage)) + var prevStatus, nextStatus string = "", "" + + 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("", + prevPage, + prevStatus)) + + htmlBody.WriteString(fmt.Sprintf("", + nextPage, + nextStatus)) } } diff --git a/cmd/root.go b/cmd/root.go index 0812fa7..7a057cd 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -12,7 +12,7 @@ import ( ) const ( - Version string = "0.65.0" + Version string = "0.66.1" ) var (