my-reader / index.html
Plahoff's picture
Upload 4 files
124f366 verified
Raw History Blame Contribute Delete
1.12 kB
<!DOCTYPE html>
<html>
<body style="background:#1a1a1a; color:white; font-family:sans-serif; padding:20px;">
<h2>Мои книги</h2>
<div id="list"></div>
<div id="reader" style="display:none;">
<button onclick="location.reload()" style="padding:10px; margin-bottom:10px;">← Назад</button>
<div id="text" style="white-space:pre-wrap; line-height:1.6; font-size:18px;"></div>
</div>
<script>
fetch('/api/books').then(r => r.json()).then(books => {
const list = document.getElementById('list');
list.innerHTML = books.map(b => `<div onclick="load('${b}')" style="padding:15px; background:#333; margin:10px 0; border-radius:8px;">${b}</div>`).join('');
});
function load(name) {
fetch('/api/book/' + name).then(r => r.json()).then(data => {
document.getElementById('list').style.display = 'none';
document.getElementById('reader').style.display = 'block';
document.getElementById('text').innerText = data.text;
});
}
</script>
</body>
</html>