Spaces:
Running
Running
File size: 5,037 Bytes
e2c3be1 72116b3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
<!DOCTYPE html>
<html lang="ro">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cititor</title>
<style>
body {
margin: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
background-color: #f5f5f5;
overflow: hidden;
}
#reader-container {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
}
#reader-container img {
width: 100%;
height: auto;
transform-origin: center center;
transition: opacity 0.2s ease, transform 0.3s;
cursor: grab;
opacity: 0;
position: absolute;
}
#reader-container img.visible {
opacity: 1;
}
@media (min-width: 768px) {
#reader-container img {
height: 90vh;
width: auto;
}
}
.controls {
position: absolute;
bottom: 20px;
display: flex;
justify-content: center;
gap: 10px;
}
button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
border: none;
border-radius: 5px;
background-color: #007bff;
color: white;
transition: background-color 0.3s;
}
button:disabled {
background-color: #ddd;
cursor: not-allowed;
}
button:hover:not(:disabled) {
background-color: #0056b3;
}
#page-input {
position: absolute;
top: 20px;
font-size: 24px;
padding: 10px 20px;
border: none;
border-radius: 10px;
text-align: center;
z-index: 1;
width: 210px;
}
#page-input:focus {
outline: none;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}
#page-number {
position: absolute;
top: 20px;
left: 20px;
font-size: 24px;
padding: 10px 20px;
border: none;
border-radius: 10px;
text-align: center;
z-index: 1;
background-color: #007bff;
color: white;
}
#loading-message {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 24px;
color: #333;
}
</style>
</head>
<body>
<div id="reader-container">
<div id="page-number"></div>
<input id="page-input" type="number" placeholder="Introdu pagina" oninput="handlePageInput(this.value)">
<img id="page-image" src="" alt="Pagina" style="display: none;">
<div id="loading-message">Imaginea se încarcă, vă rog așteptați</div>
</div>
<div class="controls">
<button id="prev-button" disabled>Înapoi</button>
<button id="next-button">Înainte</button>
</div>
<script>
const TOTAL_PAGES = 92;
let currentPage = 1;
const imageElement = document.getElementById('page-image');
const prevButton = document.getElementById('prev-button');
const nextButton = document.getElementById('next-button');
const pageNumberElement = document.getElementById('page-number');
const loadingMessage = document.getElementById('loading-message');
const preloadImages = [];
const preload = (pages) => {
pages.forEach(page => {
if (page >= 1 && page <= TOTAL_PAGES) {
const img = new Image();
img.src = `pages/${page}.jpg`;
preloadImages.push(img);
}
});
};
const updatePage = () => {
imageElement.classList.remove('visible');
loadingMessage.style.display = 'block';
setTimeout(() => {
imageElement.src = `pages/${currentPage}.jpg`;
imageElement.alt = `Pagina ${currentPage}`;
prevButton.disabled = currentPage === 1;
nextButton.disabled = currentPage === TOTAL_PAGES;
const pageNumber = currentPage * 2 + 1;
pageNumberElement.textContent = `${pageNumber - 1}-${pageNumber}`;
}, 0);
};
imageElement.onload = () => {
imageElement.style.display = 'block';
loadingMessage.style.display = 'none';
imageElement.classList.add('visible');
};
prevButton.addEventListener('click', () => {
if (currentPage > 1) {
currentPage--;
updatePage();
}
});
nextButton.addEventListener('click', () => {
if (currentPage < TOTAL_PAGES) {
currentPage++;
updatePage();
}
});
document.addEventListener('keydown', (e) => {
if (e.key === 'ArrowLeft' && currentPage > 1) {
currentPage--;
updatePage();
} else if (e.key === 'ArrowRight' && currentPage < TOTAL_PAGES) {
currentPage++;
updatePage();
}
});
function handlePageInput(value) {
const pageNumber = parseInt(value);
if (!isNaN(pageNumber) && pageNumber >= 1 && pageNumber <= TOTAL_PAGES * 2) {
currentPage = Math.ceil(pageNumber / 2);
updatePage();
}
}
updatePage();
</script>
</body>
</html>
|