﻿function getYXGLList(typeID, pageSize, notictype) {
    var strCon = "";
    jQuery.getJSON("http://game.huanlang.com/handlers/getGameNoticeListHandler.ashx?gameID=" + typeID + "&pageSize=" + pageSize + "&noticeType=" + notictype + "&pageindex=1" + "&jsoncallback=?", function(data) {
        jQuery.each(data.Items, function(i, item) {
            strCon += "<li><a href='news.aspx?id=" + item["id"] + "' target='_blank'>" + item["title"] + "</a> </li>";
        });
        jQuery("#yxgl").html(strCon);
    });
}

    function parseDate(str) {
        if (typeof str == 'string') {
            var results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) *$/);
            if (results && results.length > 3)
                return new Date(parseInt(results[1]), parseInt(results[2]) - 1, parseInt(results[3]));
            results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2}) *$/);
            if (results && results.length > 6)
                return new Date(parseInt(results[1]), parseInt(results[2]) - 1, parseInt(results[3]), parseInt(results[4]), parseInt(results[5]), parseInt(results[6]));
            results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2})\.(\d{1,9}) *$/);
            if (results && results.length > 7)
                return new Date(parseInt(results[1]), parseInt(results[2]) - 1, parseInt(results[3]), parseInt(results[4]), parseInt(results[5]), parseInt(results[6]), parseInt(results[7]));
        }
        return null;
    }

    Date.prototype.format = function(format) {
        var o = {
            "M+": this.getMonth() + 1, //month
            "d+": this.getDate(),    //day
            "h+": this.getHours(),   //hour
            "m+": this.getMinutes(), //minute
            "s+": this.getSeconds(), //second
            "q+": Math.floor((this.getMonth() + 3) / 3),  //quarter
            "S": this.getMilliseconds() //millisecond
        }
        if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
    (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o) if (new RegExp("(" + k + ")").test(format))
            format = format.replace(RegExp.$1,
      RegExp.$1.length == 1 ? o[k] :
        ("00" + o[k]).substr(("" + o[k]).length));
        return format;
    }
    
    function getNoticeListmeiti(typeID,pageSize,notictype,obj){
	var strCon="";
    jQuery.getJSON("http://game.huanlang.com/handlers/getGameNoticeListHandler.ashx?gameID="+typeID+"&pageSize="+pageSize+"&noticeType="+notictype+"&pageindex=1"+"&jsoncallback=?",function(data){
			jQuery.each(data.Items, function(i,item){
				strCon += "<li><span>[" + parseDate(item["addtime"]).format("yy/MM/dd") + "]</span><span class=\"dian\">·</span><a href='news.aspx?id=" + item["id"] + "' target=_blank>" + item["title"] + "</a></li>";
			});

			jQuery(obj).html(strCon)
        });
}
