PageSourceSearch

https://everinsuranceglobal.com/wp-content/plugins/wordpress-count…ountry-selector-public.js?ver=6ab5ea0095ce6

js everinsuranceglobal.com collected 2026-09-25 03:27:17 UTC 12,385 bytes, 389 lines download raw bytes

1(function( $ ) {
2	'use strict';
3
4	// Create the defaults once
5	var pluginName = "countrySelector",
6		defaults = {
7			country_selector_modal: "#country_selector_modal",
8			country_selector_modal_close: ".country_selector_modal_close",
9			modal_backdrop: ".modal-backdrop",
10			country_selector_modal_stay: ".country_selector_modal_stay",
11			
12			country_selector_modal_page: "#country_selector_modal_page",
13			country_selector_modal_page_show: "#country_selector_modal_page_show",
14			country_selector_modal_page_close: "#country_selector_modal_page_close",
15			country_selector_modal_goto: ".country_selector_modal_goto",
16			country_selector_modal_flag: ".country_selector_modal_flag",
17			cookie_lifetime: 60,
18		};
19
20	// The actual plugin constructor
21	function Plugin ( element, options ) {
22		this.element = element;
23		this.settings = $.extend( {}, defaults, options );
24		this._defaults = defaults;
25
26		this._name = pluginName;
27		this.init();
28	}
29
30	// Avoid Plugin.prototype conflicts
31	$.extend( Plugin.prototype, {
32		init: function() {
33			var that = this;
34			this.window = $(window);
35			this.documentHeight = $( document ).height();
36			this.windowHeight = this.window.height();
37
38            var botPattern = "/bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|crawl|spider/";
39            var re = new RegExp(botPattern, 'i');
40
41            if (re.test(navigator.userAgent)) {
42                return false;
43            }
44
45			if(!this.isEmpty($(this.settings.country_selector_modal_page))){
46				this.initPageModal();
47			}
48			this.initContinentSelector();
49			this.getUsersCountry();
50			this.getUsersLanguage();
51			this.initDropdown();
52			this.saveCountrySelection();
53				
54		},
55		initModal: function(modal) {
56			var that = this;
57			var country_selector_modal = $(this.settings.country_selector_modal);
58			var country_selector_modal_close = $(this.settings.country_selector_modal_close);
59			var country_selector_modal_stay = this.settings.country_selector_modal_stay;
60			var country_selector_modal_goto = this.settings.country_selector_modal_goto;
61			var country_selector_modal_flag = this.settings.country_selector_modal_flag;
62
63			var modal_title = country_selector_modal.find('.modal-title');
64			var modal_text = country_selector_modal.find('.country_selector_modal_text');
65			var modal_buttons = country_selector_modal.find('.country_selector_modal_buttons');
66			var modal_countries = country_selector_modal.find('.country_selector_modal_countries');
67
68			modal_title.html(modal.modal_header);
69			modal_text.html(modal.modal_text);
70			modal_buttons.html(modal.modal_buttons);
71			modal_countries.html(modal.modal_countries);		
72
73			if(this.isEmpty(this.getCookie('country_selector_modal_cookie')) || this.getParameterByName('country') === "debug") {
74		    	country_selector_modal.show();
75			    country_selector_modal.modal('show');
76			}
77
78		    country_selector_modal_close.on('click', function(){
79		    	country_selector_modal.hide();
80		    	$('.modal-backdrop').remove();
81			    country_selector_modal.modal('hide');
82			    country_selector_modal.removeClass('show');
83		    });
84
85		    country_selector_modal.on('click', country_selector_modal_stay, function(e){
86			    e.preventDefault();
87			    var href = this.href;
88			    that.createCookie('country_selector_modal_cookie', 'false', that.settings.cookie_lifetime);		    
89		    	country_selector_modal.hide();
90		    	$('.modal-backdrop').remove();
91			    country_selector_modal.modal('hide');
92			    country_selector_modal.removeClass('show');
93		    });
94
95			country_selector_modal.on('click', country_selector_modal_goto, function(e){
96			    e.preventDefault();
97			    var href = this.href;
98				that.createCookie('country_selector_modal_cookie', 'false', that.settings.cookie_lifetime);		    
99		    	window.location = href;
100		    });
101
102			country_selector_modal.on('click', country_selector_modal_flag, function(e){
103			    e.preventDefault();
104			    var href = this.href;
105				that.createCookie('country_selector_modal_cookie', 'false', that.settings.cookie_lifetime);		    
106		    	window.location = href;
107		    });
108
109			country_selector_modal.on('hide.bs.modal', function (e) {
110				that.createCookie('country_selector_modal_cookie', 'false', that.settings.cookie_lifetime);
111			});
112		},
113		initPageModal: function(callback) {
114			var that = this;
115			var country_selector_modal_page = $(this.settings.country_selector_modal_page);
116			var country_selector_modal_page_show = $(this.settings.country_selector_modal_page_show);
117			var country_selector_modal_page_close = $(this.settings.country_selector_modal_page_close);
118
119			country_selector_modal_page_show.on('click', function(e){
120				e.preventDefault();
121		    	country_selector_modal_page.show();
122			    country_selector_modal_page.modal('show');
123		    });
124			
125
126		    country_selector_modal_page_close.on('click', function(){
127		    	country_selector_modal_page.hide();
128		    	$('.modal-backdrop').remove();
129			    country_selector_modal_page.modal('hide');
130		    });
131		},
132		initContinentSelector: function() {
133			var country_selector_continent = $('.country_selector_continent');
134			var continent_to_show;
135
136			country_selector_continent.on('click', function(e) {
137				e.preventDefault();
138				continent_to_show = $(this).data('continent');
139
140				$('.country_selector_countries_by_continent').fadeOut();
141				$('.country_selector_countries_' + continent_to_show).fadeIn();
142			});
143		},
144		checkCountrySelector: function(countryCode) {
145			var that = this;
146
147			var sites_locale = $('html').attr('lang');
148			var url = window.location.href;
149			var lang = that.getUsersLanguage();
150
151			$.ajax({
152				url: that.settings.ajax_url,
153				type: 'post',
154				dataType: 'JSON',
155				data: {
156					action: 'check_country_selector',
157					country: countryCode,
158					// url: url,
159					lang: lang,
160					sites_locale: sites_locale,
161				},
162				success : function( response ) {
163
164					if(that.getParameterByName('country') === "debug") {
165						console.log(response);
166					}
167					
168					var URLchoosen = that.getCookie('country_selector_url');
169					if(response.is_default && 
170						URLchoosen && 
171						that.settings.redirectOnCookie == "1" 
172						&& that.getParameterByName('redirect') !== "false"
173						&& URLchoosen !== response.users_url
174					) {
175						window.location.replace(URLchoosen);
176					}
177					
178					if( (response.show_popup === "1") || (that.getParameterByName('country') === "debug")) {
179
180						if(response.force_redirect === "1") {
181
182							if(response.force_redirect_exclude_logged_in === "1" && response.logged_in === "1") {
183
184							} else {
185								if(response.force_redirect_seconds === "0") {
186									 window.location.replace(response.target_URL);
187									 return;
188								} else {
189									var seconds = parseInt(response.force_redirect_seconds) * 1000;
190									setTimeout(function() {
191										window.location.replace(response.target_URL);
192									}, seconds);
193								}
194							}
195						}
196
197						that.initModal(response);
198					}
199				},
200				error: function(jqXHR, textStatus, errorThrown) {
201				    console.log(jqXHR);
202				    console.log(textStatus);
203				    console.log(errorThrown);
204				}
205			});
206		},
207		getUsersCountry : function() {
208			var that = this;
209
210			var countryCodeExists = that.getCookie('country_selector_country_code');
211			if(countryCodeExists && that.getParameterByName('country') !== "debug") {
212				that.checkCountrySelector(countryCodeExists);
213				return;
214			}
215
216			if(that.settings.ipGeolocation == "1") {
217
218				var url = "https://get.geojs.io/v1/ip/geo.json";
219				$.ajax({
220					// url: "https://ip.nf/me.json",
221					url: url,
222					type: 'get',
223					dataType: 'json',
224					success : function( response ) {
225						if(that.getParameterByName('country') === "debug") {
226							console.log(response);
227						}
228
229						that.createCookie('country_selector_country_code', response.country_code, that.settings.cookie_lifetime);
230
231						that.checkCountrySelector(response.country_code);
232					},
233					error: function(jqXHR, textStatus, errorThrown) {
234					    console.log(jqXHR);
235					    console.log(textStatus);
236					    console.log(errorThrown);
237					}
238		        });
239
240			} else {
241
242				var browserLang = that.getUsersLanguage();
243				if(browserLang.length == 5) {
244
245					if(that.settings.useLanguageInsteadOfCountry == "1") {
246						var countryCode = browserLang.substring(0,2);
247					} else {
248						var countryCode = browserLang.substring(3,5);
249					}
250					
251				} else {
252					var countryCode = browserLang.substring(0,2);
253				}
254
255				countryCode = countryCode.toUpperCase();
256				if(countryCode == "EN") {
257					countryCode = "US";
258				}
259				that.createCookie('country_selector_country_code', countryCode, that.settings.cookie_lifetime);
260				that.checkCountrySelector(countryCode);
261			}
262
263
264        },
265        getUsersLanguage : function() {
266        	return navigator.language || navigator.userLanguage; 
267        },
268        initDropdown : function() {
269
270        	var continentSelect = $('.country_selector_continents_dropdown select');
271        	var countriesSelect = $('.country_selector_countries_dropdown select');
272        	var dropdownButton = $('#country_selector_dropdown_button');
273
274        	continentSelect.on('change', function(e){
275        		var continentSelected = $(this).val();
276        		
277        		$('.country_selector_countries_dropdown').fadeOut();
278        			$('#country_selector_countries_dropdown_' + continentSelected).fadeIn();	
279        	});
280        	
281        	countriesSelect.on('change', function(e){
282        		var countrySelected = $(this).val();
283        		
284        		if(countrySelected !== "") {
285        			dropdownButton.removeClass('disabled').attr('href', countrySelected);
286        		} else {
287        			dropdownButton.addClass('disabled').attr('href', '#');
288        		}
289        	});
290
291        	if (jQuery.fn.select2) {
292	        	$('.wordpress-country-selector-dropdown-select').select2().on('select2:select', function (e) {
293				    
294				    var url = $(this).val();
295				    if(url != "") {
296				    	window.location.replace(url);
297				    }
298				});
299			}
300
301        },
302        saveCountrySelection : function() {
303
304        	var that = this;
305
306        	$(document).on('click', '.country_selector_modal_goto, .country_selector_modal_stay, .country_selector_country a, .country_selector_modal_flag', function(e) {
307        		var $this = $(this);
308        		var url = $this.attr('href');
309
310        		if(url == "") {
311        			return false;
312        		}
313
314        		that.createCookie('country_selector_url', url, that.settings.cookie_lifetime);		    
315        	});
316
317    	},
318		//////////////////////
319		///Helper Functions///
320		//////////////////////
321		isEmpty: function(obj) {
322
323		    if (obj == null)		return true;
324		    if (obj.length > 0)		return false;
325		    if (obj.length === 0)	return true;
326
327		    for (var key in obj) {
328		        if (hasOwnProperty.call(obj, key)) return false;
329		    }
330
331		    return true;
332		},
333		sprintf: function parse(str) {
334		    var args = [].slice.call(arguments, 1),
335		        i = 0;
336
337		    return str.replace(/%s/g, function() {
338		        return args[i++];
339		    });
340		},
341		getCookie: function(cname) {
342		    var name = cname + "=";
343		    var ca = document.cookie.split(';');
344		    for(var i=0; i<ca.length; i++) {
345		        var c = ca[i];
346		        while (c.charAt(0)==' ') c = c.substring(1);
347		        if (c.indexOf(name) === 0) return c.substring(name.length, c.length);
348		    }
349		    return "";
350		},
351		createCookie: function(name, value, days) {
352			var expires = "";
353
354		    if (days) {
355		        var date = new Date();
356		        date.setTime(date.getTime()+(days * 24 * 60 * 60 * 1000));
357		        var expires = "; expires="+date.toGMTString();
358		    }
359
360		    document.cookie = name + "=" + value+expires + "; path=/";
361		},
362		getParameterByName: function(name, url) {
363		    if (!url) url = window.location.href;
364		    name = name.replace(/[\[\]]/g, "\\$&");
365		    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)", "i"),
366		        results = regex.exec(url);
367		    if (!results) return null;
368		    if (!results[2]) return '';
369		    return decodeURIComponent(results[2].replace(/\+/g, " "));
370		}
371	} );
372
373	// Constructor wrapper
374	$.fn[ pluginName ] = function( options ) {
375		return this.each( function() {
376			if ( !$.data( this, "plugin_" + pluginName ) ) {
377				$.data( this, "plugin_" +
378					pluginName, new Plugin( this, options ) );
379			}
380		} );
381	};
382
383	$(document).ready(function() {
384
385		$('body').countrySelector(country_selector_options);
386
387	} );
388
389})( jQuery );

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.