PageSourceSearch

https://press-herald.com/wp-content/plugins/real3d-flipbook/js/frontend.js

js press-herald.com collected 2026-10-02 07:59:51 UTC 5,567 bytes, 190 lines download raw bytes

1"use strict";
2
3window.addEventListener("DOMContentLoaded", function () {
4  r3d_frontend.options = flipbookOptions_global;
5  const withClass = r3d_frontend.options.convertPDFLinksWithClass;
6  const withoutClass = r3d_frontend.options.convertPDFLinksWithoutClass;
7
8  function findIncludedLinks(withClass) {
9    if (withClass) {
10      return document.querySelectorAll(
11        `.${withClass} a[href$=".pdf"], a.${withClass}[href$=".pdf"]`
12      );
13    } else {
14      return document.querySelectorAll('a[href$=".pdf"]');
15    }
16  }
17
18  function findExcludedLinks(withoutClass) {
19    if (withoutClass) {
20      return document.querySelectorAll(
21        `.${withoutClass} a[href$=".pdf"], a.${withoutClass}[href$=".pdf"]`
22      );
23    } else {
24      return [];
25    }
26  }
27
28  const includedLinks = findIncludedLinks(withClass);
29  const excludedLinks = findExcludedLinks(withoutClass);
30
31  const includedLinksArray = Array.from(includedLinks);
32  const excludedLinksSet = new Set(Array.from(excludedLinks));
33
34  const pdfLinks = includedLinksArray.filter(
35    (link) => !excludedLinksSet.has(link)
36  );
37
38  if (pdfLinks.length > 0) {
39    const rootFolder = r3d_frontend.rootFolder;
40    const options = r3d_frontend.options;
41
42    function convertStrings(obj) {
43      if (typeof obj === "object" && obj !== null) {
44        Object.entries(obj).forEach(([key, value]) => {
45          if (typeof value === "object" && value !== null) {
46            convertStrings(value);
47          } else {
48            if (!isNaN(value) && value !== "") {
49              obj[key] = Number(value);
50            } else if (value === "true") {
51              obj[key] = true;
52            } else if (value === "false") {
53              obj[key] = false;
54            } else if (value === "") {
55              delete obj[key];
56            }
57          }
58        });
59      }
60    }
61
62    convertStrings(options);
63
64    options.lightBox = true;
65    options.assets = {
66      preloader: rootFolder + "assets/images/preloader.jpg",
67      left: rootFolder + "assets/images/left.png",
68      overlay: rootFolder + "assets/images/overlay.jpg",
69      flipMp3: rootFolder + "assets/mp3/turnPage.mp3",
70      shadowPng: rootFolder + "assets/images/shadow.png",
71      spinner: rootFolder + "assets/images/spinner.gif",
72    };
73    options.pdfjsworkerSrc = rootFolder + "js/libs/pdf.worker.min.js";
74    options.flipbookSrc = rootFolder + "js/flipbook.min.js";
75    options.cMapUrl = rootFolder + "assets/cmaps/";
76
77    
78    var a = options.s,
79      b = 0;
80    if (!a) {
81      options.logoImg = rootFolder + "assets/images/logo_dark.png";
82      options.logoUrl = "https://real3dflipbook.com";
83      options.logoCSS =
84        "position:absolute;width:200px;margin:20px;top:0;right:0;";
85      options.logo = true;
86      b = 1;
87    }
88    
89
90    if (window.FLIPBOOK) {
91      pdfLinks.forEach((link, index) => createFlipbook(link, index, options));
92    } else {
93      Promise.all([
94        loadScript(
95          rootFolder + "js/flipbook.min.js?ver=" + r3d_frontend.version
96        ),
97        loadCSS(
98          rootFolder + "css/flipbook.min.css?ver=" + r3d_frontend.version
99        ),
100      ])
101        .then(() => {
102          pdfLinks.forEach((link, index) =>
103            createFlipbook(link, index + 1, options)
104          );
105        })
106        .catch((error) => {
107          console.error(
108            "An error occurred while loading the resources:",
109            error
110          );
111        });
112    }
113  }
114
115  function getOptionFromClass(element, optionName) {
116    while (element) {
117      if (element.classList) {
118        const matchingClass = Array.from(element.classList).find((cls) =>
119          cls.includes("r3d-" + optionName)
120        );
121        if (matchingClass) {
122          return matchingClass.replace("r3d-" + optionName + "-", "");
123        }
124      }
125      element = element.parentElement;
126    }
127    return false;
128  }
129
130  function createFlipbook(link, index, options) {
131    options.pdfUrl = link.href;
132    const deeplinkingPrefix = getOptionFromClass(link, "deeplinkingPrefix");
133    if (deeplinkingPrefix) {
134      options.deeplinkingPrefix = deeplinkingPrefix;
135    } else if (options.deeplinking && options.deeplinking.enabled) {
136      options.deeplinking.prefix = "book" + index + "_";
137    }
138    new FlipBook(link, options);
139  }
140
141  function loadScript(src) {
142    return new Promise(function (resolve, reject) {
143      var script = document.createElement("script");
144      var prior = document.getElementsByTagName("script")[0];
145      script.async = true;
146      script.src = src;
147
148      script.onload = script.onreadystatechange = function (_, isAbort) {
149        if (
150          isAbort ||
151          !script.readyState ||
152          /loaded|complete/.test(script.readyState)
153        ) {
154          script.onload = script.onreadystatechange = null;
155          script = undefined;
156
157          if (!isAbort) {
158            resolve();
159          }
160        }
161      };
162
163      script.onerror = function (error) {
164        reject(error);
165      };
166
167      prior.parentNode.insertBefore(script, prior);
168    });
169  }
170
171  function loadCSS(href) {
172    return new Promise(function (resolve, reject) {
173      var link = document.createElement("link");
174      var prior =
175        document.getElementsByTagName("link")[0] ||
176        document.getElementsByTagName("script")[0];
177      link.rel = "stylesheet";
178      link.href = href;
179
180      link.onload = () => resolve();
181      link.onerror = (error) => reject(error);
182
183      if (prior) {
184        prior.parentNode.insertBefore(link, prior);
185      } else {
186        document.head.appendChild(link);
187      }
188    });
189  }
190});

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.