PageSourceSearch

https://penaflor.cl/wp-content/plugins/real3d-flipbook/js/frontend.js?ver=4.20

js penaflor.cl collected 2026-10-02 06:44:33 UTC 6,054 bytes, 209 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 getOptionsFromClasses(element) {
116    const options = {};
117
118    while (element) {
119      if (element.classList) {
120        Array.from(element.classList).forEach((cls) => {
121          if (cls.startsWith("r3d-")) {
122            const [, keyPart, ...valueParts] = cls.split("-");
123            if (keyPart && valueParts.length) {
124              const key = keyPart;
125              let value = valueParts.join("-");
126
127              if (value === "true") value = true;
128              else if (value === "false") value = false;
129              else if (!isNaN(value) && value.trim() !== "")
130                value = Number(value);
131
132              options[key] = value;
133            }
134          }
135        });
136      }
137      element = element.parentElement;
138    }
139
140    return options;
141  }
142
143  function createFlipbook(link, index, options) {
144    options.pdfUrl = link.href;
145
146    const classOptions = getOptionsFromClasses(link);
147    Object.assign(options, classOptions);
148
149    // Handle deeplinking prefix logic
150    if (options.deeplinkingPrefix) {
151      options.deeplinking = options.deeplinking || {};
152      options.deeplinking.prefix = options.deeplinkingPrefix;
153    } else if (options.deeplinking && options.deeplinking.enabled) {
154      options.deeplinking.prefix = "book" + index + "_";
155    }
156
157    new FlipBook(link, options);
158  }
159
160  function loadScript(src) {
161    return new Promise(function (resolve, reject) {
162      var script = document.createElement("script");
163      var prior = document.getElementsByTagName("script")[0];
164      script.async = true;
165      script.src = src;
166
167      script.onload = script.onreadystatechange = function (_, isAbort) {
168        if (
169          isAbort ||
170          !script.readyState ||
171          /loaded|complete/.test(script.readyState)
172        ) {
173          script.onload = script.onreadystatechange = null;
174          script = undefined;
175
176          if (!isAbort) {
177            resolve();
178          }
179        }
180      };
181
182      script.onerror = function (error) {
183        reject(error);
184      };
185
186      prior.parentNode.insertBefore(script, prior);
187    });
188  }
189
190  function loadCSS(href) {
191    return new Promise(function (resolve, reject) {
192      var link = document.createElement("link");
193      var prior =
194        document.getElementsByTagName("link")[0] ||
195        document.getElementsByTagName("script")[0];
196      link.rel = "stylesheet";
197      link.href = href;
198
199      link.onload = () => resolve();
200      link.onerror = (error) => reject(error);
201
202      if (prior) {
203        prior.parentNode.insertBefore(link, prior);
204      } else {
205        document.head.appendChild(link);
206      }
207    });
208  }
209});

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.