// ¼­ºêÆäÀÌÁö - Ƽ½ºÅ丮 ¿¬µ¿ JS ///default/inc/customJs/tistoryBlogSub.js console.log("BLOG_SUB_JS"); function dispTistoryBlogSubList(currPage, pageSize){ console.log("dispTistoryBlogSubList") var accessCode = "29602304188fe2defc283ea75e61aea6_53c613ef24847cdcbf88d7470422deb2"; var address = "https://www.tistory.com/apis/post/list?access_token=" + accessCode + "&targetUrl=weandstory&page=" + currPage + "&count=" + pageSize; var http = jQuery.ajax( { url : address, type : "GET", async : false, cache : false, error : function(xml){ //alert('ERROR....'); }, success:function(xml){ var status = jQuery(xml).find('tistory > status').text(); var url = jQuery(xml).find('tistory > item > url').text(); var page = jQuery(xml).find('tistory > item > page').text(); var count = jQuery(xml).find('tistory > item > count').text(); var totalCount = jQuery(xml).find('tistory > item > totalCount').text(); var error_message = jQuery(xml).find('tistory > error_message').text(); var sHTML = ""; sHTML += ""; sHTML += " "; if ("200" == status) { if ( jQuery(xml).find('tistory').length > 0 ) { jQuery(xml).find('tistory > item > posts > post').each( function(idx){ var id = jQuery(xml).find('tistory > item > posts > post:eq('+idx+') > id').text(); var title = jQuery(xml).find('tistory > item > posts > post:eq('+idx+') > title').text(); var postUrl = jQuery(xml).find('tistory > item > posts > post:eq('+idx+') > postUrl').text(); var visibility = jQuery(xml).find('tistory > item > posts > post:eq('+idx+') > visibility').text(); var categoryId = jQuery(xml).find('tistory > item > posts > post:eq('+idx+') > categoryId').text(); var comments = jQuery(xml).find('tistory > item > posts > post:eq('+idx+') > comments').text(); var trackbacks = jQuery(xml).find('tistory > item > posts > post:eq('+idx+') > trackbacks').text(); var date = jQuery(xml).find('tistory > item > posts > post:eq('+idx+') > date').text(); date = date.substring(0,10); var tempTitle = "" try{ tempTitle = cutByLen(title, 45); }catch(e){ tempTitle = title; } sHTML += " "; sHTML += " "; sHTML += " "; sHTML += " "; sHTML += " "; }); } } sHTML += " "; sHTML += "
" + id + ""; sHTML += " " + title+ ""; sHTML += " " + date + "
"; jQuery('#divBlog').html(sHTML); makePageNaviC2(currPage, totalCount, pageSize); } }); } function cutByLen(str, maxByte) { var bFlag = false; for(b=i=0;c=str.charCodeAt(i);) { b+=c>>7?2:1; if (b > maxByte){ bFlag = true; break; } i++; } if(bFlag == true){ return str.substring(0,i) + "..."; }else{ return str.substring(0,i); } } function makePageNaviC2(curr_Page, totalCnt, maxRowSize){ var maxNaviSize = 5; var naviCnt = 0; var toatalPageCount = Math.ceil(totalCnt/maxRowSize); var currPage = curr_Page; if(toatalPageCount==0) toatalPageCount = 1; var trRowCount = 1; var startNum = 0; var endNum = 0; var startPageNum = Math.floor(curr_Page/(maxNaviSize+0.1))*maxNaviSize+1; var appendTemp = ''; if ( currPage < 1 ) currPage = 1; var endPage = parseInt(currPage) + 1; if (endPage > toatalPageCount) { endPage = toatalPageCount; } if(curr_Page > maxNaviSize){ //appendTemp += ' '; appendTemp += ' <<'; } for(i=startPageNum; i<=startPageNum+(maxNaviSize-1); i++){ if(i <= toatalPageCount){ if(i != currPage){ appendTemp += '' + i + ''; }else{ appendTemp += '' + i + '' ; } } naviCnt++; } if(naviCnt >= maxNaviSize && (startPageNum+maxNaviSize) <= toatalPageCount){ appendTemp += '>> '; // appendTemp += ' '; } jQuery('#ta_pageNavi').empty(); jQuery('#ta_pageNavi').append(appendTemp); } function gotoPage(currPage){ dispTistoryBlogSubList(currPage, 10); } jQuery(document).ready(function(){ dispTistoryBlogSubList(1, 10); });