最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JS分頁(yè)控件 可用于無(wú)刷新分頁(yè)

 更新時(shí)間:2013年07月23日 12:32:55   作者:  
今天無(wú)意看到了這個(gè)分頁(yè)控件,不過(guò)使用方法不是很清楚沒(méi)有研究,。大家可以自行研究,里面的函數(shù)寫法倒是不錯(cuò),需要內(nèi)容的結(jié)合

JS分頁(yè)控件,可用于無(wú)刷新分頁(yè)

復(fù)制代碼 代碼如下:

function PagerBar(recordcount, pagesize, pageindex, showpagecount) {
    var NumberRegex = new RegExp(/^\d+$/);
    this.PageIndex = 1; //頁(yè)索引,當(dāng)前頁(yè)
    if (pageindex != null && NumberRegex.test(pageindex)) this.PageIndex = parseInt(pageindex);
    this.PageSize = 10; //頁(yè)面大小
    if (pagesize != null && NumberRegex.test(pagesize)) this.PageSize = parseInt(pagesize);
    this.RecordCount = 0;
    if (recordcount != null && NumberRegex.test(recordcount)) this.RecordCount = parseInt(recordcount); //記錄總數(shù)
    this.PageCount = 0;  //頁(yè)總數(shù)
    var PagerBar = this;
    function CalculatePageCount(_pagesize, _recordcount) {//計(jì)算總頁(yè)數(shù)
        if (_pagesize != null && NumberRegex.test(_pagesize)) PagerBar.PageSize = parseInt(_pagesize);
        if (_recordcount != null && NumberRegex.test(_recordcount)) PagerBar.RecordCount = parseInt(_recordcount);
        else PagerBar.RecordCount = 0;
        if (PagerBar.RecordCount % PagerBar.PageSize == 0) {//計(jì)算總也頁(yè)數(shù)
            PagerBar.PageCount = parseInt(PagerBar.RecordCount / PagerBar.PageSize);
        }
        else {
            PagerBar.PageCount = parseInt(PagerBar.RecordCount / PagerBar.PageSize) + 1;
        }
    }
    if (this.RecordCount != 0) {//如果傳入了記錄總數(shù)則計(jì)算總頁(yè)數(shù)
        CalculatePageCount(this.PageSize, this.RecordCount);
    }
    this.ReplaceString = "《#PageLink》"; //替換頁(yè)數(shù)的文本,注:不可以有正則表達(dá)式中的符號(hào)
    this.ShowPagesCount = 5; //顯示頁(yè)數(shù)量
    if (showpagecount != null && NumberRegex.test(showpagecount.toString())) this.ShowPagesCount = parseInt(showpagecount);
    this.PreviouBarFormat = ""; //上一頁(yè)顯示文本格式
    this.IsShowPreviouString = true; //是否顯示上一頁(yè)
    this.NextBarFormat = ""; //下一頁(yè)顯示文本格式
    this.IsShowNextString = true; //是否顯示下一頁(yè)
    this.PageBarFormat = ""; //頁(yè)面連接顯示文本格式
    this.CurrentBarFormat = ""; //當(dāng)前頁(yè)顯示文本格式
    this.IsShowPageString = true; //是否顯示頁(yè)索引
    this.FristBarFormat = ""; //首頁(yè)鏈接顯示文本格式
    this.IsShowFristString = true; //是否顯示首頁(yè)
    this.LastBarFormat = ""; //尾頁(yè)顯示文本格式
    this.IsShowLastString = true; //是否顯示尾頁(yè)
    this.CurrentRecordBarFormat = "當(dāng)前記錄{0}-{1}"; //當(dāng)前記錄顯示文本格式
    this.IsShowCurrentRecordString = true; //是否顯示當(dāng)前記錄
    this.CurrentPageBarFormat = "當(dāng)前第" + this.ReplaceString + "頁(yè),共" + (this.PageCount == 0 ? 1 : this.PageCount) + "頁(yè)"; //當(dāng)前頁(yè)文字說(shuō)明文本格式
    this.IsShowCurrentPageString = true; //是否顯示當(dāng)前頁(yè)文字說(shuō)明文本
    this.OtherBarFormat = ""; //其他也顯示文本
    this.IsShowOtherString = true; //是否顯示其它頁(yè)文本
    var regexp = new RegExp(this.ReplaceString, "g"); //替換頁(yè)數(shù)文本正則表達(dá)式
    function GetFristPageString() {//獲取首頁(yè)文本
        if (PagerBar.FristBarFormat != "" && PagerBar.PageIndex != 1) {
            return PagerBar.FristBarFormat.replace(regexp, 1);
        }
        else {
            return "";
        }
    }
    function GetPreviouPageString() { //獲取上一頁(yè)文本
        if (PagerBar.PreviouBarFormat != "") {
            if (PagerBar.RecordCount > PagerBar.PageSize && PagerBar.PageIndex != 1) {//上一頁(yè)HTML輸出
                return PagerBar.PreviouBarFormat.replace(regexp, PagerBar.PageIndex - 1);
            }
            else {
                return "";
            }
        }
        else {
            return "";
        }
    }
    function GetPageString() {//獲取中間頁(yè)數(shù)鏈接
        var pagestr = "";
        if (PagerBar.CurrentBarFormat != "" && PagerBar.PageBarFormat != "") {
            var ShowPageFirest = PagerBar.PageIndex - parseInt(PagerBar.ShowPagesCount / 2 + 1) < 0 ? 0 : PagerBar.PageIndex - parseInt(PagerBar.ShowPagesCount / 2 + 1); //計(jì)算顯示頁(yè)數(shù)的其實(shí)頁(yè)數(shù)
            if (PagerBar.PageCount < PagerBar.ShowPagesCount) {//當(dāng)也總數(shù)小于顯示頁(yè)數(shù)量
                ShowPageFirest = 0;
            }
            else {
                if (PagerBar.PageIndex > (PagerBar.PageCount - parseInt(PagerBar.ShowPagesCount / 2 + 1))) {//當(dāng)頁(yè)總數(shù)在后幾頁(yè)顯示
                    ShowPageFirest = PagerBar.PageCount - PagerBar.ShowPagesCount;
                }
            }
            for (var i = ShowPageFirest; i < ShowPageFirest + PagerBar.ShowPagesCount; i++) {//循環(huán)出書(shū)頁(yè)數(shù)文本
                if (PagerBar.PageIndex == i + 1) {
                    pagestr += PagerBar.CurrentBarFormat.replace(regexp, i + 1);
                }
                else {
                    pagestr += PagerBar.PageBarFormat.replace(regexp, i + 1);
                }
                if (i >= PagerBar.PageCount - 1) {//當(dāng)?shù)竭_(dá)頁(yè)總數(shù)的時(shí)候挑出循環(huán)
                    break;
                }
            }
        }
        return pagestr;
    }
    function GetNextPageString() {//獲取下一頁(yè)鏈接
        if (PagerBar.NextBarFormat != "") {
            if (PagerBar.RecordCount > PagerBar.PageSize && PagerBar.PageIndex != PagerBar.PageCount) {//輸出下一頁(yè)HTMl
                return PagerBar.NextBarFormat.replace(regexp, PagerBar.PageIndex + 1);
            }
            else {
                return "";
            }
        }
        else {
            return "";
        }
    }
    function GetLastPageString() {//獲取尾頁(yè)鏈接
        if (PagerBar.LastBarFormat != "" && PagerBar.PageIndex != PagerBar.PageCount && PagerBar.RecordCount != 0) {
            return PagerBar.LastBarFormat.replace(regexp, PagerBar.PageCount);
        }
        else {
            return "";
        }
    }

    function GetFrontOtherPageString() {//獲取前其它頁(yè)鏈接
        if (PagerBar.OtherBarFormat != "") {
            if (PagerBar.PageIndex > PagerBar.ShowPagesCount / 2 + 1) {
                return PagerBar.OtherBarFormat.replace(regexp, PagerBar.PageIndex - PagerBar.ShowPagesCount <= 0 ? 1 : PagerBar.PageIndex - PagerBar.ShowPagesCount)
            }
            else {
                return "";
            }
        }
        else {
            return "";
        }
    }
    function GetAfterOtherPageString() {//獲取后其它頁(yè)鏈接
        if (PagerBar.OtherBarFormat != "") {
            if (PagerBar.PageIndex <= PagerBar.PageCount - PagerBar.ShowPagesCount / 2) {
                return PagerBar.OtherBarFormat.replace(regexp,
                PagerBar.PageIndex + PagerBar.ShowPagesCount >= PagerBar.PageCount ? PagerBar.PageCount : PagerBar.PageIndex + PagerBar.ShowPagesCount);
            }
            else {
                return "";
            }
        }
        else {
            return "";
        }
    }
    function GetCurrentRecordPageString() {//獲取當(dāng)前記錄文本
        if (PagerBar.CurrentRecordBarFormat != "") {
            if (PagerBar.RecordCount == 0) {
                return "";
            }
            else {
                return PagerBar.CurrentRecordBarFormat.replace("{0}", (PagerBar.PageIndex - 1) * PagerBar.PageSize + 1).replace("{1}", PagerBar.PageIndex * PagerBar.PageSize > PagerBar.RecordCount ? PagerBar.RecordCount : PagerBar.PageIndex * PagerBar.PageSize);
            }
        }
        else return "";
    }
    function GetCurrentPageBarString() {//獲取當(dāng)前頁(yè)記錄文本
        if (PagerBar.CurrentPageBarFormat != "") {
            return PagerBar.CurrentPageBarFormat.replace(regexp, PagerBar.PageIndex);
        }
        else return "";
    }
    this.GetString = function (pageindex) {//輸出HTML代碼(全部模式)
        if (pageindex != null && NumberRegex.test(pageindex)) {//如果傳入了頁(yè)索引則賦值
            this.PageIndex = parseInt(pageindex);
        }
        if (this.PageCount == 0) {//如果沒(méi)有計(jì)算過(guò)頁(yè)總數(shù),則計(jì)算頁(yè)總數(shù)
            CalculatePageCount(this.PageSize, this.RecordCount);
        }
        var pagestr = "";
        if (this.IsShowCurrentPageString) {
            pagestr = GetCurrentPageBarString();
        }
        if (this.IsShowCurrentRecordString) {
            pagestr += GetCurrentRecordPageString();
        }
        if (this.IsShowFristString) {
            pagestr += GetFristPageString();
        }
        if (this.IsShowPreviouString) {
            pagestr += GetPreviouPageString();
        }
        if (this.IsShowOtherString) {
            pagestr += GetFrontOtherPageString();
        }
        if (this.IsShowPageString) {
            pagestr += GetPageString();
        }
        if (this.IsShowOtherString) {
            pagestr += GetAfterOtherPageString();
        }
        if (this.IsShowNextString) {
            pagestr += GetNextPageString();
        }
        if (this.IsShowLastString) {
            pagestr += GetLastPageString();
        }
        return pagestr;
    }
    this.GetNormalString = function (pageindex) {
        if (pageindex != null && NumberRegex.test(pageindex)) {//如果傳入了頁(yè)索引則賦值
            this.PageIndex = parseInt(pageindex);
        }
        if (this.PageCount == 0) {//如果沒(méi)有計(jì)算過(guò)頁(yè)總數(shù),則計(jì)算頁(yè)總數(shù)
            CalculatePageCount(this.PageSize, this.RecordCount);
        }
        var pagestr = "";
        pagestr += GetFristPageString();
        pagestr += GetPreviouPageString();
        pagestr += GetPageString();
        pagestr += GetNextPageString();
        pagestr += GetLastPageString();
        return pagestr;
    }
    this.GetSimpleString = function (pageindex) {
        if (pageindex != null && NumberRegex.test(pageindex)) {//如果傳入了頁(yè)索引則賦值
            this.PageIndex = parseInt(pageindex);
        }
        if (this.PageCount == 0) {//如果沒(méi)有計(jì)算過(guò)頁(yè)總數(shù),則計(jì)算頁(yè)總數(shù)
            CalculatePageCount(this.PageSize, this.RecordCount);
        }
        var pagestr = "";
        pagestr += GetPreviouPageString();
        pagestr += GetCurrentPageBarString();
        pagestr += GetNextPageString();
        return pagestr;
    }
}

使用示例:

暫無(wú)

內(nèi)容中需要的知識(shí)點(diǎn)
分頁(yè)符《#PageLink》

相關(guān)文章

  • JS遍歷JSON數(shù)組及獲取JSON數(shù)組長(zhǎng)度操作示例【測(cè)試可用】

    JS遍歷JSON數(shù)組及獲取JSON數(shù)組長(zhǎng)度操作示例【測(cè)試可用】

    這篇文章主要介紹了JS遍歷JSON數(shù)組及獲取JSON數(shù)組長(zhǎng)度操作,涉及javascript簡(jiǎn)單json數(shù)組遍歷與運(yùn)算相關(guān)操作技巧,需要的朋友可以參考下
    2018-12-12
  • Bootstrap 模態(tài)框(Modal)帶參數(shù)傳值實(shí)例

    Bootstrap 模態(tài)框(Modal)帶參數(shù)傳值實(shí)例

    模態(tài)框(Modal)是覆蓋在父窗體上的子窗體。下面通過(guò)本文給大家介紹Bootstrap 模態(tài)框(Modal)帶參數(shù)傳值實(shí)例代碼,需要的朋友參考下吧
    2017-08-08
  • 光標(biāo)的一些操作總結(jié)

    光標(biāo)的一些操作總結(jié)

    IE下的Range操作比Mozilla下強(qiáng)很多,這里只討論IE下的操作,這里選介紹幾個(gè)光標(biāo)定位的特點(diǎn)
    2006-10-10
  • 微信小程序 多行文本顯示...+顯示更多按鈕和收起更多按鈕功能

    微信小程序 多行文本顯示...+顯示更多按鈕和收起更多按鈕功能

    這篇文章主要介紹了微信小程序多行文本顯示...+顯示更多按鈕和收起更多按鈕,代碼簡(jiǎn)單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-09-09
  • js對(duì)字符的驗(yàn)證方法匯總

    js對(duì)字符的驗(yàn)證方法匯總

    這篇文章主要介紹了js對(duì)字符的驗(yàn)證方法,實(shí)例匯總了漢字驗(yàn)證、手機(jī)驗(yàn)證、郵箱驗(yàn)證、身份證號(hào)驗(yàn)證等各種常用技巧,需要的朋友可以參考下
    2015-02-02
  • 一文帶你理解JS中的原型和原型鏈

    一文帶你理解JS中的原型和原型鏈

    在學(xué)習(xí)JavaScript中的繼承機(jī)制時(shí),我們常常會(huì)遇到原型和原型鏈這兩個(gè)概念,在初學(xué)階段,不理解這些概念很容易陷入迷茫,甚至?xí)?dǎo)致學(xué)習(xí) JS 的路程變得曲折,本文將介紹JavaScript原型和原型鏈的概念、設(shè)計(jì)思想以及相關(guān)的使用方法,需要的朋友可以參考下
    2023-07-07
  • 跨瀏覽器通用、可重用的選項(xiàng)卡tab切換js代碼

    跨瀏覽器通用、可重用的選項(xiàng)卡tab切換js代碼

    今天一同學(xué)對(duì)我說(shuō)“好吧,我準(zhǔn)備去學(xué)習(xí)”,我大驚,這老勾引我打dota的也去學(xué)習(xí),于是我好奇他學(xué)什么,他說(shuō)要搞一個(gè)選項(xiàng)卡切換js
    2011-09-09
  • 微信小程序授權(quán)登錄解決方案的代碼實(shí)例(含未通過(guò)授權(quán)解決方案)

    微信小程序授權(quán)登錄解決方案的代碼實(shí)例(含未通過(guò)授權(quán)解決方案)

    這篇文章主要介紹了微信小程序授權(quán)登錄解決方案,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-05-05
  • JavaScript 拾漏補(bǔ)遺

    JavaScript 拾漏補(bǔ)遺

    javascritp實(shí)際上由三部分組成: ECMAScript,DOM, BOM 前兩者由工業(yè)標(biāo)準(zhǔn),BOM尚比較混亂。
    2009-12-12
  • JavaScript仿支付寶密碼輸入框

    JavaScript仿支付寶密碼輸入框

    那么今天我就用JavaScript代碼來(lái)實(shí)現(xiàn)這個(gè)效果吧,那么首先介紹一下整個(gè)的思路,首先我們先將確定輸入密碼的位數(shù),我的需求是5位,那么就用一個(gè)div標(biāo)簽包住5個(gè)input標(biāo)簽
    2015-12-12

最新評(píng)論

白玉县| 孝昌县| 南通市| 中西区| 四子王旗| 渝中区| 丰顺县| 嫩江县| 类乌齐县| 鹤庆县| 固安县| 双柏县| 台北市| 顺义区| 利辛县| 安溪县| 杭锦后旗| 施甸县| 永顺县| 白城市| 衡阳县| 正定县| 博湖县| 田阳县| 通化市| 衡东县| 历史| 福泉市| 腾冲县| 噶尔县| 琼海市| 紫云| 金门县| 香格里拉县| 高安市| 成安县| 兴化市| 城固县| 桐梓县| 乌鲁木齐市| 罗田县|