PageSourceSearch

https://www.footballtransfers.com/js/custom.js?v=35607570029-181

js footballtransfers.com collected 2026-09-24 20:47:52 UTC 13,646 bytes, 349 lines download raw bytes

1/* custom js */
2$('.header-bar .btn-toggle').click(function () {
3    $(this).toggleClass('change');
4    $('.header-bar nav').slideToggle().toggleClass('open');
5    if ($(".header-bar .btn-toggle").hasClass('change')) {
6        $("#header-part.new .header-bar .menu ul.main li").removeClass("active");
7    }
8});
9
10/*mobile menu*/
11if ($(document).width() < 1024) {
12    $("#header-part.new .header-bar .menu ul.main > li").click(function () {
13        if ($(this).hasClass('active')) {
14            $("#header-part.new .header-bar .menu ul.main li").removeClass("active");
15        } else {
16            $("#header-part.new .header-bar .menu ul.main li").removeClass("active");
17            $(this).addClass("active");
18        }
19    });
20
21    $(document).on('click', ".navigation2 .has-sub > a:not('.open')", function (e) {
22        e.preventDefault();
23        const parent = $(this).parent();
24        const link = $(this);
25        const nav = parent.find('.nav2__sub');
26        const navBar = $(this).parents('.navigation2');
27        const closeBtn = '<button type="button" class="btn-close-sub"><i class="fa fa-times"></i></button>';
28
29        $(this).addClass('open');
30        nav.clone().appendTo(navBar);
31        link.clone().prependTo('.navigation2 > .nav2__sub');
32        $('.navigation2 > .nav2__sub').prepend(closeBtn);
33    });
34
35    $(document).on('click', '.btn-close-sub, .navigation2 .has-sub > a.open', function (e) {
36        e.preventDefault();
37        $('.navigation2 .has-sub > a.open').removeClass('open');
38        $('.navigation2 > .nav2__sub').remove();
39    })
40}
41
42
43//SCROLL DOWN
44
45window.onscroll = function () { scrollDown() };
46window.onload = function () { scrollDown() };
47
48var navbar = document.getElementById("onlyMenu");
49var bodytop = document.getElementById("template");
50var sticky = navbar ? navbar.offsetTop : null;
51
52function scrollDown() {
53    if ($(document).width() > 1024) {
54        if (window.pageYOffset >= 90) {
55            $("body").addClass("sticky");
56        } else {
57            $("body").removeClass("sticky");
58        }
59    }
60}
61
62/**
63 * Replaces variables in the template.
64 * @param string template.
65 * @param object variables.
66 */
67function replaceInTemplate(template, variables) {
68    for (var key in variables) {
69        template = template.replaceAll(key, variables[key]);
70    }
71
72    return template;
73}
74
75const SI_SYMBOL = ["", "K", "M", "B", "T", "P", "E"];
76
77function abbreviateNumber(number) {
78    const tier = Math.log10(Math.abs(number)) / 3 | 0;
79
80    if (tier == 0) return number;
81
82    const suffix = SI_SYMBOL[tier];
83
84    if (suffix === 'B') {
85        return parseFloat((number / Math.pow(10, 2 * 3)).toFixed(1)) + 'M';
86    } else if (suffix === 'K' && Math.abs(number) >= Math.pow(10, 5) && Math.abs(number) < Math.pow(1000, 2)) { // >= 100k and < 1M
87        return (number / Math.pow(10, 5)) == Math.round(number / Math.pow(10, 5))
88            ? parseFloat((number / Math.pow(10, 2 * 3)).toFixed(1)) + 'M'
89            : parseFloat((number / Math.pow(10, 2 * 3)).toFixed(2)) + 'M';
90    }
91
92    const scale = Math.pow(10, tier * 3);
93    const scaled = number / scale;
94
95    return parseFloat(scaled.toFixed(1)) + suffix;
96}
97
98if (!String.prototype.replaceAll) {
99    String.prototype.replaceAll = function (s, f, r) { return s.split(f).join(r) };
100}
101
102if (!Array.prototype.every) {
103    Array.prototype.every = function (callbackfn, thisArg) {
104        'use strict';
105        var T, k;
106
107        if (this == null) {
108            throw new TypeError('this is null or not defined');
109        }
110
111        // 1. Let O be the result of calling ToObject passing the this
112        //    value as the argument.
113        var O = Object(this);
114
115        // 2. Let lenValue be the result of calling the Get internal method
116        //    of O with the argument "length".
117        // 3. Let len be ToUint32(lenValue).
118        var len = O.length >>> 0;
119
120        // 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
121        if (typeof callbackfn !== 'function' && Object.prototype.toString.call(callbackfn) !== '[object Function]') {
122            throw new TypeError();
123        }
124
125        // 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
126        if (arguments.length > 1) {
127            T = thisArg;
128        }
129
130        // 6. Let k be 0.
131        k = 0;
132
133        // 7. Repeat, while k < len
134        while (k < len) {
135
136            var kValue;
137
138            // a. Let Pk be ToString(k).
139            //   This is implicit for LHS operands of the in operator
140            // b. Let kPresent be the result of calling the HasProperty internal
141            //    method of O with argument Pk.
142            //   This step can be combined with c
143            // c. If kPresent is true, then
144            if (k in O) {
145                var testResult;
146                // i. Let kValue be the result of calling the Get internal method
147                //    of O with argument Pk.
148                kValue = O[k];
149
150                // ii. Let testResult be the result of calling the Call internal method
151                // of callbackfn with T as the this value if T is not undefined
152                // else is the result of calling callbackfn
153                // and argument list containing kValue, k, and O.
154                if (T) testResult = callbackfn.call(T, kValue, k, O);
155                else testResult = callbackfn(kValue, k, O)
156
157                // iii. If ToBoolean(testResult) is false, return false.
158                if (!testResult) {
159                    return false;
160                }
161            }
162            k++;
163        }
164        return true;
165    };
166}
167
168////
169$('.popover-container').each(function () {
170    const container = $(this);
171    const trigger = container.find('.popover-trigger');
172    const modal = container.find('.popover-modal');
173    const close = container.find('.popover-close');
174
175    let offset;
176    let offsetLeft;
177    let offsetRight;
178    let offsetTop;
179    let offsetBottom;
180
181    trigger.on('click', function () {
182        offset = container.offset();
183        offsetLeft = offset.left;
184        offsetRight = ($(window).width() - (offsetLeft + container.outerWidth()))
185        offsetTop = offset.top;
186        offsetBottom = ($(window).height() - (offsetTop + container.outerHeight()))
187
188        container.toggleClass('open');
189
190        if (offsetLeft <= offsetRight) {
191            modal.css({
192                'left': offsetLeft,
193            })
194        } else {
195            modal.css({
196                'right': offsetRight,
197            })
198        }
199
200        if (offsetTop <= offsetBottom) {
201            modal.css({
202                'top': (offsetTop + container.outerHeight()),
203            })
204        } else {
205            modal.css({
206                'bottom': (offsetBottom + container.outerHeight()),
207            })
208        }
209    })
210
211    close.on('click', function () {
212        container.removeClass('open');
213    })
214})
215
216
217// Custom Tooltip
218$(document).ready(function () {
219    $.fn.toolTip = function () {
220        return this.each(function () {
221            let $toolTip = $(".popup-player-container"),
222                changeTipPosition = function (event, action) {
223                    let $target = $(event.target);
224                    let xPos = parseFloat($target.offset().left) + (parseFloat($target.width()) / 2);
225                    let yPos = $target.offset().top + 25;
226
227                    $toolTip.css({
228                        top: (yPos - 230) + "px",
229                        left: (xPos - 150) + "px"
230                    });
231                },
232                showTip = function (event, action) {
233                    $toolTip.attr("aria-hidden", false);
234                    changeTipPosition(event, action);
235                },
236                hideTip = function () {
237                    $("[role=toolTip]").attr("aria-hidden", true);
238                };
239
240            $(this).on({
241                // mousemove: changeTipPosition, // Disables the tooltip following the mouse movement
242                mouseenter: showTip,
243                focus: function (event) {
244                    showTip(event, 'keyboard');
245                },
246                mouseleave: hideTip,
247                blur: hideTip
248            });
249        });
250    };
251});
252
253
254$(function () {
255    // Player Pop-up info on article page
256    let mainArticleLinks = $('.main-article a[data-player-toolTip=1]');
257    let deviceWidth = $(window).width();
258
259    if (deviceWidth > 767) {
260        mainArticleLinks.each(function (i) {
261            $(this).addClass('popup-player')
262                .attr('aria-haspopup', true)
263                .attr('aria-describedby', 'tip-' + i);
264
265            $('.popup-player').toolTip();
266
267            $(this).hover(function () {
268                $('.popup-player-container').attr('id', $(this).attr('aria-describedby'));
269
270                // Player Variables
271                let playerName = $(this).attr('title');
272                let skill = $(this).data('skill');
273                let pot = $(this).data('pot');
274                let position = $(this).data('position');
275                let estimates = $(this).data('estimates');
276                let xtvrange = $(this).data('xtvrange');
277                let team = $(this).data('team');
278                let teamImage = $(this).data('team-image');
279                let profileImage = $(this).data('profile-image');
280
281                // Replace short dash to a long hyphen
282                let xtvRangeNew = xtvrange?.replace('-', '—');
283
284                $('.player-image img').attr('src', profileImage);
285                $('.player-name').text(playerName);
286                $('.player-position').text(position);
287                $('.player-skill').text(skill);
288                $('.player-pot').text(pot);
289                $('.player-estimates').text(estimates);
290                $('.player-team').text(team);
291                $('.player-team-image').attr('src', teamImage);
292                $('.player-xtvrange').text(xtvRangeNew);
293
294                // Check player name character length
295                let playerNameLength = playerName.length;
296
297                if (playerNameLength > 24 && playerNameLength < 32) {
298                    $('.player-name').css('fontSize', '1.7vmin');
299                } else if (playerNameLength > 31 && playerNameLength < 37) {
300                    $('.player-name').css('fontSize', '1.5vmin');
301                } else if (playerNameLength > 36 && playerNameLength < 43) {
302                    $('.player-name').css('fontSize', '1.3vmin');
303                } else if (playerNameLength > 42 && playerNameLength < 52) {
304                    $('.player-name').css('fontSize', '1vmin');
305                } else if ( playerNameLength > 51) {
306                    $('.player-name').css({'fontSize': '0.9vmin', 'textOverflow' : 'ellipsis', 'width' : '200px', 'overflow': 'hidden' });
307                } else {
308                    $('.player-name').removeAttr('style');
309                }
310
311
312            }, function () {
313                $('.popup-player-container').removeAttr('id');
314                $('.player-name').removeAttr('style');
315            });
316        });
317    };
318
319});
320
321var Base64 = { _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", encode: function (r) { var e, t, o, a, h, d, C, c = "", f = 0; for (r = Base64._utf8_encode(r); f < r.length;)e = r.charCodeAt(f++), t = r.charCodeAt(f++), o = r.charCodeAt(f++), a = e >> 2, h = (3 & e) << 4 | t >> 4, d = (15 & t) << 2 | o >> 6, C = 63 & o, isNaN(t) ? d = C = 64 : isNaN(o) && (C = 64), c = c + this._keyStr.charAt(a) + this._keyStr.charAt(h) + this._keyStr.charAt(d) + this._keyStr.charAt(C); return c }, decode: function (r) { var e, t, o, a, h, d, C, c = "", f = 0; for (r = r.replace(/[^A-Za-z0-9\+\/\=]/g, ""); f < r.length;)a = this._keyStr.indexOf(r.charAt(f++)), h = this._keyStr.indexOf(r.charAt(f++)), d = this._keyStr.indexOf(r.charAt(f++)), C = this._keyStr.indexOf(r.charAt(f++)), e = a << 2 | h >> 4, t = (15 & h) << 4 | d >> 2, o = (3 & d) << 6 | C, c += String.fromCharCode(e), 64 != d && (c += String.fromCharCode(t)), 64 != C && (c += String.fromCharCode(o)); return Base64._utf8_decode(c) }, _utf8_encode: function (r) { var e = ""; r = r.replace(/\r\n/g, "\n"); for (var t = 0; t < r.length; t++) { var o = r.charCodeAt(t); o < 128 ? e += String.fromCharCode(o) : o > 127 && o < 2048 ? (e += String.fromCharCode(o >> 6 | 192), e += String.fromCharCode(63 & o | 128)) : (e += String.fromCharCode(o >> 12 | 224), e += String.fromCharCode(o >> 6 & 63 | 128), e += String.fromCharCode(63 & o | 128)) } return e }, _utf8_decode: function (r) { var e, t, o, a, h = "", d = 0; for (e = t = o = 0; d < r.length;)(e = r.charCodeAt(d)) < 128 ? (h += String.fromCharCode(e), d++) : e > 191 && e < 224 ? (h += String.fromCharCode((31 & e) << 6 | 63 & (o = r.charCodeAt(d + 1))), d += 2) : (h += String.fromCharCode((15 & e) << 12 | (63 & (o = r.charCodeAt(d + 1))) << 6 | 63 & (a = r.charCodeAt(d + 2))), d += 3); return h } };
322
323(function () {
324
325    function displayLazyLoadedImages() {
326        const images = document.querySelectorAll('img.lazyload[data-src]');
327        let count = 0;
328
329        images.forEach(img => {
330            const dataSrc = img.getAttribute('data-src');
331            if (!dataSrc) return;
332
333            img.setAttribute('src', dataSrc);
334            img.removeAttribute('data-src');
335            img.classList.remove('lazyload');
336
337            count++;
338        });
339
340        console.log(`Updated ${count} lazyload images.`);
341    }
342
343    if (document.readyState === 'loading') {
344        document.addEventListener('DOMContentLoaded', displayLazyLoadedImages);
345    } else {
346        // DOM already ready
347        displayLazyLoadedImages();
348    }
349})();

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.