PageSourceSearch

https://www.marset.com/wp-content/themes/marset/js/geo.js

js marset.com collected 2026-10-01 14:39:57 UTC 10,020 bytes, 203 lines download raw bytes

1let globalCountryPromise;
2
3function initGeoLangPopup(countryCode) {
4  if (Cookies.get('geo_popup_shown')) return;
5
6  const usaCountries = ['US', 'CA'];
7  const isUsaLang = jQuery('body').hasClass('lang-usa');
8  const isUsaCountry = usaCountries.includes(countryCode);
9
10  let popup = null;
11  if (!isUsaLang && isUsaCountry) {
12    popup = jQuery('#geo-popup-us');
13  } else if (isUsaLang && !isUsaCountry) {
14    popup = jQuery('#geo-popup-eu');
15  }
16  if (!popup || !popup.length) return;
17
18  const backdrop = jQuery('#geo-popup-backdrop');
19
20  function dismiss() {
21    popup.fadeOut(150);
22    backdrop.fadeOut(150);
23    Cookies.set('geo_popup_shown', '1', { expires: 2, path: '/' });
24  }
25
26  popup.removeAttr('hidden').fadeIn(200);
27  backdrop.removeAttr('hidden').fadeIn(200);
28
29  popup.find('.geo-popup__dismiss').on('click', function (e) {
30    e.preventDefault();
31    dismiss();
32  });
33  popup.find('.geo-popup__button').on('click', dismiss);
34  backdrop.on('click', dismiss);
35}
36
37async function fetchVisitorGEO() {
38  globalCountryPromise = new Promise(async (resolve) => {
39    const response = await fetch('https://geolocalization.marset.workers.dev/');
40    const { city, country, ip_addr } = await response.json();
41    resolve(country);
42
43    // Push geolocation data to datalayer
44    window.dataLayer = window.dataLayer || [];
45    window.dataLayer.push({
46      'event': 'geolocationInfo',
47      'city': city,
48      'country': country
49    });
50  });
51}
52
53jQuery(document).ready(function ($) {
54
55    fetchVisitorGEO();
56  
57    globalCountryPromise.then((country) => {
58      console.log('Location:', country);
59      const countryCode = country;
60      jQuery('body').addClass('geo-' + countryCode);
61      //document.cookie = 'countryCode=' + countryCode + ';path=/';
62
63      initGeoLangPopup(countryCode);
64
65      $('.custom_field_country_select').val(countryCode);
66      $(".custom_field_country_nl_select option[value='" + countryCode + "'").addClass('selected');
67      $('.custom_field_country_nl_select').val(countryCode);
68      //$('.page-template-visita-virtual .your-country select').val(country); //full-name?
69    
70      // professionals
71      if ($('.custom_field_country_select').length) {
72        $('#wppb-form-element-31, #wppb-form-element-30, #wppb-form-element-28').removeClass('country-is-usa')
73        if (countryCode == 'US' && $(this).val() == 'US') {
74          $('#wppb-form-element-31, #wppb-form-element-30, #wppb-form-element-28').addClass('country-is-usa')
75        }
76        $('.custom_field_country_select').on('change', function () {
77          if ($(this).val() == 'US') {
78            $('#wppb-form-element-31, #wppb-form-element-30, #wppb-form-element-28').addClass('country-is-usa')
79          } else {
80            $('#wppb-form-element-31, #wppb-form-element-30, #wppb-form-element-28').removeClass('country-is-usa')
81          }
82        })
83      }
84  
85      //DETECTAR PAIS 'BUY NOW' BUTTON
86      if (countryCode.length) {
87        if (countryCode == 'US') {
88          $('.button-wrap.geodetect.usa').addClass('country-is-usa');
89        } else {
90          $('.button-wrap.geodetect.eur').addClass('country-isnt-usa');
91        }
92      } else {
93        $('.button-wrap.geodetect.eur').addClass('country-isnt-usa');
94      }
95  
96      //REVISAR QUAN PODEM DESACTIVAR COMPLETAMENT AQUESTA CAMPANYA I BORRAR
97      if ($('body').hasClass('postid-95530') || $('body').hasClass('postid-94487')) {
98        if (countryCode == 'ES') {
99          var $links = 'https://www.domesticoshop.com/lampara-followme-colores.html';
100          var randomLink = $links.split(',');
101          var $link = randomLink[Math.floor(Math.random() * randomLink.length)];
102        } else if (countryCode == 'NL') {
103          var $links = 'https://www.flinders.nl/marset-followme-tafellamp-led1';
104          var randomLink = $links.split(',');
105          var $link = randomLink[Math.floor(Math.random() * randomLink.length)];
106        } else if (countryCode == 'DE') {
107          var $links = 'https://www.light11.de/marset/followme.html,https://www.ikarus.de/follow-me-led-tischleuchte.html,https://www.design-bestseller.de/marset-follow-me-leuchte.html';
108          var randomLink = $links.split(',');
109          var $link = randomLink[Math.floor(Math.random() * randomLink.length)];
110        } else if (countryCode == 'GB') {
111          var $links = 'https://www.thelightsource.co.uk/light/marset/a657-031,https://www.davidvillagelighting.co.uk/product/Marset-Follow-Me-LED-Lamp/15142,https://www.nest.co.uk/product/marset-followme-lamp';
112          var randomLink = $links.split(',');
113          var $link = randomLink[Math.floor(Math.random() * randomLink.length)];
114        } else if (countryCode == 'FR' || countryCode == 'BE') {
115          var $links = 'https://www.dmlights.com/marset_followme_portable_and_usb_rechargeable_white___wood~0AYIC';
116          var randomLink = $links.split(',');
117          var $link = randomLink[Math.floor(Math.random() * randomLink.length)];
118        } else if (countryCode == 'US') {
119          var $links = 'https://www.marset.com/usa/light-fixtures/portable-lamps/followme-table/';
120          var randomLink = $links.split(',');
121          var $link = randomLink[Math.floor(Math.random() * randomLink.length)];
122          var $about_price = 'FollowMe by Inma Bermúdez, $245 + taxes';
123          var $price = 'Shop Now – $245';
124          $('.pre-title').html($about_price);
125          $('.geolink.with-price').html($price);
126        } else {
127          var $link = 'https://www.marset.com/en/buy-design-lamps/';
128        }
129        var $link = 'https://www.marset.com/en/buy-design-lamps/';
130        $('.geolink').attr('href', $link);
131      }
132      if ($('body').hasClass('postid-95533') || $('body').hasClass('postid-94336')) {
133        if (countryCode == 'ES') {
134          var $links = 'https://www.domesticoshop.com/lampara-chispa.html';
135          var randomLink = $links.split(',');
136          var $link = randomLink[Math.floor(Math.random() * randomLink.length)];
137        } else if (countryCode == 'NL') {
138          var $links = 'https://www.light11.eu/marset/chispa-battery-light-led.html';
139          var randomLink = $links.split(',');
140          var $link = randomLink[Math.floor(Math.random() * randomLink.length)];
141        } else if (countryCode == 'DE') {
142          var $links = 'https://www.light11.de/marset/chispa-akkuleuchte-led.html';
143          var randomLink = $links.split(',');
144          var $link = randomLink[Math.floor(Math.random() * randomLink.length)];
145        } else if (countryCode == 'GB') {
146          var $links = 'https://www.thelightsource.co.uk/light/marset/a703-002';
147          var randomLink = $links.split(',');
148          var $link = randomLink[Math.floor(Math.random() * randomLink.length)];
149        } else if (countryCode == 'FR' || countryCode == 'BE') {
150          var $links = 'https://www.dmlights.com/marset_chispa_table_lamp_black~1CM2U';
151          var randomLink = $links.split(',');
152          var $link = randomLink[Math.floor(Math.random() * randomLink.length)];
153        } else if (countryCode == 'US') {
154          var $links = 'https://www.marset.com/usa/light-fixtures/portable-lamps/chispa/';
155          var randomLink = $links.split(',');
156          var $link = randomLink[Math.floor(Math.random() * randomLink.length)];
157          var $about_price = 'Chispa by Joan Gaspar, $220 + taxes';
158          var $price = 'Shop Now – $220';
159          $('.pre-title').html($about_price);
160          $('.geolink.with-price').html($price);
161        } else {
162          var $link = 'https://www.marset.com/en/buy-design-lamps/';
163        }
164        var $link = 'https://www.marset.com/en/buy-design-lamps/';
165        $('.geolink').attr('href', $link);
166      }
167      if ($('body').hasClass('postid-95532') || $('body').hasClass('postid-94400')) {
168        if (countryCode == 'ES') {
169          var $links = 'https://www.domesticoshop.com/lampara-bicoca.html';
170          var randomLink = $links.split(',');
171          var $link = randomLink[Math.floor(Math.random() * randomLink.length)];
172        } else if (countryCode == 'NL') {
173          var $links = 'https://www.flinders.nl/marset-bicoca-tafellamp-oplaadbaar#59347';
174          var randomLink = $links.split(',');
175          var $link = randomLink[Math.floor(Math.random() * randomLink.length)];
176        } else if (countryCode == 'DE') {
177          var $links = 'https://www.light11.de/marset/bicoca.html,https://www.ikarus.de/bicoca-led-tischleuchte.html,https://www.design-bestseller.de/marset-bicoca-led-tischleuchte.html';
178          var randomLink = $links.split(',');
179          var $link = randomLink[Math.floor(Math.random() * randomLink.length)];
180        } else if (countryCode == 'GB') {
181          var $links = 'https://www.thelightsource.co.uk/light/marset/bicoca-tl-ylw,https://www.davidvillagelighting.co.uk/product/Marset-Bicoca-LED-Portable-Table-Lamp/18434,https://www.nest.co.uk/product/marset-bicoca-portable-table-lamp';
182          var randomLink = $links.split(',');
183          var $link = randomLink[Math.floor(Math.random() * randomLink.length)];
184        } else if (countryCode == 'FR' || countryCode == 'BE') {
185          var $links = 'https://www.dmlights.com/marset_bicoca_rechargeable_off_white~12KQT';
186          var randomLink = $links.split(',');
187          var $link = randomLink[Math.floor(Math.random() * randomLink.length)];
188        } else if (countryCode == 'US') {
189          var $links = 'https://www.marset.com/usa/light-fixtures/portable-lamps/bicoca-table/';
190          var randomLink = $links.split(',');
191          var $link = randomLink[Math.floor(Math.random() * randomLink.length)];
192          var $about_price = 'Bicoca by Christophe Mathieu, $245 + taxes';
193          var $price = 'Shop Now – $245';
194          $('.pre-title').html($about_price);
195          $('.geolink.with-price').html($price);
196        } else {
197          var $link = 'https://www.marset.com/en/buy-design-lamps/';
198        }
199        var $link = 'https://www.marset.com/en/buy-design-lamps/';
200        $('.geolink').attr('href', $link);
201      }
202    }); 
203});

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.