Paginador em ASP Clássico

<%
intPageCount = intPageCount
intCurrentPage = intCurrentPage
intIndexCount = intIndexCount
strToReturn = “<div class=’paginator’><div class=’base’>”
If (intCurrentPage <= 1) Then
strToReturn = strToReturn & “<span class=’prev off’><span class=’base’>Anterior</span></span> ”
Else
strToReturn = strToReturn & “<a class=’prev on’ href=’?intPage=” & (intCurrentPage-1) &”‘><span class=’base’>Anterior</span></a>”
End If
If (intPageCount <= intIndexCount) Then
‘We have less pages than total indexcount — so let’s go ahead
‘and just display all page indexes
For intIndex = 1 To intPageCount
If (intPageNumber = intIndex) Then
strToReturn = strToReturn & “<span class=’number off active’><span class=’base’>” & intIndex & “</span></span>”
Else
strToReturn = strToReturn & “<a class=’number on’ href=’?intPage=” & (intIndex) &”‘><span class=’base’>” & intIndex & “</span></a>”
End If
Next
Else
‘Figure Out Constants
intMinimumEndOfBunch = intIndexCount – 2
intMaximumStartOfBunch = intPageCount – intIndexCount + 3
intLeftOfBunchCount = Floor((intIndexCount – 5) / 2)
intRightOfBunchCount = Round((intIndexCount – 5.0) / 2.0)
intLeftBunchTrigger = 4 + intLeftOfBunchCount
intRightBunchTrigger = intMaximumStartOfBunch + Round((intIndexCount – 8.0) / 2.0)
If (intCurrentPage < intLeftBunchTrigger) Then
intPageStart = 1
strStartEllipsis = “”
Else
intPageStart = Min(intMaximumStartOfBunch, intCurrentPage – intLeftOfBunchCount)
strStartEllipsis = “<a class=’number on’ href=’?intPage=1′><span class=’base’>1</span></a>”
strStartEllipsis = strStartEllipsis & “<span class=’ellipsis’><span class=’base’>…</span></span>”
End If
If (intCurrentPage > intRightBunchTrigger) Then
intPageEnd = intPageCount
strEndEllipsis = “”
Else
intPageEnd = Max(intMinimumEndOfBunch, intCurrentPage + intRightOfBunchCount)
strEndEllipsis = “<span class=’ellipsis’><span class=’base’>…</span></span>”
strActionParameter = intPageCount
strEndEllipsis = strEndEllipsis & “<a class=’number on’ href=’?intPage=” & (intPageCount) &”‘ ><span class=’base’>” & intPageCount & “</span></a>”
End If
strToReturn = strToReturn & strStartEllipsis
For intIndex = intPageStart To intPageEnd
If (intCurrentPage = intIndex) Then
strToReturn = strToReturn & “<span class=’number off active’><span class=’base’>” & intIndex & “</span></span>”
Else
strToReturn = strToReturn & “<a class=’number on’ href=’?intPage=” & (intIndex) &”‘><span class=’base’>” & intIndex & “</span></a>”
End If
Next
strToReturn = strToReturn & strEndEllipsis
End If
If (intCurrentPage >= intPageCount) Then
strToReturn = strToReturn & “<span class=’next off’><span class=’base’>Próximo</span></span>”
Else
strToReturn = strToReturn & “<a class=’next on’ href=’?intPage=” & (intCurrentPage + 1) &”‘><span class=’base’>Próximo</span></a>”
End If
strToReturn = strToReturn & “</div></div>”
‘print paginator
Response.Write strToReturn
Function Ceil( Number )
Ceil = Int( Number )
if Ceil <> Number then
Ceil = Ceil + 1
end if
End Function
Function Floor( Number )
Floor = Int( Number )
End Function
Function Max( v1, v2 )
If v1 >= v2 Then Max = v1 Else Max = v2
End Function
Function Min( v1, v2 )
If v1 <= v2 Then Min = v1 Else Min = v2
End Function
%>
]]>