PageSourceSearch

https://womensshinemag.com/wp-content/plugins/nextgen-gallery/stat…/nextgen_tiktok_helper.js?ver=4.2.2

js womensshinemag.com collected 2026-10-03 01:44:40 UTC 12,486 bytes, 259 lines download raw bytes

1(function($) {
2    "use strict";
3
4    window.NextGEN_TikTok = {
5        extract_id: function(url) {
6            if (!url) return null;
7            url = url.trim();
8
9            var patterns = [
10                /tiktok\.com\/@[^\/]+\/video\/(\d+)/i,
11                /tiktok\.com\/v\/(\d+)/i,
12                /tiktok\.com\/embed\/v2\/(\d+)/i,
13                /tiktok\.com\/.*[?&]v=(\d+)/i,
14                /\/video\/(\d+)/i,
15                /^(\d{15,25})$/,
16            ];
17
18            for (var i = 0; i < patterns.length; i++) {
19                var match = url.match(patterns[i]);
20                if (match && match[1]) {
21                    return match[1];
22                }
23            }
24
25            if (url.match(/vm\.tiktok\.com|tiktok\.com\/t\//i)) {
26                var idMatch = url.match(/(\d{15,25})/);
27                if (idMatch) {
28                    return idMatch[1];
29                }
30                return null;
31            }
32
33            return null;
34        },
35
36        create_player: function(videoUrl, containerClass, videoClass) {
37            var container = document.createElement("div");
38            container.className = containerClass || "ngg-tiktok-container";
39
40            var video = document.createElement("video");
41            video.className = videoClass || "ngg-tiktok-video";
42            video.controls = true;
43            video.autoplay = true;
44            video.playsInline = true;
45            video.muted = true;
46            video.loop = true;
47            video.preload = "auto";
48            video.setAttribute("playsinline", "");
49            video.setAttribute("webkit-playsinline", "");
50            video.src = videoUrl;
51
52            video.addEventListener("loadedmetadata", function () {
53                var naturalWidth = video.videoWidth;
54                var naturalHeight = video.videoHeight;
55
56                if (naturalWidth && naturalHeight) {
57                    var container = video.closest('.ngg-tiktok-container');
58                    var displayWidth = naturalWidth;
59                    var displayHeight = naturalHeight;
60
61                    if (container) {
62                        var fancyboxContent = container.closest('#fancybox-content');
63                        var tbWindow = container.closest('#TB_window');
64                        var slImage = container.closest('.sl-image');
65                        var shWrap = container.closest('#shWrap');
66
67                        if (shWrap) {
68                            var wiH = window.innerHeight || 0;
69                            var dbH = document.body.clientHeight || 0;
70                            var deH = document.documentElement ? document.documentElement.clientHeight : 0;
71                            var wHeight;
72
73                            if (wiH > 0) {
74                                wHeight = ((wiH - dbH) > 1 && (wiH - dbH) < 30) ? dbH : wiH;
75                                wHeight = ((wHeight - deH) > 1 && (wHeight - deH) < 30) ? deH : wHeight;
76                            } else {
77                                wHeight = (deH > 0) ? deH : dbH;
78                            }
79
80                            if (document.getElementsByTagName("body")[0].className.match(/admin-bar/)
81                                && document.getElementById('wpadminbar') !== null) {
82                                wHeight = wHeight - document.getElementById('wpadminbar').offsetHeight;
83                            }
84
85                            var shHeight = wHeight - 50;
86                            var deW = document.documentElement ? document.documentElement.clientWidth : 0;
87                            var dbW = window.innerWidth || document.body.clientWidth;
88                            var wWidth = (deW > 1) ? deW : dbW;
89
90                            // Apply EXACT same scaling logic as Shutter images (lines 239-249)
91                            if (displayHeight > shHeight) {
92                                displayWidth = displayWidth * (shHeight / displayHeight);
93                                displayHeight = shHeight;
94                            }
95                            if (displayWidth > (wWidth - 16)) {
96                                displayHeight = displayHeight * ((wWidth - 16) / displayWidth);
97                                displayWidth = wWidth - 16;
98                            }
99
100                            video.style.width = displayWidth + "px";
101                            video.style.height = displayHeight + "px";
102                            video.style.maxWidth = "none";
103                            video.style.maxHeight = "none";
104                            video.setAttribute("width", displayWidth);
105                            video.setAttribute("height", displayHeight);
106                        } else if (fancyboxContent) {
107                            setTimeout(function() {
108                                var contentRect = fancyboxContent.getBoundingClientRect();
109                                if (contentRect.width > 10 && contentRect.height > 10) {
110                                    var maxW = contentRect.width;
111                                    var maxH = contentRect.height;
112
113                                    if (displayWidth > maxW || displayHeight > maxH) {
114                                        var ratio = displayWidth / displayHeight > maxW / maxH
115                                            ? displayWidth / maxW
116                                            : displayHeight / maxH;
117                                        displayWidth = displayWidth / ratio;
118                                        displayHeight = displayHeight / ratio;
119                                    }
120
121                                    video.style.width = displayWidth + "px";
122                                    video.style.height = displayHeight + "px";
123                                    video.setAttribute("width", displayWidth);
124                                    video.setAttribute("height", displayHeight);
125                                }
126                            }, 50);
127                            return;
128                        } else if (tbWindow) {
129                            // Thickbox: replicate EXACT same image sizing logic from thickbox.js lines 204-224
130                            var pageWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
131                            var pageHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
132                            var x = pageWidth - 150;  // Same as Thickbox: pagesize[0] - 150
133                            var y = pageHeight - 150; // Same as Thickbox: pagesize[1] - 150
134
135                            if (displayWidth > x) {
136                                displayHeight = displayHeight * (x / displayWidth);
137                                displayWidth = x;
138                                if (displayHeight > y) {
139                                    displayWidth = displayWidth * (y / displayHeight);
140                                    displayHeight = y;
141                                }
142                            } else if (displayHeight > y) {
143                                displayWidth = displayWidth * (y / displayHeight);
144                                displayHeight = y;
145                                if (displayWidth > x) {
146                                    displayHeight = displayHeight * (x / displayWidth);
147                                    displayWidth = x;
148                                }
149                            }
150
151                            video.style.width = displayWidth + "px";
152                            video.style.height = displayHeight + "px";
153                            video.setAttribute("width", displayWidth);
154                            video.setAttribute("height", displayHeight);
155                        } else if (slImage) {
156                            var widthRatio = 0.8;
157                            var heightRatio = 0.9;
158                            var windowWidth = window.innerWidth;
159                            var windowHeight = window.innerHeight;
160                            var maxWidth = windowWidth * widthRatio;
161                            var maxHeight = windowHeight * heightRatio;
162
163                            if (displayWidth > maxWidth || displayHeight > maxHeight) {
164                                var ratio = displayWidth / displayHeight > maxWidth / maxHeight
165                                    ? displayWidth / maxWidth
166                                    : displayHeight / maxHeight;
167                                displayWidth /= ratio;
168                                displayHeight /= ratio;
169                            }
170
171                            video.style.width = displayWidth + "px";
172                            video.style.height = displayHeight + "px";
173                            video.style.maxWidth = maxWidth + "px";
174                            video.style.maxHeight = maxHeight + "px";
175                        }
176                    }
177                }
178            });
179
180            video.addEventListener("canplay", function () {
181                video.play().catch(function () {});
182            });
183
184            container.appendChild(video);
185            return container;
186        },
187
188        handle_content: function(options) {
189            var self = this;
190            var playUrl = options.playUrl;
191            var $targetContainer = $(options.container);
192
193            if (!playUrl) return null;
194
195            var tiktokContent = null;
196
197            var applyDimensions = function (el) {
198                if (options.width) {
199                    var w = typeof options.width === "number" ? options.width + "px" : options.width;
200                    el.style.width = w;
201                    var inner = el.querySelector("video, iframe, .ngg-tiktok-error-content");
202                    if (inner) inner.style.width = "100%";
203                }
204                if (options.height) {
205                    var h = typeof options.height === "number" ? options.height + "px" : options.height;
206                    el.style.height = h;
207                    var inner = el.querySelector("video, iframe, .ngg-tiktok-error-content");
208                    if (inner) inner.style.height = "100%";
209                }
210            };
211
212            if (playUrl) {
213                var decodedUrl = playUrl;
214                try {
215                    decodedUrl = decodeURIComponent(playUrl);
216                } catch (e) {}
217
218                tiktokContent = self.create_player(decodedUrl, options.containerClass, options.videoClass);
219                if (tiktokContent) {
220                    applyDimensions(tiktokContent);
221                    var video = tiktokContent.querySelector("video");
222                    if (video) {
223                        video.onerror = function () {
224                            $(tiktokContent).remove();
225                            var errorMsg = self.create_error("Video failed to load", options.errorClass);
226                            applyDimensions(errorMsg);
227                            if (typeof options.onBeforeAppend === "function") o
227ptions.onBeforeAppend(errorMsg);
228                            $targetContainer.append(errorMsg);
229                        };
230                    }
231                    if (typeof options.onBeforeAppend === "function") options.onBeforeAppend(tiktokContent);
232                    $targetContainer.append(tiktokContent);
233                }
234            } else {
235                var errorMsg = self.create_error("Video not available", options.errorClass);
236                applyDimensions(errorMsg);
237                if (typeof options.onBeforeAppend === "function") options.onBeforeAppend(errorMsg);
238                $targetContainer.append(errorMsg);
239                tiktokContent = errorMsg;
240            }
241
242            return tiktokContent;
243        },
244
245        create_error: function(message, containerClass) {
246            var container = document.createElement("div");
247            container.className = containerClass || "ngg-tiktok-error";
248            container.innerHTML =
249                '<div class="ngg-tiktok-error-content">' +
250                '<span class="ngg-tiktok-error-icon">&#9888;</span>' +
251                '<span class="ngg-tiktok-error-text">' +
252                (message || "Video failed to load") +
253                "</span>" +
254                "</div>";
255            return container;
256        }
257    };
258})(jQuery);
259

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.