css
2 years ago
images
2 years ago
js
2 years ago
sounds
2 years ago
templates
2 years ago
viewer.html
2 years ago
viewer.html
131 lines
| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | |
| 4 | <head> |
| 5 | <title>Debugging</title> |
| 6 | <meta charset="utf-8" /> |
| 7 | </head> |
| 8 | |
| 9 | <body> |
| 10 | <style type="text/css"> |
| 11 | body { |
| 12 | margin: 0; |
| 13 | padding: 0; |
| 14 | } |
| 15 | |
| 16 | .viewer-container { |
| 17 | height: 100vh; |
| 18 | width: 100%; |
| 19 | } |
| 20 | |
| 21 | .fullscreen { |
| 22 | background-color: #333; |
| 23 | } |
| 24 | </style> |
| 25 | |
| 26 | <div class="viewer-container" id="viewer-container"></div> |
| 27 | |
| 28 | <script src="../../../../../wp-includes/js/jquery/jquery.js"></script> |
| 29 | <script src="js/html2canvas.min.js"></script> |
| 30 | <script src="js/three.min.js"></script> |
| 31 | <script src="js/pdf.min.js"></script> |
| 32 | <script src="js/3dflipbook.min.js"></script> |
| 33 | |
| 34 | <script type="text/javascript"> |
| 35 | var template = { |
| 36 | html: "templates/book-view.html", |
| 37 | links: [], |
| 38 | styles: ["css/ep-black-book-view.css"], |
| 39 | script: "js/default-book-view.js", |
| 40 | sounds: { |
| 41 | startFlip: "sounds/start-flip.mp3", |
| 42 | endFlip: "sounds/end-flip.mp3", |
| 43 | }, |
| 44 | }; |
| 45 | </script> |
| 46 | |
| 47 | <script> |
| 48 | // Ensure the script runs after the page has fully loaded |
| 49 | |
| 50 | // Function to extract the file URL from the query parameters |
| 51 | function extractFileParamData(src, $param) { |
| 52 | // Parse the URL |
| 53 | var url = new URL(src); |
| 54 | // Extract the 'file' parameter from the query string |
| 55 | var fileUrl = url.searchParams.get($param); |
| 56 | return fileUrl; |
| 57 | } |
| 58 | |
| 59 | var parentIframeSrc; |
| 60 | |
| 61 | var params = {}; |
| 62 | |
| 63 | window.onload = function () { |
| 64 | // Access the parent window |
| 65 | var parentWindow = window.parent; |
| 66 | |
| 67 | // Get the iframes within the parent window |
| 68 | var iframes = parentWindow.document.getElementsByTagName("iframe"); |
| 69 | |
| 70 | for (var i = 0; i < iframes.length; i++) { |
| 71 | if (iframes[i].contentWindow === window) { |
| 72 | // Get the src attribute of the iframe |
| 73 | parentIframeSrc = iframes[i].src; |
| 74 | |
| 75 | // Book 1 { |
| 76 | jQuery("#viewer-container").FlipBook({ |
| 77 | pdf: extractFileParamData(parentIframeSrc, "file"), |
| 78 | template: template, |
| 79 | }); |
| 80 | |
| 81 | // The encoded string you want to decode |
| 82 | const encodedString = extractFileParamData(parentIframeSrc, "key"); |
| 83 | |
| 84 | // Step 1: Base64 Decode |
| 85 | const decodedString = atob(encodedString); |
| 86 | |
| 87 | // Step 1: Create URLSearchParams object |
| 88 | const urlParams = new URLSearchParams(decodedString); |
| 89 | |
| 90 | // Step 2: Convert URLSearchParams to Object |
| 91 | const paramsObject = {}; |
| 92 | for (const [key, value] of urlParams.entries()) { |
| 93 | params[key] = |
| 94 | value == "yes" || value == "true" |
| 95 | ? true |
| 96 | : value == "no" |
| 97 | ? false |
| 98 | : value; |
| 99 | } |
| 100 | |
| 101 | |
| 102 | const newSettings = decodedString; |
| 103 | |
| 104 | let oldData = localStorage.getItem("flipbook_settings"); |
| 105 | let settingsArray; |
| 106 | |
| 107 | try { |
| 108 | settingsArray = oldData ? JSON.parse(oldData) : []; |
| 109 | if (!Array.isArray(settingsArray)) { |
| 110 | settingsArray = []; |
| 111 | } |
| 112 | } catch (e) { |
| 113 | settingsArray = []; |
| 114 | } |
| 115 | |
| 116 | settingsArray.push(newSettings); |
| 117 | |
| 118 | let newData = JSON.stringify(settingsArray); |
| 119 | localStorage.setItem("flipbook_settings", newData); |
| 120 | |
| 121 | let updatedData = localStorage.getItem("flipbook_settings"); |
| 122 | |
| 123 | |
| 124 | break; // Exit the loop once the matching iframe is found and processed |
| 125 | } |
| 126 | } |
| 127 | }; |
| 128 | </script> |
| 129 | </body> |
| 130 | |
| 131 | </html> |