|  |  | @ -1,13 +1,13 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | document.addEventListener('DOMContentLoaded', function() { |  |  |  | document.addEventListener('DOMContentLoaded', function () { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     function label(element, value) { |  |  |  |     function label(element, value) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         if(element.hasAttribute('value')) { |  |  |  |         if (element.hasAttribute('value')) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             if(value !== undefined) { |  |  |  |             if (value !== undefined) { | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 element.setAttribute('value', value) |  |  |  |                 element.setAttribute('value', value) | 
			
		
	
		
		
			
				
					
					|  |  |  |             } else { |  |  |  |             } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 return element.getAttribute('value') |  |  |  |                 return element.getAttribute('value') | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |         } else { |  |  |  |         } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |             if(value !== undefined) { |  |  |  |             if (value !== undefined) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 element.textContent = value |  |  |  |                 element.textContent = value | 
			
		
	
		
		
			
				
					
					|  |  |  |             } else { |  |  |  |             } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 return element.textContent |  |  |  |                 return element.textContent | 
			
		
	
	
		
		
			
				
					|  |  | @ -19,14 +19,14 @@ document.addEventListener('DOMContentLoaded', function() { | 
			
		
	
		
		
			
				
					
					|  |  |  |         const btn = event.target |  |  |  |         const btn = event.target | 
			
		
	
		
		
			
				
					
					|  |  |  |         const countdown = btn.getAttribute('data-countdown') |  |  |  |         const countdown = btn.getAttribute('data-countdown') | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         if(countdown !== '1') { |  |  |  |         if (countdown !== '1') { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             event.preventDefault() |  |  |  |             event.preventDefault() | 
			
		
	
		
		
			
				
					
					|  |  |  |             btn.classList.add('__on-countdown') |  |  |  |             btn.classList.add('__on-countdown') | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             const hasCountdown = countdown !== null |  |  |  |             const hasCountdown = countdown !== null | 
			
		
	
		
		
			
				
					
					|  |  |  |             const newCountdown = hasCountdown ? countdown - 1 : 3 |  |  |  |             const newCountdown = hasCountdown ? countdown - 1 : 3 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             if(!hasCountdown) { |  |  |  |             if (!hasCountdown) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 btn.setAttribute('data-label', label(btn)) |  |  |  |                 btn.setAttribute('data-label', label(btn)) | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -38,29 +38,67 @@ document.addEventListener('DOMContentLoaded', function() { | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     document.querySelectorAll('.delete-btn').forEach(function(btn) { |  |  |  |     document.querySelectorAll('.delete-btn').forEach(function (btn) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         btn.addEventListener('click', countdownDeleteButton) |  |  |  |         btn.addEventListener('click', countdownDeleteButton) | 
			
		
	
		
		
			
				
					
					|  |  |  |     }) |  |  |  |     }) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     function dynamicTables() { |  |  |  |     function dynamicTables() { | 
			
		
	
		
		
			
				
					
					|  |  |  |         const range = (x,y) => |  |  |  |         const pageSize = 25 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |               x > y ? [] : [x, ...range(x + 1, y)]; |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         const pageSize = 50 |  |  |  |         const range = (x, y) => | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         const colsFromThead = thead => |  |  |  |             x > y ? [] : [x, ...range(x + 1, y)]; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |               [...thead.children[0].children].map(th => th.innerText) |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         const visibleRows = page => |  |  |  |         const visibleRows = page => | 
			
		
	
		
		
			
				
					
					|  |  |  |               range(page * pageSize, (page + 1) * pageSize - 1) |  |  |  |             range(page * pageSize, (page + 1) * pageSize - 1) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         document.querySelectorAll('table').forEach(function(tbl) { |  |  |  |         function toggleVisibilities(tbl, ixsToShow) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             const thead = tbl.tHead |  |  |  |             const rows = [...tbl.tBodies[0].rows] | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             const tbody = tbl.tBodies[0] |  |  |  |             rows.forEach(function (row, ix) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             const cols = colsFromThead(thead) |  |  |  |                 row.style.display = ixsToShow.includes(ix) ? 'table-row' : 'none'; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             const rows = [...tbl.rows] |  |  |  |             }) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             let page = 0 |  |  |  |         } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             console.debug(visibleRows(1)) |  |  |  | 
 | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         function prevClick(tbl) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             const page = tbl.getAttribute('data-page') * 1 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             tbl.setAttribute('data-page', page - 1) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             toggleVisibilities(tbl, visibleRows(page - 1)) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         function nextClick(tbl) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             const page = tbl.getAttribute('data-page') * 1 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             tbl.setAttribute('data-page', page + 1) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             toggleVisibilities(tbl, visibleRows(page + 1)) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         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) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         document.querySelectorAll('table').forEach(function (tbl) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             toggleVisibilities(tbl, visibleRows(0)) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             tbl.setAttribute('data-page', 0) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             addToolbar(tbl) | 
			
		
	
		
		
			
				
					
					|  |  |  |         }) |  |  |  |         }) | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     dynamicTables() |  |  |  |     dynamicTables() | 
			
		
	
		
		
			
				
					
					|  |  |  | }) |  |  |  | }) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |