var cache = { }; $(document).ready(function() { cache["loadimg"] = $("").attr("src", "http://image.eduhouse.net/2009_iae/image/loadinfo_s.gif"); cache["loadimg2"] = $("").attr("src", "http://image.eduhouse.net/2009_iae/image/loadinfo_s.gif"); jQuery.historyInit(actionHandler); $("a[rel='history_news']").live("click", function() { $("#list_wrap").empty().append(cache["loadimg"]); dvf_historyHandler(this.href); return false; }); changeContry2(document.getElementById("natCd").value); }); function changeContry2(_arg){ $(".news_internal").children("li").each(function() { $(this).children("a").attr("class",""); }); $("#camp_news_"+_arg).attr("class","on"); } function changeContry(_arg){ $(".news_internal").children("li").each(function() { $(this).children("a").attr("class",""); }); $("#camp_news_"+_arg).attr("class","on"); $("#list_wrap").empty().append(cache["loadimg"]); $("#page_no").val(1); $("#natCd").val(_arg); read_news_list(); } function actionHandler(p_hash) { // hash doesn't contain the first # character. //trace("hash=" + p_hash); var arrHashToken; if(p_hash) { arrHashToken = p_hash.split("_"); if (arrHashToken.length > 0) { $("#natCd").val(arrHashToken[0]); var natIdEnd = arrHashToken[0]; if (arrHashToken.length > 1) $("#page_no").val(arrHashToken[1]); read_news_list(); } } } function read_news_list() { var param = {natCd: $("#natCd").val(), page_no: $("#page_no").val(), page_size: $("#page_size").val(), NewsCode: $("#NewsCode").val()}; $.ajax({ url: "/service/study_info/svc_earlynews_list.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) { var newsList = $("#list_wrap"); newsList.empty(); if (p_data.totalCnt <= 0) { newsList.append("등록된 학교뉴스가 없습니다."); } else { if (p_data.dataList != undefined && p_data.dataList.length > 0){ for (var idx = 0; idx < p_data.dataList.length; idx++) { var datarec = p_data.dataList[idx]; newsList.append("
"+ "
"+ ""+ "
"+ "
"+ "
" + unescape(datarec.newstitle) +"
"+ "
" + unescape(datarec.newssummary) + "
"+ ""+ "
"+ "
"); } }else{ newsList.append("등록된 학교뉴스가 없습니다."); } } // paging 다시 그리기 viewPaging(parseInt($("#page_no").val(),10), parseInt($("#page_size").val(),10), p_data.totalCnt, 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; //alert("stPageno:" + stPageno + ", endPageno:" + endPageno + ", totPage:" + totPageCnt + ", viewPaing:" + p_viewPagingNo); var natCd = $("#natCd").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); }