ginipick commited on
Commit
fa9425b
ยท
verified ยท
1 Parent(s): ac7995e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +320 -127
app.py CHANGED
@@ -1584,18 +1584,113 @@ HTML = """
1584
  // ํ˜„์žฌ ์—ด๋ฆฐ PDF์˜ ID
1585
  let currentPdfId = null;
1586
 
1587
- /* ๐Ÿ”Š ์˜ค๋””์˜ค unlock โ€“ ๋‚ด์žฅ Audio ์™€ ๊ฐ™์€ MP3 ๊ฒฝ๋กœ ์‚ฌ์šฉ */
1588
- ['click','touchstart'].forEach(evt=>{
1589
- document.addEventListener(evt,function u(){new Audio('static/turnPage2.mp3')
1590
- .play().then(a=>a.pause()).catch(()=>{});document.removeEventListener(evt,u,{capture:true});},
1591
- {once:true,capture:true});
1592
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1593
 
1594
  /* โ”€โ”€ ์œ ํ‹ธ โ”€โ”€ */
1595
  function $id(id){return document.getElementById(id)}
1596
 
1597
  // ํŒŒ์ผ ์—…๋กœ๋“œ ์ด๋ฒคํŠธ ์ฒ˜๋ฆฌ
1598
- document.addEventListener("DOMContentLoaded", function() {
 
1599
  console.log("DOM ๋กœ๋“œ ์™„๋ฃŒ, ์ด๋ฒคํŠธ ์„ค์ • ๏ฟฝ๏ฟฝ์ž‘");
1600
 
1601
  // PDF ์—…๋กœ๋“œ ๋ฒ„ํŠผ
@@ -2175,129 +2270,137 @@ function addCard(i, thumb, title, isCached = false, pdfId = null) {
2175
  }
2176
  }
2177
 
2178
- function createFlipBook(pages) {
2179
- console.log('FlipBook ์ƒ์„ฑ ์‹œ์ž‘. ํŽ˜์ด์ง€ ์ˆ˜:', pages.length);
 
 
 
 
 
 
 
 
2180
 
2181
- try {
2182
- // ํ™”๋ฉด ๋น„์œจ ๊ณ„์‚ฐ
2183
- const calculateAspectRatio = () => {
2184
- const windowWidth = window.innerWidth;
2185
- const windowHeight = window.innerHeight;
2186
- const aspectRatio = windowWidth / windowHeight;
2187
-
2188
- // ๋„ˆ๋น„ ๋˜๋Š” ๋†’์ด ๊ธฐ์ค€์œผ๋กœ ์ตœ๋Œ€ 90% ์ œํ•œ
2189
- let width, height;
2190
- if (aspectRatio > 1) { // ๊ฐ€๋กœ ํ™”๋ฉด
2191
- height = Math.min(windowHeight * 0.9, windowHeight - 40);
2192
- width = height * aspectRatio * 0.8; // ๊ฐ€๋กœ ํ™”๋ฉด์—์„œ๋Š” ์•ฝ๊ฐ„ ์ค„์ž„
2193
- if (width > windowWidth * 0.9) {
2194
- width = windowWidth * 0.9;
2195
- height = width / (aspectRatio * 0.8);
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() {