(function (window) { function myPaginationArray(totalPage, currentPage) { var myPage = []; if (totalPage < 10) { for (var i = 0; i < totalPage; i++) { var page = { pagination: i + 1, currentPage: currentPage }; myPage.push(page); } } else { if (currentPage > 5) { if (currentPage + 5 >= totalPage) { for (var i = currentPage - 5 + 1; i <= totalPage; i++) { var page = { pagination: i, currentPage: currentPage }; myPage.push(page); } } else { for (var i = currentPage - 5 + 1; i <= currentPage + 5; i++) { var page = { pagination: i, currentPage: currentPage }; myPage.push(page); } } } else { for (var i = 0; i < 10; i++) { var page = { pagination: i + 1, currentPage: currentPage }; myPage.push(page); } } } return myPage; } var listPager = { fullPagination: function (option) { option = $.extend({ totalPage: 0, page: 0, pageContent: '' }, option); var pageFooter = { total: option.totalPage, prev: option.page - 1, next: option.page + 1, page: option.page }; if (option.page == option.total) { pageFooter.next = option.total; } if (option.page == 1) { pageFooter.prev = 1; } pageFooter.list = myPaginationArray(option.totalPage, option.page); if (option.pageContent) { $("#list_page_footer").tmpl(pageFooter).appendTo(option.pageContent); } } } window.listPager = listPager; })(window)