PageSourceSearch

https://www.turkloydu.org/scripts/global-scripts.js?v=WP8Eg7eiLImN6EKz0ef1ugvbrbgJZ7_rd9kZiU9mCVQ

js turkloydu.org collected 2026-09-24 20:19:15 UTC 3,845 bytes, 134 lines download raw bytes

1if (typeof (Global) === "undefined") {
2    Global = {__namespace: true};
3}
4
5$(function() {
6    if ($('#page-sidebar').length === 0) {
7        $('#btnSidebarMobileToggler').remove();
8    }
9
10    if($('.main-slider').length === 0) {
11        $('.page-wrapper').addClass('mobile-container');
12    }
13
14    setClientIpAddress();
15});
16
17Global.UI = {
18    setSelect: function (_id, _url) {
19        $(_id).select2({
20            placeholder: "Choose option...",
21            allowClear: true,
22            minimumInputLength: 2,
23            theme: 'bootstrap-5',
24            ajax: {
25                url: _url,
26                data: function (params) {
27                    return {
28                        terms: params.term
29                    };
30                },
31                processResults: function (result) {
32                    return {
33                        results: $.map(result.data, function (item) {
34                            return {
35                                id: item.id,
36                                text: item.name
37                            }
38                        })
39                    }
40                }
41            }
42        });
43    },
44    populateSelect: function (element, data, placeholder, callback) {
45        element.empty();
46        element.append('<option value="">' + placeholder + '</option>');
47        for (let i = 0; i < data.length; i++) {
48            element.append('<option value="' + data[i].id + '">' + data[i].name + '</option>');
49        }
50        if (callback) {
51            callback();
52        }
53    },
54    toggleSubmitButton: function(id, value) {
55        if (value) {
56            $(id).prop('disabled', true);
57            $(`${id} > span`).removeClass("d-none");
58        } else {
59            $(id).prop('disabled', false);
60            $(`${id} > span`).addClass("d-none");
61        }
62    }
63}
64
65Global.Validation = {
66    isEmptyOrWhiteSpace: function (str) {
67        if (str === undefined || str === null || str === "Invalid date") {
68            return true;
69        } else {
70
71            const value = str.toString();
72            return value.match(/^ *$/) !== null;
73        }
74    }
75};
76
77$("#btnSubmitNewsletter").on("click", function (e) {
78    subscribeNewsletter();
79});
80
81$("#btnSubmitFooterNewsletter").on("click", function (e) {
82    subscribeNewsletter();
83});
84
85$('#inputEmail').on("keypress", function (e) {
86    const key = e.which;
87    if (key === 13)  // the enter key code
88    {
89        subscribeNewsletter();
90        return false;
91    }
92});
93
94function subscribeNewsletter() {
95    const page = document.location.href;
96    $.ajax({
97        type: "POST",
98        url: "https://api.turkloydu.org/iys/member/newsletter/subscribe",
99        contentType: "application/json; charset=utf-8",
100        headers: {
101            'x-client-ip': localStorage.getItem('clientIpAddress')
102        },
103        data: JSON.stringify({
104            emailAddress: $("#inputEmailAddress").val(),
105            source: page
106        }),
107        dataType: "json",
108        success: function (response) {
109            $("#divNewsletterSubscriptionErrorMessage").addClass("d-none");
110            $("#divNewsletterSubscriptionSuccessMessage").removeClass("d-none");
111
112            $("#inputEmailAddress").val(null);
113        },
114        error: function (ex) {
115            $("#divNewsletterSubscriptionSuccessMessage").addClass("d-none");
116            $("#divNewsletterSubscriptionErrorMessage").removeClass("d-none");
117            $("#divNewsletterSubscriptionErrorMessage").html(ex.responseJSON.errorMessage);
118        }
119    });
120}
121
122function setClientIpAddress() {
123    $.ajax({
124        type: "GET",
125        url: "https://geolocation-db.com/json/",
126        dataType: "json",
127        success: function (response) {
128            localStorage.setItem('clientIpAddress', response.IPv4);
129        },
130        error: function (ex) {
131
132        }
133    });
134}

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.