// таблица export const cntrls = { table: document.querySelector("#items-table tbody"), form: document.getElementById("items-form"), lineId: document.getElementById("items-line-id"), nickname: document.getElementById("nickname"), email: document.getElementById("email"), password: document.getElementById("password"), image: document.getElementById("image"), imagePreview: document.getElementById("image-preview"), }; export const imagePlaceholder = "https://via.placeholder.com/200"; function createTableAnchor(icon, callback) { const i = document.createElement("i"); i.classList.add("fa-solid", icon); const a = document.createElement("a"); a.href = "#"; a.appendChild(i); a.onclick = (event) => { event.preventDefault(); event.stopPropagation(); callback(); }; const td = document.createElement("td"); td.appendChild(a); return td; } function createTableColumn(value) { const td = document.createElement("td"); td.textContent = value; return td; } export function createTableRow(item, index, editPageCallback, deleteCallback) { const rowNumber = document.createElement("th"); rowNumber.scope = "row"; rowNumber.textContent = index + 1; const row = document.createElement("tr"); row.id = `line-${item.id}`; row.appendChild(rowNumber); row.appendChild(createTableColumn(item.nickname)); row.appendChild(createTableColumn(item.email)); row.appendChild(createTableColumn(item.password)); row.appendChild(createTableAnchor("fa-pen-to-square", editPageCallback)); row.appendChild(createTableAnchor("fa-trash", deleteCallback)); return row; }