{"id":159,"date":"2025-01-20T18:18:41","date_gmt":"2025-01-20T21:18:41","guid":{"rendered":"https:\/\/jgplate.nl\/pt\/?page_id=159"},"modified":"2025-01-21T20:18:45","modified_gmt":"2025-01-21T23:18:45","slug":"acervo","status":"publish","type":"page","link":"https:\/\/jgplate.nl\/pt\/acervo\/","title":{"rendered":"Biblioteca"},"content":{"rendered":"\n<div style=\"display: flex; flex-wrap: wrap;\">\n    <div style=\"flex: 70%; padding-right: 10px;\">\n        <div>\n            <label for=\"title-search\">Procurar por T\u00edtulo:<\/label>\n            <input type=\"text\" id=\"title-search\" oninput=\"applyFilter()\" placeholder=\"Digite o t\u00edtulo do livro\">\n        <\/div>\n\n        <div>\n            <label for=\"author-search\">Procurar por Autor:<\/label>\n            <input type=\"text\" id=\"author-search\" oninput=\"applyFilter()\" placeholder=\"Digite o nome do autor\">\n        <\/div>\n    <\/div>\n\n    <div style=\"flex: 30%; padding-left: 10px;\">\n        <div>\n            <label for=\"language-filter\">Filtrar por L\u00edngua:<\/label>\n            <select id=\"language-filter\" onchange=\"applyFilter()\">\n                <option value=\"\">Todas<\/option>\n                <option value=\"PT\">Portugu\u00eas<\/option>\n                <option value=\"EN\">Ingl\u00eas<\/option>\n                <option value=\"NL\">Holand\u00eas<\/option>\n                <option value=\"ES\">Espanhol<\/option>\n            <\/select>\n        <\/div>\n\n        <div>\n            <label for=\"status-filter\">Filtrar por Status:<\/label>\n            <select id=\"status-filter\" onchange=\"applyFilter()\">\n                <option value=\"\">Todos<\/option>\n                <option value=\"Dispon\u00edvel\">Dispon\u00edvel<\/option>\n                <option value=\"Reservado\">Reservado<\/option>\n                <option value=\"Emprestado\">Emprestado<\/option>\n            <\/select>\n        <\/div>\n    <\/div>\n<\/div>\n\n<table style=\"width: 100%; border-collapse: collapse;\">\n<\/table>\n\n<script>\n    let sheetData = [];\n\n    async function loadGoogleSheetData() {\n        const url = \"https:\/\/sheets.googleapis.com\/v4\/spreadsheets\/1N6tgvXVn_u2lyjkn4UKzPiFQ4r84mKzKX4v9fR2PQSk\/values\/import?key=AIzaSyDsQzZ_qc1U6TMDKWyggBoQI99x8pX7QEk\";\n\n        try {\n            const response = await fetch(url);\n            const data = await response.json();\n\n            if (data.values) {\n                sheetData = data.values;\n                renderTable(sheetData);\n            } else {\n                console.error(\"No data found in the sheet.\");\n            }\n        } catch (error) {\n            console.error(\"Error fetching Google Sheet data:\", error);\n        }\n    }\n\n    function renderTable(data) {\n        const tableContainer = document.querySelector(\"table\");\n        tableContainer.innerHTML = \"\"; \/\/ Clear the table before rendering\n\n        data.forEach((row, index) => {\n            if (index === 0) return; \/\/ Skip header row\n            const [codigo, titulo, autor1, autor2, lingua, grupo, imagem, status] = row;\n\n            const tableRow = document.createElement(\"tr\");\n\n            \/\/ Coluna da imagem\n            const imgCell = document.createElement(\"td\");\n            imgCell.style.width = \"240px\";\n            imgCell.style.border = \"1px solid black\";\n            imgCell.style.textAlign = \"center\";\n            imgCell.style.padding = \"2px\";\n            const img = document.createElement(\"img\");\n            img.src = imagem;\n            img.alt = titulo;\n            img.style.maxWidth = \"100%\";\n            imgCell.appendChild(img);\n            tableRow.appendChild(imgCell);\n\n            \/\/ Coluna do t\u00edtulo e autores\n            const infoCell = document.createElement(\"td\");\n            infoCell.style.width = \"720px\";\n            infoCell.style.border = \"1px solid black\";\n            infoCell.style.textAlign = \"left\";\n            infoCell.style.padding = \"2px\";\n            infoCell.innerHTML = `<h4>${titulo}<\/h4><p>Autor: ${autor1}<\/p><p>Autor 2: ${autor2}<\/p>`;\n            tableRow.appendChild(infoCell);\n\n            \/\/ Coluna do c\u00f3digo, grupo e status\n            const detailsCell = document.createElement(\"td\");\n            detailsCell.style.width = \"480px\";\n            detailsCell.style.border = \"1px solid black\";\n            detailsCell.style.textAlign = \"left\";\n            detailsCell.style.padding = \"2px\";\n\n            \/\/ Aplicar estilo condicional ao status\n            let statusStyle = \"\";\n            if (status === \"Dispon\u00edvel\") {\n                statusStyle = \"color: darkgreen; font-weight: bold;\";\n            } else if (status === \"Reservado\") {\n                statusStyle = \"color: goldenrod; font-weight: bold;\";\n            } else if (status === \"Emprestado\") {\n                statusStyle = \"color: red; font-weight: bold;\";\n            }\n\n            detailsCell.innerHTML = `<p><strong>C\u00f3digo:<\/strong> ${codigo}<\/p>\n                                     <p><strong>Grupo:<\/strong> ${grupo}<\/p>\n                                     <p><strong>Status:<\/strong> <span style=\"${statusStyle}\">${status}<\/span><\/p>`;\n            tableRow.appendChild(detailsCell);\n\n            tableContainer.appendChild(tableRow);\n        });\n    }\n\n    function applyFilter() {\n        const statusFilterValue = document.getElementById(\"status-filter\").value;\n        const titleFilterValue = document.getElementById(\"title-search\").value.toLowerCase();\n        const authorFilterValue = document.getElementById(\"author-search\").value.toLowerCase();\n        const languageFilterValue = document.getElementById(\"language-filter\").value;\n\n        const filteredData = sheetData.filter(row => {\n            const matchesStatus = !statusFilterValue || row[7] === statusFilterValue || row[0] === \"C\u00f3digo\";\n            const matchesTitle = !titleFilterValue || row[1].toLowerCase().includes(titleFilterValue);\n            const matchesAuthor = !authorFilterValue || row[2].toLowerCase().includes(authorFilterValue) || row[3].toLowerCase().includes(authorFilterValue);\n            const matchesLanguage = !languageFilterValue || row[0].startsWith(languageFilterValue);\n            return matchesStatus && matchesTitle && matchesAuthor && matchesLanguage;\n        });\n\n        renderTable(filteredData);\n    }\n\n    loadGoogleSheetData();\n<\/script>\n\n","protected":false},"excerpt":{"rendered":"<p>Procurar por T\u00edtulo: Procurar por Autor: Filtrar por L\u00edngua: TodasPortugu\u00easIngl\u00easHoland\u00easEspanhol Filtrar por Status: TodosDispon\u00edvelReservadoEmprestado<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-159","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/jgplate.nl\/pt\/wp-json\/wp\/v2\/pages\/159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jgplate.nl\/pt\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/jgplate.nl\/pt\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/jgplate.nl\/pt\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jgplate.nl\/pt\/wp-json\/wp\/v2\/comments?post=159"}],"version-history":[{"count":55,"href":"https:\/\/jgplate.nl\/pt\/wp-json\/wp\/v2\/pages\/159\/revisions"}],"predecessor-version":[{"id":220,"href":"https:\/\/jgplate.nl\/pt\/wp-json\/wp\/v2\/pages\/159\/revisions\/220"}],"wp:attachment":[{"href":"https:\/\/jgplate.nl\/pt\/wp-json\/wp\/v2\/media?parent=159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}