|
|
|
@ -57,39 +57,48 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function prevClick(tbl) {
|
|
|
|
|
const page = tbl.getAttribute('data-page') * 1
|
|
|
|
|
tbl.setAttribute('data-page', page - 1)
|
|
|
|
|
toggleVisibilities(tbl, visibleRows(page - 1))
|
|
|
|
|
function prevButton(tbl) {
|
|
|
|
|
const btn = document.createElement('button')
|
|
|
|
|
btn.classList.add('prev')
|
|
|
|
|
btn.innerText = 'Prev'
|
|
|
|
|
btn.addEventListener('click', function () {
|
|
|
|
|
const page = tbl.getAttribute('data-page') * 1
|
|
|
|
|
if (page > 0) {
|
|
|
|
|
tbl.setAttribute('data-page', page - 1)
|
|
|
|
|
toggleVisibilities(tbl, visibleRows(page - 1))
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
return btn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function nextClick(tbl) {
|
|
|
|
|
const page = tbl.getAttribute('data-page') * 1
|
|
|
|
|
tbl.setAttribute('data-page', page + 1)
|
|
|
|
|
toggleVisibilities(tbl, visibleRows(page + 1))
|
|
|
|
|
function nextButton(tbl) {
|
|
|
|
|
const btn = document.createElement('button')
|
|
|
|
|
btn.classList.add('next')
|
|
|
|
|
btn.innerText = 'Next'
|
|
|
|
|
btn.addEventListener('click', function () {
|
|
|
|
|
const page = tbl.getAttribute('data-page') * 1
|
|
|
|
|
const lastRowNum = (page + 1) * pageSize
|
|
|
|
|
if (lastRowNum < tbl.tBodies[0].rows.length) {
|
|
|
|
|
tbl.setAttribute('data-page', page + 1)
|
|
|
|
|
toggleVisibilities(tbl, visibleRows(page + 1))
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
return btn
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addToolbar(tbl) {
|
|
|
|
|
const toolbar = document.createElement('section')
|
|
|
|
|
toolbar.classList.add('tbl-toolbar')
|
|
|
|
|
|
|
|
|
|
const prevBtn = document.createElement('button')
|
|
|
|
|
prevBtn.classList.add('prev')
|
|
|
|
|
prevBtn.innerText = 'Prev'
|
|
|
|
|
prevBtn.addEventListener('click', function () {
|
|
|
|
|
prevClick(tbl)
|
|
|
|
|
})
|
|
|
|
|
toolbar.insertAdjacentElement('beforeend', prevBtn)
|
|
|
|
|
|
|
|
|
|
const nextBtn = document.createElement('button')
|
|
|
|
|
nextBtn.classList.add('next')
|
|
|
|
|
nextBtn.innerText = 'Next'
|
|
|
|
|
nextBtn.addEventListener('click', function () {
|
|
|
|
|
nextClick(tbl)
|
|
|
|
|
})
|
|
|
|
|
toolbar.insertAdjacentElement('beforeend', nextBtn)
|
|
|
|
|
|
|
|
|
|
tbl.insertAdjacentElement('afterend', toolbar)
|
|
|
|
|
const toolbarTop = document.createElement('section')
|
|
|
|
|
toolbarTop.classList.add('tbl-toolbar')
|
|
|
|
|
toolbarTop.insertAdjacentElement('beforeend', prevButton(tbl))
|
|
|
|
|
toolbarTop.insertAdjacentElement('beforeend', nextButton(tbl))
|
|
|
|
|
|
|
|
|
|
const toolbarBottom = document.createElement('section')
|
|
|
|
|
toolbarBottom.classList.add('tbl-toolbar')
|
|
|
|
|
toolbarBottom.insertAdjacentElement('beforeend', prevButton(tbl))
|
|
|
|
|
toolbarBottom.insertAdjacentElement('beforeend', nextButton(tbl))
|
|
|
|
|
|
|
|
|
|
tbl.insertAdjacentElement('afterend', toolbarTop)
|
|
|
|
|
tbl.insertAdjacentElement('beforebegin', toolbarBottom)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
document.querySelectorAll('table').forEach(function (tbl) {
|
|
|
|
@ -101,19 +110,3 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
|
|
|
|
|
|
|
|
dynamicTables()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
$('table').DataTable({
|
|
|
|
|
stateSave: true,
|
|
|
|
|
fixedHeader: true,
|
|
|
|
|
lengthMenu: [[25, 50, 100, -1], [25, 50, 100, "All"]],
|
|
|
|
|
stateSaveCallback: function(settings,data) {
|
|
|
|
|
localStorage.setItem('DataTables', JSON.stringify(data))
|
|
|
|
|
},
|
|
|
|
|
stateLoadCallback: function(settings) {
|
|
|
|
|
return JSON.parse(localStorage.getItem('DataTables'))
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
*/
|
|
|
|
|