Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1584,18 +1584,113 @@ HTML = """
|
|
| 1584 |
// ํ์ฌ ์ด๋ฆฐ PDF์ ID
|
| 1585 |
let currentPdfId = null;
|
| 1586 |
|
| 1587 |
-
|
| 1588 |
-
|
| 1589 |
-
|
| 1590 |
-
|
| 1591 |
-
|
| 1592 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1593 |
|
| 1594 |
/* โโ ์ ํธ โโ */
|
| 1595 |
function $id(id){return document.getElementById(id)}
|
| 1596 |
|
| 1597 |
// ํ์ผ ์
๋ก๋ ์ด๋ฒคํธ ์ฒ๋ฆฌ
|
| 1598 |
-
|
|
|
|
| 1599 |
console.log("DOM ๋ก๋ ์๋ฃ, ์ด๋ฒคํธ ์ค์ ๏ฟฝ๏ฟฝ์");
|
| 1600 |
|
| 1601 |
// PDF ์
๋ก๋ ๋ฒํผ
|
|
@@ -2175,129 +2270,137 @@ function addCard(i, thumb, title, isCached = false, pdfId = null) {
|
|
| 2175 |
}
|
| 2176 |
}
|
| 2177 |
|
| 2178 |
-
|
| 2179 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2180 |
|
| 2181 |
-
|
| 2182 |
-
|
| 2183 |
-
|
| 2184 |
-
|
| 2185 |
-
|
| 2186 |
-
|
| 2187 |
-
|
| 2188 |
-
|
| 2189 |
-
|
| 2190 |
-
|
| 2191 |
-
|
| 2192 |
-
|
| 2193 |
-
|
| 2194 |
-
|
| 2195 |
-
|
| 2196 |
-
|
| 2197 |
-
} else { // ์ธ๋ก ํ๋ฉด
|
| 2198 |
-
width = Math.min(windowWidth * 0.9, windowWidth - 40);
|
| 2199 |
-
height = width / aspectRatio * 0.9; // ์ธ๋ก ํ๋ฉด์์๋ ์ฝ๊ฐ ๋๋ฆผ
|
| 2200 |
-
if (height > windowHeight * 0.9) {
|
| 2201 |
-
height = windowHeight * 0.9;
|
| 2202 |
-
width = height * aspectRatio * 0.9;
|
| 2203 |
-
}
|
| 2204 |
-
}
|
| 2205 |
-
|
| 2206 |
-
// ์ต์ ์ฌ์ด์ฆ ๋ฐํ
|
| 2207 |
-
return {
|
| 2208 |
-
width: Math.round(width),
|
| 2209 |
-
height: Math.round(height)
|
| 2210 |
-
};
|
| 2211 |
-
};
|
| 2212 |
-
|
| 2213 |
-
// ์ด๊ธฐ ํ๋ฉด ๋น์จ ๊ณ์ฐ
|
| 2214 |
-
const size = calculateAspectRatio();
|
| 2215 |
-
viewer.style.width = size.width + 'px';
|
| 2216 |
-
viewer.style.height = size.height + 'px';
|
| 2217 |
-
|
| 2218 |
-
// ํ์ด์ง ๋ฐ์ดํฐ ์ ์ (๋น ํ์ด์ง ์ฒ๋ฆฌ)
|
| 2219 |
-
const validPages = pages.map(page => {
|
| 2220 |
-
// src๊ฐ ์๋ ํ์ด์ง๋ ๋ก๋ฉ ์ค ์ด๋ฏธ์ง๋ก ๋์ฒด
|
| 2221 |
-
if (!page || !page.src) {
|
| 2222 |
-
return {
|
| 2223 |
-
src: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjVmNWY1Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSJBcmlhbCIgZm9udC1zaXplPSIxMiIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9Ii4zZW0iIGZpbGw9IiM1NTUiPkxvYWRpbmcuLi48L3RleHQ+PC9zdmc+',
|
| 2224 |
-
thumb: page && page.thumb ? page.thumb : ''
|
| 2225 |
-
};
|
| 2226 |
-
}
|
| 2227 |
-
return page;
|
| 2228 |
-
});
|
| 2229 |
-
|
| 2230 |
-
fb = new FlipBook(viewer, {
|
| 2231 |
-
pages: validPages,
|
| 2232 |
-
viewMode: 'webgl',
|
| 2233 |
-
autoSize: true,
|
| 2234 |
-
flipDuration: 800,
|
| 2235 |
-
backgroundColor: '#fff',
|
| 2236 |
-
/* ๐ ๋ด์ฅ ์ฌ์ด๋ */
|
| 2237 |
-
sound: true,
|
| 2238 |
-
assets: {flipMp3: 'static/turnPage2.mp3', hardFlipMp3: 'static/turnPage2.mp3'},
|
| 2239 |
-
controlsProps: {
|
| 2240 |
-
enableFullscreen: true,
|
| 2241 |
-
enableToc: true,
|
| 2242 |
-
enableDownload: false,
|
| 2243 |
-
enablePrint: false,
|
| 2244 |
-
enableZoom: true,
|
| 2245 |
-
enableShare: true, // ๊ณต์ ๋ฒํผ ํ์ฑํ
|
| 2246 |
-
enableSearch: true,
|
| 2247 |
-
enableAutoPlay: true,
|
| 2248 |
-
enableAnnotation: false,
|
| 2249 |
-
enableSound: true,
|
| 2250 |
-
enableLightbox: false,
|
| 2251 |
-
layout: 10, // ๋ ์ด์์ ์ต์
|
| 2252 |
-
skin: 'light', // ์คํจ ์คํ์ผ
|
| 2253 |
-
autoNavigationTime: 3600, // ์๋ ๋๊น ์๊ฐ(์ด)
|
| 2254 |
-
hideControls: false, // ์ปจํธ๋กค ์จ๊น ๋นํ์ฑํ
|
| 2255 |
-
paddingTop: 10, // ์๋จ ํจ๋ฉ
|
| 2256 |
-
paddingLeft: 10, // ์ข์ธก ํจ๋ฉ
|
| 2257 |
-
paddingRight: 10, // ์ฐ์ธก ํจ๋ฉ
|
| 2258 |
-
paddingBottom: 10, // ํ๋จ ํจ๋ฉ
|
| 2259 |
-
pageTextureSize: 1024, // ํ์ด์ง ํ
์ค์ฒ ํฌ๊ธฐ
|
| 2260 |
-
thumbnails: true, // ์ฌ๋ค์ผ ํ์ฑํ
|
| 2261 |
-
autoHideControls: false, // ์๋ ์จ๊น ๋นํ์ฑํ
|
| 2262 |
-
controlsTimeout: 8000, // ์ปจํธ๋กค ํ์ ์๊ฐ ์ฐ์ฅ
|
| 2263 |
-
shareHandler: copyPdfShareUrl // ๊ณต์ ํธ๋ค๋ฌ ์ค์
|
| 2264 |
-
}
|
| 2265 |
-
});
|
| 2266 |
-
|
| 2267 |
-
// ํ๋ฉด ํฌ๊ธฐ ๋ณ๊ฒฝ ์ FlipBook ํฌ๊ธฐ ์กฐ์
|
| 2268 |
-
window.addEventListener('resize', () => {
|
| 2269 |
-
if (fb) {
|
| 2270 |
-
const newSize = calculateAspectRatio();
|
| 2271 |
-
viewer.style.width = newSize.width + 'px';
|
| 2272 |
-
viewer.style.height = newSize.height + 'px';
|
| 2273 |
-
fb.resize();
|
| 2274 |
-
}
|
| 2275 |
-
});
|
| 2276 |
-
|
| 2277 |
-
// FlipBook ์์ฑ ํ ์ปจํธ๋กค๋ฐ ๊ฐ์ ํ์
|
| 2278 |
-
setTimeout(() => {
|
| 2279 |
-
try {
|
| 2280 |
-
// ์ปจํธ๋กค๋ฐ ๊ด๋ จ ์์ ์ฐพ๊ธฐ ๋ฐ ์คํ์ผ ์ ์ฉ
|
| 2281 |
-
const menuBars = document.querySelectorAll('.flipbook-container .fb3d-menu-bar');
|
| 2282 |
-
if (menuBars && menuBars.length > 0) {
|
| 2283 |
-
menuBars.forEach(menuBar => {
|
| 2284 |
-
menuBar.style.display = 'block';
|
| 2285 |
-
menuBar.style.opacity = '1';
|
| 2286 |
-
menuBar.style.visibility = 'visible';
|
| 2287 |
-
menuBar.style.zIndex = '9999';
|
| 2288 |
-
});
|
| 2289 |
-
}
|
| 2290 |
-
} catch (e) {
|
| 2291 |
-
console.warn('์ปจํธ๋กค๋ฐ ์คํ์ผ ์ ์ฉ ์ค ์ค๋ฅ:', e);
|
| 2292 |
-
}
|
| 2293 |
-
}, 1000);
|
| 2294 |
-
|
| 2295 |
-
console.log('FlipBook ์์ฑ ์๋ฃ');
|
| 2296 |
-
} catch (error) {
|
| 2297 |
-
console.error('FlipBook ์์ฑ ์ค ์ค๋ฅ ๋ฐ์:', error);
|
| 2298 |
-
showError("FlipBook์ ์์ฑํ๋ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.");
|
| 2299 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2300 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2301 |
|
| 2302 |
/* โโ ๋ค๋น๊ฒ์ด์
โโ */
|
| 2303 |
$id('homeButton').onclick=()=>{
|
|
@@ -2393,6 +2496,96 @@ function addCard(i, thumb, title, isCached = false, pdfId = null) {
|
|
| 2393 |
$id('home').style.display = 'block';
|
| 2394 |
});
|
| 2395 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2396 |
|
| 2397 |
// ๊ด๋ฆฌ์ ํ์ด์ง ํ์
|
| 2398 |
async function showAdminPage() {
|
|
|
|
| 1584 |
// ํ์ฌ ์ด๋ฆฐ PDF์ ID
|
| 1585 |
let currentPdfId = null;
|
| 1586 |
|
| 1587 |
+
// ์ค๋์ค ์ปจํ
์คํธ์ ์ด๊ธฐํ ์ํ ๊ด๋ฆฌ
|
| 1588 |
+
let audioInitialized = false;
|
| 1589 |
+
let audioContext = null;
|
| 1590 |
+
|
| 1591 |
+
// ์ค๋์ค ์ด๊ธฐํ ํจ์
|
| 1592 |
+
function initializeAudio() {
|
| 1593 |
+
if (audioInitialized) return Promise.resolve();
|
| 1594 |
+
|
| 1595 |
+
return new Promise((resolve) => {
|
| 1596 |
+
// ์ค๋์ค ์ปจํ
์คํธ ์์ฑ (์ฌ์ฉ์ ์ํธ์์ฉ์ด ํ์ ์๋ ์ด๊ธฐํ)
|
| 1597 |
+
audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
| 1598 |
+
|
| 1599 |
+
// MP3 ๋ก๋ ๋ฐ ์ด๊ธฐํ
|
| 1600 |
+
const audio = new Audio('/static/turnPage2.mp3');
|
| 1601 |
+
audio.volume = 0.01; // ์ต์ ๋ณผ๋ฅจ์ผ๋ก ์ค์
|
| 1602 |
+
|
| 1603 |
+
// ๋ก๋๋ ์ค๋์ค ์ฌ์ ์๋ (์ฌ์ฉ์ ์ํธ์์ฉ ์๊ตฌ๋ ์ ์์)
|
| 1604 |
+
const playPromise = audio.play();
|
| 1605 |
+
|
| 1606 |
+
if (playPromise !== undefined) {
|
| 1607 |
+
playPromise
|
| 1608 |
+
.then(() => {
|
| 1609 |
+
// ์ฑ๊ณต์ ์ผ๋ก ์ฌ์๋จ - ์ฆ์ ์ผ์์ ์ง
|
| 1610 |
+
audio.pause();
|
| 1611 |
+
audioInitialized = true;
|
| 1612 |
+
console.log('์ค๋์ค ์ด๊ธฐํ ์ฑ๊ณต');
|
| 1613 |
+
resolve();
|
| 1614 |
+
})
|
| 1615 |
+
.catch((error) => {
|
| 1616 |
+
console.log('์๋ ์ค๋์ค ์ด๊ธฐํ ์คํจ, ์ฌ์ฉ์ ์ํธ์์ฉ ํ์:', error);
|
| 1617 |
+
|
| 1618 |
+
// ์ฌ์ฉ์ ์ํธ์์ฉ์ด ํ์ํ ๊ฒฝ์ฐ, ์ด๋ฒคํธ ๋ฆฌ์ค๋ ์ถ๊ฐ
|
| 1619 |
+
const initOnUserAction = function() {
|
| 1620 |
+
const tempAudio = new Audio('/static/turnPage2.mp3');
|
| 1621 |
+
tempAudio.volume = 0.01;
|
| 1622 |
+
tempAudio.play()
|
| 1623 |
+
.then(() => {
|
| 1624 |
+
tempAudio.pause();
|
| 1625 |
+
audioInitialized = true;
|
| 1626 |
+
console.log('์ฌ์ฉ์ ์ํธ์์ฉ์ผ๋ก ์ค๋์ค ์ด๊ธฐํ ์ฑ๊ณต');
|
| 1627 |
+
resolve();
|
| 1628 |
+
|
| 1629 |
+
// ์ด๋ฒคํธ ๋ฆฌ์ค๋ ์ ๊ฑฐ
|
| 1630 |
+
['click', 'touchstart', 'keydown'].forEach(event => {
|
| 1631 |
+
document.removeEventListener(event, initOnUserAction, { capture: true });
|
| 1632 |
+
});
|
| 1633 |
+
})
|
| 1634 |
+
.catch(e => console.error('์ค๋์ค ์ด๊ธฐํ ์คํจ:', e));
|
| 1635 |
+
};
|
| 1636 |
+
|
| 1637 |
+
// ์ฌ์ฉ์ ์ํธ์์ฉ ์ด๋ฒคํธ์ ๋ฆฌ์ค๋ ์ถ๊ฐ
|
| 1638 |
+
['click', 'touchstart', 'keydown'].forEach(event => {
|
| 1639 |
+
document.addEventListener(event, initOnUserAction, { once: true, capture: true });
|
| 1640 |
+
});
|
| 1641 |
+
|
| 1642 |
+
// ํ์ด์ง ๋ก๋ ์งํ ์ฌ์ฉ์์๊ฒ ์ค๋์ค ํ์ฑํ ์์ฒญ
|
| 1643 |
+
if (window.location.pathname.startsWith('/view/')) {
|
| 1644 |
+
// ์ค๋์ค ํ์ฑํ ์๋ด ๋ฉ์์ง ํ์ (๋ฐ๋ก๊ฐ๊ธฐ ๋งํฌ๋ก ์ ์ํ ๊ฒฝ์ฐ)
|
| 1645 |
+
setTimeout(() => {
|
| 1646 |
+
const audioPrompt = document.createElement('div');
|
| 1647 |
+
audioPrompt.style.position = 'fixed';
|
| 1648 |
+
audioPrompt.style.bottom = '80px';
|
| 1649 |
+
audioPrompt.style.left = '50%';
|
| 1650 |
+
audioPrompt.style.transform = 'translateX(-50%)';
|
| 1651 |
+
audioPrompt.style.backgroundColor = 'rgba(0,0,0,0.7)';
|
| 1652 |
+
audioPrompt.style.color = 'white';
|
| 1653 |
+
audioPrompt.style.padding = '10px 20px';
|
| 1654 |
+
audioPrompt.style.borderRadius = '20px';
|
| 1655 |
+
audioPrompt.style.zIndex = '10000';
|
| 1656 |
+
audioPrompt.style.cursor = 'pointer';
|
| 1657 |
+
audioPrompt.innerHTML = 'ํ์ด์ง ์ด๋๋ ํด๋ฆญํ์ฌ ์๋ฆฌ ํจ๊ณผ ํ์ฑํ <i class="fas fa-volume-up"></i>';
|
| 1658 |
+
audioPrompt.id = 'audioPrompt';
|
| 1659 |
+
|
| 1660 |
+
// ํด๋ฆญ ์ ์๋ฆฌ ํ์ฑํ ๋ฐ ๋ฉ์์ง ์ ๊ฑฐ
|
| 1661 |
+
audioPrompt.addEventListener('click', function() {
|
| 1662 |
+
initOnUserAction();
|
| 1663 |
+
audioPrompt.remove();
|
| 1664 |
+
});
|
| 1665 |
+
|
| 1666 |
+
document.body.appendChild(audioPrompt);
|
| 1667 |
+
|
| 1668 |
+
// 10์ด ํ ์๋์ผ๋ก ์จ๊น
|
| 1669 |
+
setTimeout(() => {
|
| 1670 |
+
if (document.getElementById('audioPrompt')) {
|
| 1671 |
+
document.getElementById('audioPrompt').remove();
|
| 1672 |
+
}
|
| 1673 |
+
}, 10000);
|
| 1674 |
+
}, 2000);
|
| 1675 |
+
}
|
| 1676 |
+
});
|
| 1677 |
+
} else {
|
| 1678 |
+
// ๋ธ๋ผ์ฐ์ ๊ฐ Promise ๊ธฐ๋ฐ ์ฌ์์ ์ง์ํ์ง ์๋ ๊ฒฝ์ฐ
|
| 1679 |
+
audioInitialized = true;
|
| 1680 |
+
resolve();
|
| 1681 |
+
}
|
| 1682 |
+
});
|
| 1683 |
+
}
|
| 1684 |
+
|
| 1685 |
+
// ํ์ด์ง ๋ก๋ ์ ์ค๋์ค ์ด๊ธฐํ ์๋
|
| 1686 |
+
document.addEventListener('DOMContentLoaded', initializeAudio);
|
| 1687 |
|
| 1688 |
/* โโ ์ ํธ โโ */
|
| 1689 |
function $id(id){return document.getElementById(id)}
|
| 1690 |
|
| 1691 |
// ํ์ผ ์
๋ก๋ ์ด๋ฒคํธ ์ฒ๋ฆฌ
|
| 1692 |
+
// ํ์ด์ง ๋ก๋ ์ ์ค๋์ค ์ด๊ธฐํ ์๋
|
| 1693 |
+
document.addEventListener('DOMContentLoaded', initializeAudio);
|
| 1694 |
console.log("DOM ๋ก๋ ์๋ฃ, ์ด๋ฒคํธ ์ค์ ๏ฟฝ๏ฟฝ์");
|
| 1695 |
|
| 1696 |
// PDF ์
๋ก๋ ๋ฒํผ
|
|
|
|
| 2270 |
}
|
| 2271 |
}
|
| 2272 |
|
| 2273 |
+
|
| 2274 |
+
function createFlipBook(pages) {
|
| 2275 |
+
console.log('FlipBook ์์ฑ ์์. ํ์ด์ง ์:', pages.length);
|
| 2276 |
+
|
| 2277 |
+
try {
|
| 2278 |
+
// ํ๋ฉด ๋น์จ ๊ณ์ฐ
|
| 2279 |
+
const calculateAspectRatio = () => {
|
| 2280 |
+
const windowWidth = window.innerWidth;
|
| 2281 |
+
const windowHeight = window.innerHeight;
|
| 2282 |
+
const aspectRatio = windowWidth / windowHeight;
|
| 2283 |
|
| 2284 |
+
// ๋๋น ๋๋ ๋์ด ๊ธฐ์ค์ผ๋ก ์ต๋ 90% ์ ํ
|
| 2285 |
+
let width, height;
|
| 2286 |
+
if (aspectRatio > 1) { // ๊ฐ๋ก ํ๋ฉด
|
| 2287 |
+
height = Math.min(windowHeight * 0.9, windowHeight - 40);
|
| 2288 |
+
width = height * aspectRatio * 0.8; // ๊ฐ๋ก ํ๋ฉด์์๋ ์ฝ๊ฐ ์ค์
|
| 2289 |
+
if (width > windowWidth * 0.9) {
|
| 2290 |
+
width = windowWidth * 0.9;
|
| 2291 |
+
height = width / (aspectRatio * 0.8);
|
| 2292 |
+
}
|
| 2293 |
+
} else { // ์ธ๋ก ํ๋ฉด
|
| 2294 |
+
width = Math.min(windowWidth * 0.9, windowWidth - 40);
|
| 2295 |
+
height = width / aspectRatio * 0.9; // ์ธ๋ก ํ๋ฉด์์๋ ์ฝ๊ฐ ๋๋ฆผ
|
| 2296 |
+
if (height > windowHeight * 0.9) {
|
| 2297 |
+
height = windowHeight * 0.9;
|
| 2298 |
+
width = height * aspectRatio * 0.9;
|
| 2299 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2300 |
}
|
| 2301 |
+
|
| 2302 |
+
// ์ต์ ์ฌ์ด์ฆ ๋ฐํ
|
| 2303 |
+
return {
|
| 2304 |
+
width: Math.round(width),
|
| 2305 |
+
height: Math.round(height)
|
| 2306 |
+
};
|
| 2307 |
+
};
|
| 2308 |
+
|
| 2309 |
+
// ์ด๊ธฐ ํ๋ฉด ๋น์จ ๊ณ์ฐ
|
| 2310 |
+
const size = calculateAspectRatio();
|
| 2311 |
+
viewer.style.width = size.width + 'px';
|
| 2312 |
+
viewer.style.height = size.height + 'px';
|
| 2313 |
+
|
| 2314 |
+
// ์ฌ์ด๋ ์ด๊ธฐํ ์ฌ๋ถ ํ์ธ
|
| 2315 |
+
if (!audioInitialized) {
|
| 2316 |
+
initializeAudio()
|
| 2317 |
+
.then(() => console.log('FlipBook ์์ฑ ์ ์ค๋์ค ์ด๊ธฐํ ์๋ฃ'))
|
| 2318 |
+
.catch(e => console.warn('FlipBook ์์ฑ ์ ์ค๋์ค ์ด๊ธฐํ ์คํจ:', e));
|
| 2319 |
}
|
| 2320 |
+
|
| 2321 |
+
// ํ์ด์ง ๋ฐ์ดํฐ ์ ์ (๋น ํ์ด์ง ์ฒ๋ฆฌ)
|
| 2322 |
+
const validPages = pages.map(page => {
|
| 2323 |
+
// src๊ฐ ์๋ ํ์ด์ง๋ ๋ก๋ฉ ์ค ์ด๋ฏธ์ง๋ก ๋์ฒด
|
| 2324 |
+
if (!page || !page.src) {
|
| 2325 |
+
return {
|
| 2326 |
+
src: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjVmNWY1Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSJBcmlhbCIgZm9udC1zaXplPSIxMiIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9Ii4zZW0iIGZpbGw9IiM1NTUiPkxvYWRpbmcuLi48L3RleHQ+PC9zdmc+',
|
| 2327 |
+
thumb: page && page.thumb ? page.thumb : ''
|
| 2328 |
+
};
|
| 2329 |
+
}
|
| 2330 |
+
return page;
|
| 2331 |
+
});
|
| 2332 |
+
|
| 2333 |
+
fb = new FlipBook(viewer, {
|
| 2334 |
+
pages: validPages,
|
| 2335 |
+
viewMode: 'webgl',
|
| 2336 |
+
autoSize: true,
|
| 2337 |
+
flipDuration: 800,
|
| 2338 |
+
backgroundColor: '#fff',
|
| 2339 |
+
/* ๐ ๋ด์ฅ ์ฌ์ด๋ */
|
| 2340 |
+
sound: true,
|
| 2341 |
+
assets: {flipMp3: '/static/turnPage2.mp3', hardFlipMp3: '/static/turnPage2.mp3'}, // ์ ๋ ๊ฒฝ๋ก๋ก ์์
|
| 2342 |
+
controlsProps: {
|
| 2343 |
+
enableFullscreen: true,
|
| 2344 |
+
enableToc: true,
|
| 2345 |
+
enableDownload: false,
|
| 2346 |
+
enablePrint: false,
|
| 2347 |
+
enableZoom: true,
|
| 2348 |
+
enableShare: true, // ๊ณต์ ๋ฒํผ ํ์ฑํ
|
| 2349 |
+
enableSearch: true,
|
| 2350 |
+
enableAutoPlay: true,
|
| 2351 |
+
enableAnnotation: false,
|
| 2352 |
+
enableSound: true,
|
| 2353 |
+
enableLightbox: false,
|
| 2354 |
+
layout: 10, // ๋ ์ด์์ ์ต์
|
| 2355 |
+
skin: 'light', // ์คํจ ์คํ์ผ
|
| 2356 |
+
autoNavigationTime: 3600, // ์๋ ๋๊น ์๊ฐ(์ด)
|
| 2357 |
+
hideControls: false, // ์ปจํธ๋กค ์จ๊น ๋นํ์ฑํ
|
| 2358 |
+
paddingTop: 10, // ์๋จ ํจ๋ฉ
|
| 2359 |
+
paddingLeft: 10, // ์ข์ธก ํจ๋ฉ
|
| 2360 |
+
paddingRight: 10, // ์ฐ์ธก ํจ๋ฉ
|
| 2361 |
+
paddingBottom: 10, // ํ๋จ ํจ๋ฉ
|
| 2362 |
+
pageTextureSize: 1024, // ํ์ด์ง ํ
์ค์ฒ ํฌ๊ธฐ
|
| 2363 |
+
thumbnails: true, // ์ฌ๋ค์ผ ํ์ฑํ
|
| 2364 |
+
autoHideControls: false, // ์๋ ์จ๊น ๋นํ์ฑํ
|
| 2365 |
+
controlsTimeout: 8000, // ์ปจํธ๋กค ํ์ ์๊ฐ ์ฐ์ฅ
|
| 2366 |
+
shareHandler: copyPdfShareUrl // ๊ณต์ ํธ๋ค๋ฌ ์ค์
|
| 2367 |
+
}
|
| 2368 |
+
});
|
| 2369 |
+
|
| 2370 |
+
// ํ๋ฉด ํฌ๊ธฐ ๋ณ๊ฒฝ ์ FlipBook ํฌ๊ธฐ ์กฐ์
|
| 2371 |
+
window.addEventListener('resize', () => {
|
| 2372 |
+
if (fb) {
|
| 2373 |
+
const newSize = calculateAspectRatio();
|
| 2374 |
+
viewer.style.width = newSize.width + 'px';
|
| 2375 |
+
viewer.style.height = newSize.height + 'px';
|
| 2376 |
+
fb.resize();
|
| 2377 |
+
}
|
| 2378 |
+
});
|
| 2379 |
+
|
| 2380 |
+
// FlipBook ์์ฑ ํ ์ปจํธ๋กค๋ฐ ๊ฐ์ ํ์
|
| 2381 |
+
setTimeout(() => {
|
| 2382 |
+
try {
|
| 2383 |
+
// ์ปจํธ๋กค๋ฐ ๊ด๋ จ ์์ ์ฐพ๊ธฐ ๋ฐ ์คํ์ผ ์ ์ฉ
|
| 2384 |
+
const menuBars = document.querySelectorAll('.flipbook-container .fb3d-menu-bar');
|
| 2385 |
+
if (menuBars && menuBars.length > 0) {
|
| 2386 |
+
menuBars.forEach(menuBar => {
|
| 2387 |
+
menuBar.style.display = 'block';
|
| 2388 |
+
menuBar.style.opacity = '1';
|
| 2389 |
+
menuBar.style.visibility = 'visible';
|
| 2390 |
+
menuBar.style.zIndex = '9999';
|
| 2391 |
+
});
|
| 2392 |
+
}
|
| 2393 |
+
} catch (e) {
|
| 2394 |
+
console.warn('์ปจํธ๋กค๋ฐ ์คํ์ผ ์ ์ฉ ์ค ์ค๋ฅ:', e);
|
| 2395 |
+
}
|
| 2396 |
+
}, 1000);
|
| 2397 |
+
|
| 2398 |
+
console.log('FlipBook ์์ฑ ์๋ฃ');
|
| 2399 |
+
} catch (error) {
|
| 2400 |
+
console.error('FlipBook ์์ฑ ์ค ์ค๋ฅ ๋ฐ์:', error);
|
| 2401 |
+
showError("FlipBook์ ์์ฑํ๋ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.");
|
| 2402 |
+
}
|
| 2403 |
+
}
|
| 2404 |
|
| 2405 |
/* โโ ๋ค๋น๊ฒ์ด์
โโ */
|
| 2406 |
$id('homeButton').onclick=()=>{
|
|
|
|
| 2496 |
$id('home').style.display = 'block';
|
| 2497 |
});
|
| 2498 |
}
|
| 2499 |
+
|
| 2500 |
+
/* โโ ์นด๋ โ FlipBook โโ */
|
| 2501 |
+
async function open(i) {
|
| 2502 |
+
// ๊ธฐ์กด open ํจ์ ๋ด์ฉ...
|
| 2503 |
+
}
|
| 2504 |
+
|
| 2505 |
+
/* โโ PDF ID๋ก PDF ์ด๊ธฐ โโ */
|
| 2506 |
+
async function openPdfById(pdfId, pdfPath, isCached = false) {
|
| 2507 |
+
try {
|
| 2508 |
+
// ์ค๋์ค ์ด๊ธฐํ ์๋
|
| 2509 |
+
await initializeAudio().catch(e => console.warn('PDF ์ด๊ธฐ ์ ์ค๋์ค ์ด๊ธฐํ ์คํจ:', e));
|
| 2510 |
+
|
| 2511 |
+
// ๋จผ์ ํ ํ๋ฉด์์ ์นด๋๋ฅผ ์ฐพ์์ ํด๋ฆญํ๋ ๋ฐฉ๋ฒ ์๋
|
| 2512 |
+
let foundCard = false;
|
| 2513 |
+
const cards = document.querySelectorAll('.card');
|
| 2514 |
+
|
| 2515 |
+
for (let i = 0; i < cards.length; i++) {
|
| 2516 |
+
if (cards[i].dataset.pdfId === pdfId) {
|
| 2517 |
+
cards[i].click();
|
| 2518 |
+
foundCard = true;
|
| 2519 |
+
break;
|
| 2520 |
+
}
|
| 2521 |
+
}
|
| 2522 |
+
|
| 2523 |
+
// ์นด๋๋ฅผ ์ฐพ์ง ๋ชปํ ๊ฒฝ์ฐ ์ง์ ์คํ
|
| 2524 |
+
if (!foundCard) {
|
| 2525 |
+
toggle(false);
|
| 2526 |
+
showLoading("PDF ์ค๋น ์ค...");
|
| 2527 |
+
|
| 2528 |
+
let pages = [];
|
| 2529 |
+
|
| 2530 |
+
// ์ด๋ฏธ ์บ์๋ ๊ฒฝ์ฐ ์บ์๋ ๋ฐ์ดํฐ ์ฌ์ฉ
|
| 2531 |
+
if (isCached) {
|
| 2532 |
+
try {
|
| 2533 |
+
const response = await fetch(`/api/cached-pdf?path=${encodeURIComponent(pdfPath)}`);
|
| 2534 |
+
const cachedData = await response.json();
|
| 2535 |
+
|
| 2536 |
+
if (cachedData.status === "completed" && cachedData.pages) {
|
| 2537 |
+
hideLoading();
|
| 2538 |
+
createFlipBook(cachedData.pages);
|
| 2539 |
+
// ํ์ฌ ์ด๋ฆฐ PDF์ ID ์ ์ฅ
|
| 2540 |
+
currentPdfId = pdfId;
|
| 2541 |
+
return;
|
| 2542 |
+
}
|
| 2543 |
+
} catch (error) {
|
| 2544 |
+
console.error("์บ์ ๋ฐ์ดํฐ ๋ก๋ ์คํจ:", error);
|
| 2545 |
+
}
|
| 2546 |
+
}
|
| 2547 |
+
|
| 2548 |
+
// ์ธ๋ค์ผ ๊ฐ์ ธ์ค๊ธฐ
|
| 2549 |
+
try {
|
| 2550 |
+
const thumbResponse = await fetch(`/api/pdf-thumbnail?path=${encodeURIComponent(pdfPath)}`);
|
| 2551 |
+
const thumbData = await thumbResponse.json();
|
| 2552 |
+
|
| 2553 |
+
if (thumbData.thumbnail) {
|
| 2554 |
+
pages = [{
|
| 2555 |
+
src: thumbData.thumbnail,
|
| 2556 |
+
thumb: thumbData.thumbnail,
|
| 2557 |
+
path: pdfPath,
|
| 2558 |
+
cached: isCached
|
| 2559 |
+
}];
|
| 2560 |
+
}
|
| 2561 |
+
} catch (error) {
|
| 2562 |
+
console.error("์ธ๋ค์ผ ๋ก๋ ์คํจ:", error);
|
| 2563 |
+
}
|
| 2564 |
+
|
| 2565 |
+
// ์ผ๋จ ๊ธฐ๋ณธ ํ์ด์ง ์ถ๊ฐ
|
| 2566 |
+
if (pages.length === 0) {
|
| 2567 |
+
pages = [{
|
| 2568 |
+
path: pdfPath,
|
| 2569 |
+
cached: isCached
|
| 2570 |
+
}];
|
| 2571 |
+
}
|
| 2572 |
+
|
| 2573 |
+
// ํ๋ก์ ํธ์ ์ถ๊ฐํ๊ณ ๋ทฐ์ด ์คํ
|
| 2574 |
+
const projectId = projects.push(pages) - 1;
|
| 2575 |
+
hideLoading();
|
| 2576 |
+
open(projectId);
|
| 2577 |
+
|
| 2578 |
+
// ํ์ฌ ์ด๋ฆฐ PDF์ ID ์ ์ฅ
|
| 2579 |
+
currentPdfId = pdfId;
|
| 2580 |
+
}
|
| 2581 |
+
} catch (error) {
|
| 2582 |
+
console.error("PDF ID๋ก ์ด๊ธฐ ์คํจ:", error);
|
| 2583 |
+
hideLoading();
|
| 2584 |
+
showError("PDF๋ฅผ ์ด ์ ์์ต๋๋ค. ๋ค์ ์๋ํด์ฃผ์ธ์.");
|
| 2585 |
+
}
|
| 2586 |
+
}
|
| 2587 |
+
|
| 2588 |
+
|
| 2589 |
|
| 2590 |
// ๊ด๋ฆฌ์ ํ์ด์ง ํ์
|
| 2591 |
async function showAdminPage() {
|