document.addEventListener("DOMContentLoaded", function () {
const listInterval = setInterval(() => {
const tableBody = document.querySelector(".view-grid table tbody");
if (tableBody) {
clearInterval(listInterval);
//find all the rows
const rows = tableBody.querySelectorAll("tr");
rows.forEach(row => {
//find the column to put the button
const pickUpTicketCell = row.querySelector('td[data-th="Pick up ticket"]');
if (pickUpTicketCell) {
//to prevent dupped buttons
if (!pickUpTicketCell.querySelector("button")) {
//create the button
const button = document.createElement("button");
button.innerText = "Pick Up Ticket";
button.style.margin = "5px"; //style
//click event
button.addEventListener("click", function () {
const ticketId = row.dataset.id;
alert(`Pop up message, row ID: ${ticketId}`);
});
pickUpTicketCell.appendChild(button);
}
}
});
console.log("Buttons added successfully.");
}
}, 500);
});