1"use strict"; 2(function () { 3 document.addEventListener("DOMContentLoaded", function () { 4 var books = document.querySelectorAll(".real3dflipbook"); 5 if (books.length > 0) { 6 books.forEach(function (bookElement) { 7 var o = window["flipbookOptions_" + bookElement.id]; 8 var o_global = window["flipbookOptions_global"]; 9 10 function convertStrings(obj) { 11 Object.keys(obj).forEach(function (key) { 12 var value = obj[key]; 13 if ( 14 value === null || 15 value === undefined || 16 (Array.isArray(value) && value.length == 0) 17 ) 18 delete obj[key]; 19 else if (typeof value === "object") { 20 convertStrings(value); 21 } else if (!isNaN(value)) { 22 if (obj[key] === "") delete obj[key]; 23 else obj[key] = Number(value); 24 } else if (value === "true") { 25 obj[key] = true; 26 } else if (value === "false") { 27 obj[key] = false; 28 } 29 }); 30 } 31 32 var s = o.s; 33 convertStrings(o); 34 convertStrings(o_global); 35 36 function r3d_stripslashes(str) { 37 return (str + "").replace(/\\(.?)/g, function (s, n1) { 38 switch (n1) { 39 case "\\": 40 return "\\"; 41 case "0": 42 return "\u0000"; 43 case "": 44 return ""; 45 default: 46 return n1; 47 } 48 }); 49 } 50 51 function decode(obj) { 52 Object.keys(obj).forEach(function (key) { 53 if (typeof obj[key] === "string") 54 obj[key] = r3d_stripslashes(obj[key]); 55 else if (typeof obj[key] === "object") obj[key] = decode(obj[key]); 56 }); 57 return obj; 58 } 59 60 o = decode(o); 61 o_global = decode(o_global); 62 o.s = s; 63 64 65 var a = o.s; 66 if (!a) { 67 o.logoImg = o.rootFolder + "assets/images/logo_dark.png"; 68 o.logoUrl = "https://real3dflipbook.com"; 69 o.logoCSS = 70 "position:absolute;width:200px;margin:20px;top:0;right:0;"; 71 o.logo = true; 72 } 73 74 75 if (o.pages) { 76 if (!Array.isArray(o.pages)) { 77 var pages = []; 78 Object.keys(o.pages).forEach(function (key) { 79 pages[key] = o.pages[key]; 80 }); 81 o.pages = pages; 82 } 83 84 o.pages.forEach(function (page) { 85 if (page.htmlContent) page.htmlContent = unescape(page.htmlContent); 86 if (page.items) { 87 page.items.forEach(function (item, itemIndex) { 88 if (item.url) item.url = unescape(item.url); 89 }); 90 } 91 }); 92 } 93 94 o = FLIPBOOK.extend(true, {}, o_global, o); 95 96 o.assets = { 97 preloader: o.rootFolder + "assets/images/preloader.jpg", 98 left: o.rootFolder + "assets/images/left.png", 99 overlay: o.rootFolder + "assets/images/overlay.jpg", 100 flipMp3: o.rootFolder + "assets/mp3/turnPage.mp3", 101 shadowPng: o.rootFolder + "assets/images/shadow.png", 102 spinner: o.rootFolder + "assets/images/spinner.gif", 103 }; 104 105 o.pdfjsworkerSrc = 106 o.rootFolder + "js/libs/pdf.worker.min.js?ver=" + o.version; 107 o.flipbookSrc = o.rootFolder + "js/flipbook.min.js?ver=" + o.version; 108 o.cMapUrl = o.rootFolder + "assets/cmaps/"; 109 110 o.social = []; 111 112 if (o.btnDownloadPages && o.btnDownloadPages.url) { 113 o.btnDownloadPages.url = o.btnDownloadPages.url.replace(/\\/g, "/"); 114 } 115 116 if (o.btnDownloadPdf) { 117 if (o.btnDownloadPdfUrl) 118 o.btnDownloadPdf.url = o.btnDownloadPdfUrl.replace(/\\/g, "/"); 119 else if (o.btnDownloadPdf && o.btnDownloadPdf.url) 120 o.btnDownloadPdf.url = o.btnDownloadPdf.url.replace(/\\/g, "/"); 121 else if (o.pdfUrl) 122 o.btnDownloadPdf.url = o.pdfUrl.replace(/\\/g, "/"); 123 } 124 125 var bookContainer = bookElement; 126 var parentContainer = bookContainer.parentNode; 127 128 var isMobile = 129 /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( 130 navigator.userAgent 131 ) || 132 (navigator.maxTouchPoints && 133 navigator.maxTouchPoints > 2 && 134 /MacIntel/.test(navigator.platform)); 135 136 o.mode = isMobile && o.modeMobile ? o.modeMobile : o.mode; 137 138 o.doubleClickZoomDisabled = !o.doubleClickZoom; 139 o.pageDragDisabled = !o.pageDrag; 140 141 //options from url parameters 142 function getUrlVars() { 143 var vars = {}; 144 var parts = window.location.href.replace( 145 /[?&]+([^=&]+)=([^&]*)/gi, 146 function (m, key, value) { 147 vars[key] = value.split("#")[0]; 148 } 149 ); 150 return vars; 151 } 152
153 var urlParams = getUrlVars(); 154 155 Object.keys(urlParams).forEach(function (key) { 156 if (key.indexOf("r3d-") !== -1) 157 o[key.replace("r3d-", "")] = decodeURIComponent(urlParams[key]); 158 }); 159 160 o.shareImage = o.shareImage || o.lightboxThumbnailUrl; 161 162 var book; 163 164 function expandBasePath(o) { 165 if (!o || !o.basePath || !Array.isArray(o.pages)) return; 166 167 const base = o.basePath; 168 169 if (typeof base !== "string" || base.length < 8) return; 170 171 for (const page of o.pages) { 172 if (!page || typeof page !== "object") continue; 173 174 for (const key of ["src", "thumb", "json"]) { 175 if (!page[key] || typeof page[key] !== "string") continue; 176 177 const value = page[key]; 178 179 if (/^(https?:)?\/\//i.test(value)) continue; 180 181 if (value.startsWith(base)) continue; 182 183 page[key] = base + value; 184 } 185 } 186 } 187 expandBasePath(o); 188 189 switch (o.mode) { 190 case "normal": 191 bookContainer.className += "-" + bookContainer.id; 192 o.lightBox = false; 193 bookElement.style.position = "relative"; 194 bookElement.style.display = "block"; 195 bookElement.style.width = "100%"; 196 197 let width = bookContainer.getBoundingClientRect().width; 198 if (width < o.responsiveViewTreshold) { 199 bookContainer.style.height = width / 0.65 + "px"; 200 } else { 201 bookContainer.style.height = width / 1.3 + "px"; 202 } 203 204 book = new FlipBook(bookElement, o); 205 break; 206 case "lightbox": 207 bookElement.style.display = "inline"; 208 o.lightBox = true; 209 210 bookContainer.className += "-" + bookContainer.id; 211 bookElement.setAttribute("style", o.lightboxContainerCSS); 212 213 if (o.hideThumbnail) o.lightboxThumbnailUrl = ""; 214 215 o.lightboxText = o.lightboxText || ""; 216 217 if (o.showTitle) o.lightboxText += o.name; 218 if (o.showDate) o.lightboxText += o.date; 219 220 if (o.lightboxThumbnailUrl) { 221 if (location.protocol === "https:") 222 o.lightboxThumbnailUrl = o.lightboxThumbnailUrl.replace( 223 "http://", 224 "https://" 225 ); 226 else if (location.protocol === "http:") 227 o.lightboxThumbnailUrl = o.lightboxThumbnailUrl.replace( 228 "https://", 229 "http://" 230 ); 231 232 var thumbWrapper = document.createElement("div"); 233 thumbWrapper.setAttribute("style", "position: relative;"); 234 bookElement.appendChild(thumbWrapper); 235 236 var thumb = document.createElement("img"); 237 thumb.setAttribute("src", o.lightboxThumbnailUrl); 238 thumbWrapper.appendChild(thumb); 239 thumb.setAttribute("style", o.lightboxThumbnailUrlCSS); 240 241 if (o.thumbAlt) thumb.setAttribute("alt", o.thumbAlt); 242 243 if (o.lightboxThumbnailInfo) { 244 var defaultLightboxThumbnailInfoCSS = 245 "position: absolute; display: grid; align-items: center; text-align: center; top: 0; width: 100%; height: 100%; font-size: 16px; color: #000; background: rgba(255,255,255,.8); "; 246 247 var thumbInfo = document.createElement("span"); 248 thumbWrapper.appendChild(thumbInfo); 249 thumbInfo.setAttribute( 250 "style", 251 defaultLightboxThumbnailInfoCSS + o.lightboxThumbnailInfoCSS 252 ); 253 thumbInfo.textContent = o.lightboxThumbnailInfoText || o.name; 254 thumbInfo.style.display = "none"; 255 256 thumbWrapper.addEventListener("mouseenter", function () { 257 thumbInfo.style.display = "block"; 258 }); 259 260 thumbWrapper.addEventListener("mouseleave", function () { 261 thumbInfo.style.display = "none"; 262 }); 263 } 264 } 265 266 if (o.lightboxText && o.lightboxText !== "") { 267 var text = document.createElement("span"); 268 text.textContent = o.lightboxText; 269 var style = "text-align:center; padding: 10px 0;"; 270 style += o.lightboxTextCSS; 271 272 if (o.lightboxTextPosition === "top") { 273 bookElement.insertBefore(text, bookElement.firstChild); 274 } else { 275 bookElement.appendChild(text); 276 } 277 text.setAttribute("style", style); 278 } 279 280 if (!o.lightboxCssClass || o.lightboxCssClass === "") { 281 o.lightboxCssClass = bookContainer.className; 282 } else { 283 bookElement.classList.add(o.lightboxCssClass); 284 } 285 286 if (o.lightboxLink) { 287 document 288 .querySelectorAll("." + o.lightboxCssClass) 289 .forEach(function (el) { 290 el.addEventListener("click", function () { 291 var target = o.lightboxLinkNewWindow ? "_blank" : "_self"; 292 window.open(o.lightboxLink, target); 293 }); 294 }); 295 } else { 296 book = new FlipBook( 297 document.querySelectorAll("." + o.lightboxCssClass), 298 o 299 ); 300 } 301 break; 302 303 case "fullscreen": 304 o.lightBox = false; 305 document.body.appendChild(bookElement); 306 bookElement.classList.add("flipbook-browser-fullscreen"); 307 if ( 308 !( 309 "fullscreenEnabled" in document || 310 "webkitFullscreenEnabled" in document || 311 "mozFullScreenEnabled" in document 312 ) 313 ) { 314 o.btnExpand = { enabled: false }; 315 } 316 317 book = new FlipBook(bookElement, o); 318 document.body.style.overflow = "hidden"; 319 320 if (o.menuSelector) { 321 var menu = document.querySelector(o.menuSelector); 322 var height = window.innerHeight - menu.offsetHeight; 323 bookElement.style.top = menu.offsetHeight + "px"; 324 bookElement.style.height = height + "px"; 325 326 window.onresize = function () { 327 height = window.innerHeight - menu.offsetHeight; 328 bookElement.style.top = menu.offsetHeight + "px"; 329 bookElement.style.height = height + "px"; 330 }; 331 } 332 break; 333 } 334 335 336 if (book && book.on) { 337 book.on("r3d-update-note", function (e) { 338 sendAjax({ note: e.note }, "r3d_update_note"); 339 }); 340 341 book.on("r3d-delete-note", function (e) { 342 sendAjax({ note: e.note }, "r3d_delete_note"); 343 }); 344 345 if (book.options.resumeReading) { 346 bookElement.addEventListener("pagechange", function (e) { 347 sendAjax({ page: e.page.split("-")[0] }, "r3d_last_page"); 348 }); 349 } 350 } 351 352 function sendAjax(obj, action) { 353 var data = { 354 bookId: book.options.bookId, 355 action: action, 356 nonce: r3d.nonce, 357 };
358 Object.keys(obj).forEach(function (key) { 359 data[key] = obj[key]; 360 }); 361 362 var xhr = new XMLHttpRequest(); 363 xhr.open("POST", r3d.ajax_url, true); 364 xhr.setRequestHeader( 365 "Content-Type", 366 "application/x-www-form-urlencoded" 367 ); 368 369 var params = Object.keys(data) 370 .map(function (key) { 371 return ( 372 encodeURIComponent(key) + "=" + encodeURIComponent(data[key]) 373 ); 374 }) 375 .join("&"); 376 377 xhr.send(params); 378 } 379 380 }); 381 } 382 }); 383})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.