﻿var GD = { Version: '1.0.0.0' };
GD.Page = Class.create({
    initialize: function() {
        this.type = 0;
        this.ListDate = null;
        this.FCurrentPage = 0;
        this.FPageLine = 40;
        this.divPaginationID = null;

        this.WebSiteId = null;
        this.NKid = null;
        this.queryString = null;
        this.linkurl = null;
        this.Action = null;
    },
    GetEleByClientID: function(divPagination, wid, nkid, querystring, url, action) {
        this.divPaginationID = divPagination;
        this.WebSiteId = wid == "" ? null : wid;
        this.NKid = nkid == "" ? null : nkid;
        this.queryString = querystring;
        this.Action = action;
        this.linkurl = url == "" ? "http://10.0.0.4:8053" : url;
    },
    LoadData: function() {
        if(this.queryString==""||this.queryString==null)
        {
            $('newslist').innerHTML = "<ul class=\"lists\"><li><h3>没有相关新闻信息！</h3></li></ul>";
            return false;
        }
        this.ListDate = RXSG.GameData.CurrNews.GetRelateNewsList(this.WebSiteId, this.NKid, this.queryString, this.FCurrentPage, this.FPageLine, this.Action).value;
        this.Formate();
    },
    Formate: function() {
        if (this.ListDate == null || this.ListDate.IsSuccess == false) {
            $('newslist').innerHTML = "<ul class=\"lists\"><li><h3>系统忙，请稍候重试！</h3></li></ul>";
        }
        else {
            var DataList = this.ListDate.DataList;
            if (DataList == null || DataList.length == 0) {
                $('newslist').innerHTML = "<ul class=\"lists\"><li><h3>没有相关新闻信息！</h3></li></ul>";
            }
            else {
                var i = 0;
                var j = 0;
                var row = DataList[i];
                var html = "<ul class=\"lists\">";
                while (row != null) {
                    html += "<li><h3><a href=\"" + this.linkurl + row[3] + "\" target=\"_blank\" title=\"" + row[0] + "\">" + row[4] + "</a></h3>" + row[1] + "</li>";
                    i++;
                    j++;
                    row = DataList[i];
                    if (j == 5) {
                        html += "</ul><ul class=\"lists\">";
                        j = 0;
                    }
                }
                html += "</ul>";
                $('newslist').innerHTML = html;
            }
            var FSumCount = this.ListDate.Tag;
            var FCurrentPageLine = i;
            var FPageCount = Math.ceil(FSumCount / this.FPageLine);
            var pagingation = new Pagination("Pagination1", FPageCount, this.FCurrentPage, FSumCount, FCurrentPageLine, "page.PageChange", this.divPaginationID, 1)
        }
    },
    //分页调整
    PageChange: function(pNum) {
        this.FCurrentPage = parseInt(pNum);
        this.LoadData();
    }
})
//构造一个函数
function MergFunctionName() {
    var result = arguments[0] + "(", a = arguments;
    if (a.length > 1) {
        for (i = 1; i < a.length; i++) {
            result += "\'" + arguments[i] + "\'";
            if (i != (a.length - 1))
                result += ",";
        }
    }
    result += ")";
    return result;
}
