(function($) {
$.fn.table = async function(options) {
};
$.fn.table.lineSelect = function() {
return ``
}
$.fn.table.orderBySelect = function() {
return `
`
}
$.fn.table.makePagination = function(limit, total, page = 1) {
let overFlow = false
const totalPage = Math.ceil( total / limit ),
pageGroup = Math.ceil( page / 5 ),
last_ = pageGroup * 5,
first = last_ - 4
last = (overFlow = last_ > totalPage) ? totalPage : last_,
links = `%datas%`;
let next = last + 1,
prev = first - 1,
html = '';
if (page <= 5) {
html += `
«
‹
`
} else {
html += links.co_split({active: '', offset: 0, page: 1, datas: `«`});
html += links.co_split({active: '', offset: (prev - 1) * limit, page: prev, datas: `‹`});
}
for (let i = first; i <= last; i++) {
if ( i >= 1 && i <= totalPage ) {
const active = (page === i) ? ` active ` : ``,
offset = (i - 1) * limit;
html += links.co_split({active: active, offset: offset, page: i, datas: i});
}
}
if (! overFlow && ! (first + 5 > totalPage)) {
html += links.co_split({active: '', offset: (next - 1) * limit, page: next, datas: `›`});
html += links.co_split({active: '', offset: (totalPage - 1) * limit, page: totalPage, datas: `»`});
} else {
html += `
›
»
`
}
return html
};
}(jQuery));