$(document).ready(function () { const createTable = () => { const table = document.getElementById("documentsTable"); const tbody = table.querySelector("tbody"); // Очищаем таблицу tbody.innerHTML = ""; documents.forEach((doc) => { const row = document.createElement("tr"); const data = document.createElement("td"); const rowContainer = document.createElement("div"); rowContainer.setAttribute("class", "row-container with-button"); rowContainer.setAttribute( "onclick", `window.open('` + API_SERVER + `/` + doc.path + `', '_blank')` ); const rowIcon = document.createElement("div"); rowIcon.setAttribute("class", "row-icon"); let svgContent; if (doc.type === "pdf") { svgContent = ` `; } else if (doc.type === "doc" || doc.type === "docx") { svgContent = ` `; } else { svgContent = ` `; } rowIcon.innerHTML = svgContent; rowContainer.appendChild(rowIcon); const rowContent = document.createElement("div"); rowContent.setAttribute("class", "row-content"); const documentName = document.createElement("h1"); documentName.textContent = doc.name; documentName.setAttribute("id", `doc-name-${doc.id}`); rowContent.appendChild(documentName); const documentType = document.createElement("h2"); documentType.textContent = doc.type; rowContent.appendChild(documentType); const date = document.createElement("span"); date.textContent = doc.date; rowContent.appendChild(date); rowContainer.appendChild(rowContent); data.appendChild(rowContainer); if (isAdmin && isFull) { const deleteContainer = document.createElement("div"); deleteContainer.setAttribute("class", "row-delete-container"); deleteContainer.setAttribute("onclick", `deleteDoc(${doc.id});`); let deleteContent = ` `; deleteContainer.innerHTML = deleteContent; data.appendChild(deleteContainer); } row.appendChild(data); tbody.appendChild(row); }); }; createTable(); });