var cache = { }; $(document).ready(function() { cache["loadimg"] = $("").attr("src", "http://image.eduhouse.net/2009_iae/image/loadinfo_s.gif"); jQuery.historyInit(actionHandler); $("a[rel='history_event']").live("click", function() { $("#event_list_cont").empty().append(cache["loadimg"]); dvf_historyHandler(this.href); return false; }); $("#passed_evt_prev, #passed_evt_next").click(function() { var nwPageNo = parseInt($("#passed_page_no").val(), 10); if (this.id == "passed_evt_prev") { if (1 < nwPageNo) { nwPageNo--; } else { alert("첫 페이지입니다."); return; } } else { if (nwPageNo < parseInt($("#passed_page_cnt").val(),10)) { nwPageNo++; } else { alert("마지막 페이지입니다."); return; } } $("#sidebar_b > div.event_cont").empty().append(cache["loadimg"]); $("#passed_page_no").val(nwPageNo); read_br_event("4", nwPageNo, $("#passed_page_size").val(), "pass"); }); }); function actionHandler(p_hash) { var arrToken; if(p_hash) { arrToken = p_hash.split("_"); } else { arrToken = $("#init_param").val().split("_"); } if (0 < arrToken.length) { switch(arrToken[0]) { case "PAGE": $("#page_no").val(arrToken[1]); read_br_event("4", arrToken[1], $("#page_size").val(), "ing"); break; } } } // 지사 이벤트 읽어오기 function read_br_event(p_zoneID, p_pageNo, p_pageSize, p_targetGb) { var param = {zone_id: p_zoneID, cont_target: p_targetGb, page_no: p_pageNo, page_size: p_pageSize}; $.ajax({ url: "/service/common/svc_banner_event_read.asp", type: 'POST', data: param, dataType: 'json', async: true, //timeout: 3000, error: function(p_req, p_status, p_err) { //alert('ERR1'); alert("지사 이벤트를 읽는 중 오류가 발생하였습니다. 잠시 후 이용바랍니다."); }, success: function(p_data) { if ("pass" == p_targetGb) { dispPassedEventList(p_data); } else { dispIngEventList(p_data); } } }); } function dispIngEventList(p_data) { var brEventList = $("#event_list_cont").empty(); if (p_data.bannerCnt <= 0) { brEventList.append("

진행중인 이벤트가 없습니다.

"); } else { var pageNo = $("#page_no").val(); var pageSize = $("#page_size").val(); var passedPageNo = $("#passed_page_no").val(); var passedPageSize = $("#passed_page_size").val(); for (var idx = 0; idx < p_data.bannerList.length; idx++) { var datarec = p_data.bannerList[idx]; var RedirURL = "/event/iae_br_event_view.asp?zone_id="+datarec.ZoneID+"&banner_id="+datarec.bannerID+"&page_no="+pageNo+"&page_size="+pageSize; var lnkUrl = ""; if (datarec.typeID == "2") { if (datarec.isHtml == "Y") { lnkUrl = unescape(datarec.contents); } else { lnkUrl = "javascript:click_winBanner('"+ datarec.ZoneID +"', '" + datarec.bannerID + "', '" + RedirURL + "', '" + datarec.state + "');"; } } else { if (datarec.isHtml == "Y") { lnkUrl = "javascript:click_innerBanner('"+ datarec.ZoneID +"', '" + datarec.bannerID + "', '" + RedirURL + "', '" + datarec.state + "');"; } else { if (datarec.redirURL != "" ) lnkUrl = "javascript:click_innerBanner('"+ datarec.ZoneID +"', '" + datarec.bannerID + "', '" + RedirURL + "', '" + datarec.state + "');\""; else lnkUrl = ""; } } var frDate = datarec.frDate.replace(/[^0-9]/, "."); var toDate = datarec.toDate.replace(/[^0-9]/, "."); brEventList.append("
  • " + "
    \"\"
    " + "
    " + "
    " + "" + "" + unescape(datarec.title) + "
    " + "
    이벤트 : " + unescape(datarec.title) + "
    " + "
    이벤트 기간 : " + frDate + " - " + toDate + "
    " + "
    이벤트 문의 : event@eduhouse.net
    " + "
    이벤트 내용 : " + unescape(datarec.altText) + "
    " + "
    " + "
    \"이벤트
    " + "
  • "); } // paging 다시 그리기 viewPaging(parseInt($("#page_no").val(),10), parseInt($("#page_size").val(),10), p_data.bannerCnt, parseInt($("#view_paging_no").val(),10), "div.page_index"); } } function viewPaging(p_pageNo, p_pageSize, p_dataCnt, p_viewPagingNo, p_containerSelector) { var totPageCnt = Math.floor((p_dataCnt - 1) / p_pageSize) + 1; var stPageno = p_pageNo - ((p_pageNo - 1) % p_viewPagingNo); var endPageno = stPageno + p_viewPagingNo - 1; if (endPageno > totPageCnt) endPageno = totPageCnt; //trace("stPageno:" + stPageno + ", endPageno:" + endPageno + ", totPage:" + totPageCnt + ", viewPaing:" + p_viewPagingNo); var natCd = $("#natCd").val(); var term = $("#term").val(); var pagingTxt = 1 < p_pageNo ? " " : " "; pagingTxt += p_viewPagingNo < stPageno ? " " : " "; for (var idx = stPageno; idx <= endPageno; idx++) { pagingTxt += p_pageNo != idx ? " " + idx + " " : " " + idx + " "; } pagingTxt += totPageCnt > endPageno ? " " : " "; pagingTxt += totPageCnt > p_pageNo ? " " : " "; $("#pagingNav").html(pagingTxt); } function dispPassedEventList(p_data) { var brEventList = $("#sidebar_b > div.event_cont").empty(); if (p_data.bannerCnt <= 0) { brEventList.append("

    지난 이벤트가 없습니다.

    "); } else { var pageNo = $("#page_no").val(); var pageSize = $("#page_size").val(); var passedPageNo = $("#passed_page_no").val(); var passedPageSize = $("#passed_page_size").val(); var fstClass = " class=\"first\""; for (var idx = 0; idx < p_data.bannerList.length; idx++) { var datarec = p_data.bannerList[idx]; var lnkUrl = ""; if (datarec.typeID == "2") { if (datarec.isHtml == "Y") { lnkUrl = unescape(datarec.contents); } else { lnkUrl = "javascript:click_winBanner('"+ datarec.ZoneID +"', '" + datarec.bannerID + "', '" + datarec.redirURL + "', '" + datarec.state + "');"; } } else { if (datarec.isHtml == "Y") { lnkUrl = "javascript:click_winBanner('"+ datarec.ZoneID +"', '" + datarec.bannerID + "', '" + datarec.redirURL + "', '" + datarec.state + "');"; } else { if (datarec.redirURL != "" ) lnkUrl = "javascript:click_innerBanner('"+ datarec.ZoneID +"', '" + datarec.bannerID + "', '" + datarec.redirURL + "', '" + datarec.state + "');\""; else lnkUrl = ""; } } var frDate = datarec.frDate.replace(/[^0-9]/, "."); var toDate = datarec.toDate.replace(/[^0-9]/, "."); brEventList.append( "" + "
    " + unescape(datarec.title) + "
    " + "
    \"\"
    " + "
    이벤트 기간 :
    " + frDate + " ~ " + toDate + "
    " + "
    이벤트 자세히 보기
    " + ""); fstClass = ""; } $("#passed_evt_page").text($("#passed_page_no").val() + "/" + $("#passed_page_cnt").val()); } } // 이벤트 상세 보기 type별 Link 함수: Popup open function click_winBanner(p_zoneID, p_bannerID, p_url, state) { if (state =="end"){ alert("종료된 이벤트입니다.") read_br_event("4", $("#passed_page_no").val(), $("#passed_page_size").val(), "pass"); } else{ //alert("p_url=" + p_url); if( p_url != "") window.open(p_url); } } // 이벤트 상세 보기 type별 Link 함수: 현재 페이지 이동 function click_innerBanner(p_zoneID, p_bannerID, p_url, state) { if (state =="end"){ alert("종료된 이벤트입니다.") read_br_event("4", $("#passed_page_no").val(), $("#passed_page_size").val(), "pass"); } else{ //alert("p_url=" + p_url); if( p_url != "") location.href = p_url; } }