$(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");
row.setAttribute(
"onclick",
`window.open('` + API_SERVER + `/` + doc.path + `', '_blank')`
);
const data = document.createElement("td");
const rowContainer = document.createElement("div");
rowContainer.setAttribute("class", "row-container");
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;
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);
row.appendChild(data);
tbody.appendChild(row);
});
};
createTable();
});