﻿var preUrl = '../../Common/Bbs/Bbs.asmx';



$(document).ready(function () {

    
    var result, list;
    $.ajax({
        url: preUrl + "/GetSimpleList"
        , data: "{ pBbsId: 'notic', pTopCount: '6', pAddColumns: ', convert(char(10), reg_date,102) reg_date'}"
        , success: function (data) {
            eval("result = " + data.d);
            list = result.List;
            var text = tDate = img = "";
            var regDate, endDate;
            var toDate = new Date();

            var format =
                   "<tr>\r\n"
                + "    <td class='nTd1' >\r\n"
                + "         <img src='../Img/Common/bullet_dot_11.gif' style='padding-right:3px;' /> <a href='../30Bbs/Aboard.aspx?id=notic&no={0}'>{1}</a> {2}</td>"
                + "</tr>";

            $.each(list, function (index, obj) {
                tDate = obj.reg_date.split(".");
                regDate = new Date(tDate[0], tDate[1] - 1, tDate[2]);

                img = '';
                if (calculateDays(regDate, toDate) < 10)
                    img = "<img src='../Img/Common/bullet_new.gif' >";

                text += String.format(format, obj.no, whiteSpace(30, obj.subject), img);
            }); 

            $('#tbdNotice').html(text);
        }
    });

//    $.ajax({
//        url: preUrl + "/GetSimpleList"
//        , data: "{ pBbsId: 'SM_edu', pTopCount: '5', pAddColumns: ', convert(char(10), reg_date,102) reg_date'}"
//        , success: function (data) {
//            eval("result = " + data.d);
//            list = result.List;
//            var text = tDate = img = "";
//            var regDate, endDate;
//            var toDate = new Date();

//            var format = "<li><a href='../31BbsLecture/Lview.aspx?id=SM_edu&no={0}'>[{1} 강의] {2}</a>{3}</li>\r\n";

//            $.each(list, function (index, obj) {
//                tDate = obj.reg_date.split(".");
//                regDate = new Date(tDate[0], tDate[1] - 1, tDate[2]);

//                img = '';
//                if (calculateDays(regDate, toDate) < 30)
//                    img = "<img src='../Img/Common/bullet_new.gif' >";

//                text += String.format(format, obj.no, obj.reg_date, whiteSpace(25, obj.subject), img);
//            }); 

//            $('#ulSmLecture').html(text);
//        }
//    });


});       


////시간계산 메인에서 사용
//function calculateDays(sDate, eDate) {
//    try {
//        if (eDate == null)
//            eDate = new Date();
//        // 1 day in milliseconds
//        var oneDay = (1000 * 60 * 60 * 24);
//        return Math.ceil((eDate - sDate) / oneDay);
//    }
//    catch (e) {
//        return 0;
//    }
//}

////특정수 이상의 글자일 경우 뒤에 ...을 붙임
//function whiteSpace(pLength, pSubject) {
//    if (pSubject.length > eval(pLength))
//        pSubject = pSubject.substr(0, 28) + '...';

//    return pSubject.fixed();
//}
