分页的解析处理(ASP)

部署运行你感兴趣的模型镜像

<%@ Language = VBScript %>
<% Option Explicit %>
<script language="javascript">
function fPageClick(pageno){
 var url = ''
 url = 'page.asp' +
  '?crtpage=' + pageno
  document.location.replace(url);
}
</script>
<%
Const GSTR_DIS_FVLH_TTL_BACK  = "<<前へ"
Const GSTR_DIS_FVLH_TTL_FWRD  = "次へ>>"
'==========================================================
'機能 : 表示用ページ番号解析処理
'引数 : なし
'      total  IN 全ページ数
'      current  IN カレントのページ
'      dispnum  IN 中央表示ページ数 ※ 奇数
'      amari  IN 余りページ表示数 指定数に大体近い数が採用される
'      aryPagesL OUT 左ページ番号の配列
'      aryPagesM OUT 中央ページ番号の配列
'      aryPagesR OUT 右ページ番号の配列
'      jmpL  OUT 左ジャンプ数
'      jmpR  OUT 右ジャンプ数
'返却値 : なし
'==========================================================
Function fblnGetArrayOfManyPages(ByVal total, ByVal current, ByVal dispnum, ByVal amari, ByRef aryPagesL, ByRef aryPagesM, ByRef aryPagesR, ByRef jmpL, ByRef jmpR)


 Dim currentL, currentR 'カレント5件の左右のページ番号
 Dim lenL, lenR   'カレント左右の残り件数
 Dim sepL, sepR   '左右のジャンプ間隔
 Dim viewL, viewR  '左右の実表示個数

 fblnGetArrayOfManyPages = False

 If current > total Or current < 1 Then Exit Function
 If total <= 0      Then Exit Function
 If dispnum <= 0      Then Exit Function
 If dispnum / 2 = Int(dispnum / 2) Then Exit Function
 If amari <= 0      Then Exit Function

 currentL = current - Int(dispnum / 2)
 If currentL <= 2 Then
  currentL = 1
  currentR = dispnum
 Else
  currentR = current + Int(dispnum / 2)
  If currentR >= total - 3 Then
   currentL = total - dispnum
   currentR = total
  End If
 End If

 If total <= dispnum Then
  currentL = 1
  currentR = total
 End If

 lenL = currentL - 1
 lenR = total - currentR

 If lenL <= 0 Then
  viewL = 1
 Else
  viewL = Round(amari * lenL / (lenL +lenR), 0)
 End If

 If lenR <= 0 Then
  viewR = total
 Else
  viewR = Round(amari * lenR / (lenL +lenR), 0)
 End If

 sepL = 0
 sepR = 0

 If viewL > 0 Then
  sepL = Round(LenL / viewL, 0)
  If sepL < 1 Then sepL = 1
 End If

 If viewR > 0 Then
  sepR = Round(LenR / viewR, 0)
  If sepR < 1 Then sepR = 1
 End If

 'ページ配列の生成

 Dim intPagesL, intPagesM, intPagesR
 Dim i

 intPagesL = 0
 If sepL > 0 Then
  For i = 1 To currentL Step sepL
   If i >= currentL Then Exit For
   If Not IsArray(aryPagesL) Then aryPagesL = Array(-1)
   ReDim Preserve aryPagesL(intPagesL)
   aryPagesL(intPagesL) = i
   intPagesL = intPagesL + 1
  Next
 Else
  If currentL > 1 Then
   If Not IsArray(aryPagesL) Then aryPagesL = Array(-1)
   ReDim Preserve aryPagesL(intPagesL)
   aryPagesL(intPagesL) = 1
  End If
 End If

 intPagesM = 0
 For i = currentL To currentR
  If Not IsArray(aryPagesM) Then aryPagesM = Array(-1)
  ReDim Preserve aryPagesM(intPagesM)
  aryPagesM(intPagesM) = i
  intPagesM = intPagesM + 1
 Next

 If total > currentR  Then
  intPagesR = 0
  If sepR > 0 Then
   For i = currentR + sepR To total Step sepR
    If i >= total Then
'     If intPagesR > 0 Then
'      intPagesR = intPagesR - 1
'     End If
     Exit For
    End If
    If Not IsArray(aryPagesR) Then aryPagesR = Array(-1)
    ReDim Preserve aryPagesR(intPagesR)
    aryPagesR(intPagesR) = i
    intPagesR = intPagesR + 1
   Next
  End If
  If Not IsArray(aryPagesR) Then aryPagesR = Array(-1)
  ReDim Preserve aryPagesR(intPagesR)
  aryPagesR(intPagesR) = total
 End If

 jmpL = sepL
 jmpR = sepR

 fblnGetArrayOfManyPages = True
End Function


Function fGetPageHTML(strHTML,totalPage,currentPage,dispnum,amari)

 Dim aryPagesL, aryPagesM, aryPagesR, jmpL, jmpR, i, intTempPage
 
   'If fblnGetArrayOfManyPages(lngPageNumber, lngCurentPage, 5, 6, aryPagesL, aryPagesM, aryPagesR, jmpL, jmpR) Then
   If fblnGetArrayOfManyPages(totalPage, currentPage, dispnum, amari, aryPagesL, aryPagesM, aryPagesR, jmpL, jmpR) Then
    Dim strDisp, strDelmiL, strDelmiR

    If currentPage = 1 Then
     strHTML = strHTML & GSTR_DIS_FVLH_TTL_BACK & "&nbsp;"
    Else
     strHTML = strHTML & "<a href=javascript:fPageClick("  & currentPage-1 & ")>" & GSTR_DIS_FVLH_TTL_BACK & "</a>&nbsp;"
    End If

    
    '## 実ページ番号の表示部分
    strDelmiL = "&hellip;"
    strDelmiR = "&hellip;"

    If jmpL <= 1 Then
     strDelmiL = "&nbsp;"
    End If
    If jmpR <= 1 Then
     strDelmiR = "&nbsp;"
    End If

    If IsArray(aryPagesL) Then
     intTempPage = CInt(-100)
     For i = 0 To UBound(aryPagesL)
      If (intTempPage + 1) < CInt(aryPagesL(i)) Then
       strHTML = strHTML & "<a href=javascript:fPageClick("  & CStr(aryPagesL(i)) & ")>" & CStr(aryPagesL(i)) & "</a>" & strDelmiL
       intTempPage = CInt(aryPagesL(i))
      End If
     Next
    End If

    If IsArray(aryPagesM) Then
     For i = 0 To UBound(aryPagesM)
      If Int(aryPagesM(i)) = Int(currentPage) Then
       strHTML = strHTML & "<b>[" & CStr(aryPagesM(i)) & "]</b>"
      Else
       strHTML = strHTML & "<a href=javascript:fPageClick("  & CStr(aryPagesM(i)) & ")>" & CStr(aryPagesM(i)) & "</a>"
      End If
      If i <> UBound(aryPagesM) Then
       strHTML = strHTML & "&nbsp;"
      End If
     Next
    End If

    If IsArray(aryPagesR) Then
     Dim strHTMLWork : strHTMLWork = ""
     intTempPage = CInt(aryPagesR(UBound(aryPagesR))) + 100
     For i = UBound(aryPagesR) To 0 Step -1
      If (intTempPage - 1) > CInt(aryPagesR(i)) Then
       strHTMLWork = strDelmiR & "<a href=javascript:fPageClick("  & CStr(aryPagesR(i)) & ")>" & CStr(aryPagesR(i)) & "</a>" & strHTMLWork
       intTempPage = CInt(aryPagesR(i))
      End If
     Next
     strHTML = strHTML & strHTMLWork
    End If

    '## 「次へ>>」の表示部分
    If Int(currentPage) = Int(currentPage) Then
     strHTML = strHTML & "&nbsp;" & GSTR_DIS_FVLH_TTL_FWRD & "</td>"
    Else
     strHTML = strHTML & "&nbsp;<a href=javascript:fPageClick("  & currentPage+1 & ")>" & GSTR_DIS_FVLH_TTL_FWRD & "</a></td>"
    End If
   Else
    strHTML = strHTML & ""
   End If
End Function

 

Dim lngCurentPage
Dim strHTML
Dim blnRet

If Request.QueryString("crtpage")<>"" Then
 lngCurentPage = CLng(Request.QueryString("crtpage"))
Else
 lngCurentPage = 1
End If
blnRet = fGetPageHTML(strHTML,1000,lngCurentPage,5,6)
response.write(strHTML)
%>

您可能感兴趣的与本文相关的镜像

ACE-Step

ACE-Step

音乐合成
ACE-Step

ACE-Step是由中国团队阶跃星辰(StepFun)与ACE Studio联手打造的开源音乐生成模型。 它拥有3.5B参数量,支持快速高质量生成、强可控性和易于拓展的特点。 最厉害的是,它可以生成多种语言的歌曲,包括但不限于中文、英文、日文等19种语言

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值