';
} else {
paginatedRows.forEach(row => tableBody.appendChild(row));
}
renderPagination();
}
function renderPagination() {
paginationContainer.innerHTML = '';
const totalPages = Math.ceil(filteredRows.length / rowsPerPage);
if (totalPages <= 1) return;
// Previous Button
const prevBtn = document.createElement('button');
prevBtn.textContent = '« Prev';
prevBtn.className = 'mlla-page-btn';
prevBtn.disabled = currentPage === 1;
prevBtn.addEventListener('click', () => {
if (currentPage > 1) {
currentPage--;
renderTable();
}
});
paginationContainer.appendChild(prevBtn);
// Simple Text Display
const pageInfo = document.createElement('span');
pageInfo.className = 'mlla-page-info';
pageInfo.textContent = `Page ${currentPage} of ${totalPages}`;
paginationContainer.appendChild(pageInfo);
// Next Button
const nextBtn = document.createElement('button');
nextBtn.textContent = 'Next »';
nextBtn.className = 'mlla-page-btn';
nextBtn.disabled = currentPage === totalPages;
nextBtn.addEventListener('click', () => {
if (currentPage < totalPages) {
currentPage++;
renderTable();
}
});
paginationContainer.appendChild(nextBtn);
}
searchInput.addEventListener('input', function(e) {
const searchTerm = e.target.value.toLowerCase();
filteredRows = originalRows.filter(row => {
const rowText = row.textContent.toLowerCase();
return rowText.includes(searchTerm);
});
currentPage = 1;
renderTable();
});
renderTable();