PageSourceSearch

https://www.scientology-madrid.es/theme/gsc_headers/generic-utils-before-doc-ready.js?_=9d8f7badc

js scientology-madrid.es collected 2026-09-26 16:14:48 UTC 16,752 bytes, 482 lines download raw bytes

1/**
2@file
3Generic JS util functions useful for the responsive slideshow.
4No dependencies.
5Should be included after the slideshow DOM, as early as possible.
6*/
7
8
9//<script>
10
11if (!window.responsiveSliderDetermineFirstSlide) {
12
13    
14    
15    function responsiveSliderDetermineFirstSlide() {
16
17        if (window.globalSlideshowOptionsOverride && globalSlideshowOptionsOverride.startSlide) {
18            return globalSlideshowOptionsOverride.startSlide;
19        }
20
21        
22        if (!document.querySelectorAll || !Array.prototype.reduce) return;
23
24        
25        if (globalGetParams.video || globalGetParams['video-play']) {
26
27            var videoParam = globalGetParams.video || globalGetParams['video-play'];
28            var mySlides = document.querySelectorAll('#header .slideshow-main slide');
29            var slideMatching = Array.prototype.reduce.call(
30                document.querySelectorAll('#header .slideshow-main slide .video-js'),
31                function(m, v) {
32                    if (m != null) return m;
33                    var parentSlide = window._getParentForType && _getParentForType(v, 'SLIDE');
34                    for (var i = 0; i < mySlides.length; i++) {
35                        if (mySlides[i] == parentSlide) {
36                            if (_getVideoIdForSlide(mySlides, i) == videoParam) return i;
37                            break;
38                        }
39                    }
40                },
41                null
42            );
43
44            if (slideMatching !== void 0) return parseInt(slideMatching) + 1;
45            
46            
47            if (globalGetParams.slide) return globalGetParams.slide;
48            
49            
50            return 1;
51
52        }
53
54        if (location.hash) {
55            var newSlideIdx = parseInt(location.hash.substring(1).replace(/slide/, '')) - 1;
56            if (!isNaN(newSlideIdx) && newSlideIdx >= 0 && newSlideIdx <= document.querySelectorAll('#header slide').length - 1) {
57                return newSlideIdx + 1;
58        }
59        }
60
61        
62        return 1;
63
64    }
65
66}
67
68if (!window._slideToSlideId) {
69
70    
71    function _slideToSlideId(slidesIdx) {
72        var deltaX = (isRTL ? -1 : 1) * (slidesIdx-1) * 100;
73        var slideHolder = document.querySelector('#header .slideshow-main .slide-holder');
74        if (!slideHolder) return;
75        setTransform(slideHolder, 'translate3d(calc(' + (-deltaX) + '% - ' + (deltaX / 2) + 'px), 0, 0)');
76    }
77
78}
79
80if (!window.setTransform) {
81
82    
83    
84    function setTransform(elem, transform) {
85        elem.style.MozTransform = transform;  
86        elem.style.msTransform = transform;  
87        elem.style.OTransform = transform;  
88        elem.style.WebkitTransform = transform;  
89        elem.style.transform = transform;   
90    }
91
92}
93
94if  (!window.cookieMonster) {
95
96    
97
98    var cookieMonster = {
99        get: function (sKey) {
100            return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null;
101        },
102        set: function (sKey, sValue, vEnd, sPath, sDomain, bSecure) {
103            if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) { return false; }
104            var sExpires = "";
105            if (vEnd) {
106                switch (vEnd.constructor) {
107                    case Number:
108                        sExpires = vEnd === Infinity ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; max-age=" + vEnd;
109                        break;
110                    case String:
111                        sExpires = "; expires=" + vEnd;
112                        break;
113                    case Date:
114                        sExpires = "; expires=" + vEnd.toUTCString();
115                        break;
116                }
117            }
118            document.cookie = encodeURIComponent(sKey) + "=" + encodeURIComponent(sValue) + sExpires + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "") + (bSecure ? "; secure" : "");
119            return true;
120        },
121        remove: function (sKey, sPath, sDomain) {
122            if (!sKey || !this.has(sKey)) { return false; }
123            document.cookie = encodeURIComponent(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT" + ( sDomain ? "; domain=" + sDomain : "") + ( sPath ? "; path=" + sPath : "");
124            return true;
125        },
126        has: function (sKey) {
127            return (new RegExp("(?:^|;\\s*)" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie);
128        }
129    };
130
131}
132
133
134function slideshowCaptionsOverflow() {
135
136    
137    if (document.body.className.match(/authoring-true/)) return;
138
139    
140    
141
142    if(document.documentElement.lang == "zh" && document.location.pathname == "/scientology-today/events/new-years-2017.html") {
143        
144        return true;
145    }
146
147    [].forEach.call(document.querySelectorAll('#header_slideshow_wraper .slide-templated-new .item.text-item'), function(v) {
148        
149        if (v.className.match(/caption-overflow-adjusted/)) {
150            v.classList.remove('caption-overflow-adjusted');
151            var full = v.parentNode.querySelector('.slider-captions-more-full');
152
153            if (full) {
154                v.innerHTML = full.innerHTML;
155                $(full).parent('slide').find('.text-item').show();
156                full.parentNode.removeChild(full);
157                v.offsetTop;
158            }
159        }
160
161        if (v.offsetHeight < v.scrollHeight) {
162
163            var origCont = v.innerHTML,
164                tempSlideCaptionAdjusted= false;
165
166            for (var infiniteGuard = 200; infiniteGuard > 0; infiniteGuard--) {
167
168                
169
170                var cont = v.innerHTML.replace(new RegExp('... <a[^>]*>' + (window.moreTexti18n ? moreTexti18n : 'more') + ' »<.a>.*$'), '');
171
172
173                
174                cont = cont.replace(/&[a-z]+;$/, '');
175
176                
177                var lastDivider = Math.max(cont.lastIndexOf(' '), cont.lastIndexOf('.'), cont.lastIndexOf(','), cont.lastIndexOf('。'), cont.lastIndexOf('、'), cont.lastIndexOf('・'));
178
179                if (lastDivider < 1) {
180                    
181                    window.console && console.error && console.error('could not break this string: ' + origCont);
182                    v.innerHTML = origCont;
183                    break;
184                }
185
186                var newCont = cont.substring(0, lastDivider);
187                
188                
189                var tempElem = document.createElement('DIV');
190                tempElem.innerHTML = newCont;
191                newCont = tempElem.innerHTML;
192
193                if (cont == newCont) {
194                    window.console && console.error && console.error('no change:');
195                    window.console && console.error && console.error(cont);
196                    window.console && console.error && console.error(newCont);
197                    break;
198                }
199
200                v.innerHTML = newCont + '... <a href="#" class="slider-captions-more">' + (window.moreTexti18n ? moreTexti18n : 'more') + ' »</a>';
201
202                
203                v.offsetTop;
204                if (v.offsetHeight >= v.scrollHeight) {
205                    v.classList.add('caption-overflow-adjusted');
206
207                    v.insertAdjacentHTML('afterend', '<span class="slider-captions-more-full ignore-zoom item">' + origCont + '<div class="close-full-caption">'+closeTexti18n+'<span class="glyphicon glyphicon-remove-circle"></span></div></span>');
208                    tempSlideCaptionAdjusted = true;
209                    break;
210                }
211                
212            };
213
214            if (!tempSlideCaptionAdjusted) 
215                window.console && console.error && console.error('could not break this string: ' + origCont);
216
217        }
218
219    });
220}
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237var effectivePixelRatio = 1;
238if (window.devicePixelRatio) {
239    if (window.devicePixelRatio > 1.0 && window.devicePixelRatio <= 1.5) {
240        effectivePixelRatio = 1.5;
241    } else if (window.devicePixelRatio > 1.5) {
242        
243        effectivePixelRatio = 2;
244    }
245}
246
247
248var deviceCustomType = 'tablet';
249if (screen.height > 1024 || screen.width > 1024 || /Trident/.test(navigator.userAgent))  {
250    deviceCustomType = 'desktop';
251} else if (screen.height < 768 && screen.width < 768) {
252    deviceCustomType = 'mobile';
253}
254
255if (document.documentElement) document.documentElement.className += ' device-custom-type-' + deviceCustomType;
256
257
258function determineImageSize(imageDom) {
259
260    if (!imageDom.getAttribute('data-height')) {
261        if(window.location.pathname == "/") {
262            return [[800, 450], [2*800, 2*450]];
263        }
264
265        window.console && console.error && console.error('no data-height specified:');
266        window.console && console.error && console.error(imageDom && imageDom.outerHTML);
267
268        
269        return [[860, 575], [2*860, 2*575]];
270    }
271
272    var imageRelativeDims = [parseInt(imageDom.getAttribute('data-width')) / 860, parseInt(imageDom.getAttribute('data-height')) / 575];
273
274    
275    if (deviceCustomType == 'desktop' && effectivePixelRatio == 1) {
276        return [
277            [Math.round(imageRelativeDims[0] * 860), Math.round(imageRelativeDims[1] * 575)],
278            
279            
280            [Math.round(imageRelativeDims[0] * 860), Math.round(imageRelativeDims[1] * 575)]
281        ];
282    }
283
284    
285    if (deviceCustomType == 'desktop') {
286        return [
287            [Math.round(imageRelativeDims[0] * 860 * effectivePixelRatio), Math.round(imageRelativeDims[1] * 575 * effectivePixelRatio)],
288            [Math.round(imageRelativeDims[0] * 860 * effectivePixelRatio), Math.round(imageRelativeDims[1] * 575 * effectivePixelRatio)]
289        ];
290    }
291
292    
293    if (deviceCustomType == 'tablet') {
294        return [
295            [Math.round(imageRelativeDims[0] * 860 * effectivePixelRatio), Math.round(imageRelativeDims[1] * 575 * effectivePixelRatio)],
296            [Math.round(imageRelativeDims[0] * 860 * Math.max(1.5, effectivePixelRatio)), Math.round(imageRelativeDims[1] * 575 * Math.max(1.5, effectivePixelRatio))]
297        ];
298    }
299
300    
301    return [
302        
303        [Math.round(imageRelativeDims[0] * 680 * effectivePixelRatio), Math.round(imageRelativeDims[1] * 454 * effectivePixelRatio)],
304        [Math.round(imageRelativeDims[0] * 680 * effectivePixelRatio), Math.round(imageRelativeDims[1] * 454 * effectivePixelRatio)]
305    ];
306
307}
308
309function determineImageSourcesFromPrebuilt(imageDom, imgSizes) {
310    if (!imageDom || !imageDom.getAttribute || !window.JSON || !JSON.parse) return;
311
312    var serializedSources = imageDom.getAttribute('data-prebuilt-responsive-sources');
313    if (!serializedSources) return;
314
315    try {
316        var responsiveSources = JSON.parse(serializedSources);
317        var primarySrc = responsiveSources[String(imgSizes[0][0])];
318        if (!primarySrc) return;
319
320        return [primarySrc, responsiveSources[String(imgSizes[1][0])] || primarySrc];
321    } catch (err) {
322        window.console && console.error && console.error('bad prebuilt responsive sources:');
323        window.console && console.error && console.error(serializedSources);
324    }
325}
326
327
328function determineImageSources(imageDom) {
329    
330    if (!imageDom || !imageDom.getAttribute || !imageDom.getAttribute('data-src')) {
331        window.console && console.error && console.error('cannot get image source, no data-src specified:');
332        window.console && console.error && console.error(imageDom);
333        return;
334    }
335
336    var imgSrc = imageDom.getAttribute('data-src');
337    var qaOverride = getParameterByName('qa');
338    if (qaOverride) {
339        imgSrc = imgSrc.replace(/@qa=85/, '@qa='+qaOverride);
340    }
341
342    
343    if(imgSrc.indexOf('overrideW')===-1) {
344        imgSrc = imgSrc.replace(/@w=[0-9\.]+/, '');
345    }
346    imgSrc = imgSrc.replace(/@h=[0-9\.]+/, '');
347
348                
349    var imgSizes = determineImageSize(imageDom);
350    var prebuiltSources = determineImageSourcesFromPrebuilt(imageDom, imgSizes);
351    if (prebuiltSources) return prebuiltSources;
352
353    if (imgSrc.match(/cropfit@/)) {
354        return [imgSrc.replace(/cropfit@/, 'cropfit@w=' + imgSizes[0][0] + '@'), imgSrc.replace(/cropfit@/, 'cropfit@w=' + imgSizes[1][0] + '@')];
355    } else if (imgSrc.match(/cropfit/)) {
356        return [imgSrc.replace(/cropfit/, 'cropfit@w=' + imgSizes[0][0]), imgSrc.replace(/cropfit/, 'cropfit@w=' + imgSizes[1][0])];
357    } else {
358        window.console && console.error && console.error('non-cropfit image: ' + imgSrc);
359        return [imgSrc, imgSrc.replace(/temp-color-tests/, 'temp-color-tests/retina')];
360    }
361
362}
363
364
365
366function slideshowPreloadFirstSlide() {
367
368    
369    
370
371    
372    document.querySelector && new function() {
373    
374        var firstImage = document.querySelector('slide img[data-src]');
375        var firstSlide = document.querySelector('slide');
376
377        if (window.responsiveSliderDetermineFirstSlide) {
378            var firstSlideNum = responsiveSliderDetermineFirstSlide();
379            firstSlide = document.querySelector('slide:nth-child(' + (firstSlideNum+1) + ')');
380            firstImage = document.querySelector('slide:nth-child(' + (firstSlideNum+1) + ') img[data-src]');
381        }
382
383        
384        if (firstSlide) firstSlide.className += ' fso-slide-active ';
385        
386        if (firstImage) {
387
388            if (firstSlide.querySelector('.image-holder') && window.determineImageSources) {
389
390                firstSlide.className += ' js-starting-slide';
391
392                [].forEach.call(firstSlide.querySelectorAll('.image-holder'), function(imgHolder) {
393
394                    
395                    
396                    
397
398                    imgHolder.className += ' js-dynamic-size-set';
399                    imgHolder.style.height = (Math.ceil(parseFloat(imgHolder.getAttribute('data-height')) / 575 * 1000000) / 10000) + '%';
400                    imgHolder.style.width = (Math.ceil(parseFloat(imgHolder.getAttribute('data-width')) / 860 * 1000000) / 10000) + '%';
401
402                    
403                    var theImage = imgHolder.querySelector('img');
404                    theImage.addEventListener && theImage.addEventListener('load', function() {
405                        imgHolder.classList && imgHolder.classList.remove('js-preview');
406                    });
407                    theImage.src = determineImageSources(theImage)[0];
408                    theImage.className += ' loaded';
409
410                    
411
412                });
413
414                if (firstSlide.querySelectorAll('.image-holder') && firstSlide.querySelectorAll('.image-holder').length == 1) firstSlide.className += ' js-single-image-slide';
415
416                document.querySelector('.slideshow-wrapper').className += ' js-slideshow-preinited';
417
418            } else {
419                [].forEach.call(firstSlide.querySelectorAll('img'), function(theImage) {
420                    theImage.src = theImage.getAttribute('data-src');
421 
422                    
423                    
424                    
425                });
426
427            }                        
428        }
429    }
430
431}
432
433
434
435
436
437
438function slideshowPrepare() {
439
440    
441    if (document.querySelectorAll && document.querySelectorAll('.slide-holder slide').length == 1)
442        document.getElementById('header_slideshow_wraper').classList.add('slideshow-only-one-slide');
443
444    
445    if (window.responsiveSliderDetermineFirstSlide) {
446        var firstSlide = responsiveSliderDetermineFirstSlide();
447        _slideToSlideId(firstSlide);
448    }
449
450    
451    if (document.querySelector && !document.querySelector('.slide-holder slide'))
452        document.querySelector('.slideshow-wrapper.slideshow-main').parentNode.removeChild(document.querySelector('.slideshow-wrapper.slideshow-main'));
453
454    
455    if (
456            window.deviceCustomType == 'desktop' &&
457            document.body.className.match(/templated-slider-build-2-1/) && 
458            (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) > 767 &&
459            (
460                (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) < 1025 ||
461                !document.body.className.match(/locale-en/) ||
462                document.body.className.match(/path-scientology-today-church-openings/)
463                || document.body.className.match(/path-inside-our-church/)
464            ) &&
465            window.slideshowCaptionsOverflow
466       ) {
467        slideshowCaptionsOverflow();
468    }
469
470}
471function getParameterByName(name, url) {
472    if (!url) url = window.location.href;
473    name = name.replace(/[\[\]]/g, "\\$&");
474    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
475        results = regex.exec(url);
476    if (!results) return null;
477    if (!results[2]) return '';
478    return decodeURIComponent(results[2].replace(/\+/g, " "));
479}
480
481
482//</script>

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.