MCPcopy Index your code
hub / github.com/TruthHun/BookStack / GetPagerHtml

Function GetPagerHtml

utils/pager.go:98–128  ·  view source on GitHub ↗
(requestURI string, pageIndex, pageSize, totalCount int)

Source from the content-addressed store, hash-verified

96}
97
98func GetPagerHtml(requestURI string, pageIndex, pageSize, totalCount int) html.HTML {
99 po := &PageOptions{
100 CurrentPage: pageIndex,
101 PageSize: pageSize,
102 EnableFirstLastLink: true,
103 ParamName: "page",
104 TotalPages: int(math.Ceil(float64(totalCount) / float64(pageSize))),
105 LinkItemCount: 5,
106 }
107 totalPages := int(math.Ceil(float64(totalCount) / float64(pageSize)))
108
109 setDefault(po, totalPages)
110 DealUri(po, requestURI)
111 str := ""
112 if totalPages <= po.LinkItemCount {
113 str = fun1(po, totalPages) //显示完全 12345678910
114 } else if totalPages > po.LinkItemCount {
115 if po.CurrentPage < po.LinkItemCount {
116 str = fun2(po, totalPages) //123456789...200
117 } else {
118 if po.CurrentPage+po.LinkItemCount < totalPages {
119 str = fun3(po, totalPages)
120 } else {
121 str = fun4(po, totalPages)
122 }
123 }
124 }
125 str = strings.Replace(str, "?&", "?", -1)
126 //str = strings.Replace(str,"&&","&",-1)
127 return html.HTML(str)
128}
129
130/**
131 * 处理url,目的是保存参数

Callers 5

HistoryMethod · 0.92
SitemapMethod · 0.92
UsersMethod · 0.92
CommentsMethod · 0.92
AttachListMethod · 0.92

Calls 7

setDefaultFunction · 0.85
DealUriFunction · 0.85
fun1Function · 0.85
fun2Function · 0.85
fun3Function · 0.85
fun4Function · 0.85
ReplaceMethod · 0.45

Tested by

no test coverage detected