document.addEventListener("DOMContentLoaded", function() { const csvFilePath = './book_evolution/data.csv'; function loadCSV(filePath) { return fetch(filePath) .then(response => response.text()) .then(text => Papa.parse(text, { header: true }).data); } function createFlipBook(pages) { const container = document.getElementById('flip_book_container'); const numPages = pages.length; let flipBookHTML = ''; let style = document.createElement('style'); let css = ''; flipBookHTML += `\n`; for (let i = 0; i < numPages - 1; i++) { flipBookHTML += `\n`; } flipBookHTML += `
\n`; flipBookHTML += `
` for (let i = 0; i < numPages - 1; i++) { console.log(i) const page = pages[i]; const pageIndex = i + 1; flipBookHTML += `
Back content
Back page edge shading

${page.title}

${page.author}

${page.affiliation}

${page.summary}

\n`; css += ` #page${pageIndex} { z-index: ${numPages - i}; } #page${pageIndex}_checkbox:checked~#flip_book #page${pageIndex} { transform: rotateY(-180deg); z-index: ${i + 1}; }\n`; } flipBookHTML += `
Back Cover
`; container.innerHTML = flipBookHTML; style.innerHTML = css; document.head.appendChild(style); const md = window.markdownit(); const summaryElements = document.querySelectorAll('.summary'); summaryElements.forEach(el => { el.innerHTML = md.render(el.textContent); }); } loadCSV(csvFilePath).then(pages => { createFlipBook(pages); }); });