function setEditButtonOnClick(editButton, printer) { editButton.onclick = function () { document.getElementById('editInputName').value = printer.name; document.getElementById('editInputPrice').value = printer.price; document.getElementById('editInputBuildVolume').value = printer.build_volume; document.getElementById('editInputMaxSpeed').value = printer.max_speed; document.getElementById('editModalConfirm').setAttribute('onclick', `editPrinter(${printer.id})`); } } function setButtonAttributes(buttonType, modal) { const button = document.createElement('button'); button.setAttribute('data-bs-target', modal); button.setAttribute('data-bs-toggle', 'modal'); button.setAttribute('class', `btn ${buttonType}`); return button; } function setViewButtonOnClick(viewButton, printer) { viewButton.onclick = function () { document.getElementById('viewModalName').textContent = `Name: ${printer.name}`; document.getElementById('viewModalPrice').textContent = `Price: ${printer.price.toFixed(2)}$`; document.getElementById('viewModalBuildVolume').textContent = `Build Volume: ${printer.build_volume}`; document.getElementById('viewModalMaxSpeed').textContent = `Max Speed: ${printer.max_speed}mm/s`; } }