PageSourceSearch

https://www.convert.com/wp-content/themes/olympus/js/main.js?ver=1790788470

js convert.com collected 2026-10-01 08:32:25 UTC 6,858 bytes, 215 lines download raw bytes

1jQuery(function ($) {
2  function getCookie(name) {
3    const cookies = document.cookie.split(';');
4    for (let i = 0; i < cookies.length; i++) {
5      const cookie = cookies[i].split('=');
6      if (cookie[0].trim() === name) {
7        return decodeURIComponent(cookie[1]);
8      }
9    }
10    return null;
11  }
12
13  function setUtmCookie(source, campaign, content) {
14    // Seed from the stored cookie, never from an empty object: a later touch
15    // carrying only some utm_* params (e.g. the app bounce-back link, which has
16    // utm_source but no utm_campaign) would otherwise drop the siblings and lose
17    // the campaign for every visitor whose sessionStorage has already expired.
18    let data = {};
19    try {
20      const raw = getCookie('_conv_utm');
21      if (raw) data = JSON.parse(raw) || {};
22    } catch (e) {
23      data = {};
24    }
25    if (source) data.utm_source = source;
26    if (campaign) data.utm_campaign = campaign;
27    if (content) data.utm_content = content;
28    const expires = new Date();
29    expires.setDate(expires.getDate() + 30);
30    document.cookie =
31      '_conv_utm=' +
32      encodeURIComponent(JSON.stringify(data)) +
33      '; expires=' +
34      expires.toUTCString() +
35      '; path=/; domain=.convert.com; SameSite=Lax; secure';
36  }
37
38  function getUtmFromCookie(key) {
39    const cookieKeyMap = {
40      utmSource: 'utm_source',
41      utmCampaign: 'utm_campaign',
42      utmContent: 'utm_content',
43    };
44    try {
45      const raw = getCookie('_conv_utm');
46      if (!raw) return null;
47      const data = JSON.parse(raw);
48      return data[cookieKeyMap[key]] || null;
49    } catch (e) {
50      return null;
51    }
52  }
53
54  function setSessionStorageItem(key, value, ambassador = false) {
55    const currentValue = sessionStorage.getItem(key);
56    const cookieValue = getUtmFromCookie(key);
57    const newValue =
58      ambassador ||
59      value ||
60      currentValue ||
61      cookieValue ||
62      (key === 'utmSource' ? 'Organic/Website' : '');
63    sessionStorage.setItem(key, newValue);
64  }
65
66  function setUtmValue(input, value, storageKey) {
67    if (input.length) {
68      input.val(sessionStorage.getItem(storageKey));
69    }
70  }
71
72  function setUtmSource(urlString) {
73    const url = new URL(urlString);
74    const utmSource = url.searchParams.get('utm_source');
75    const utmCampaign = url.searchParams.get('utm_campaign');
76    const utmContent = url.searchParams.get('utm_content');
77    const utmSourceDataName = $('input[data-name="utm_source"]');
78    const utmCampaignDataName = $('input[data-name="utm_campaign"]');
79    const utmContentDataName = $('input[data-name="utm_content"]');
80    const utmSourceName = $('input[name="utm_source"]');
81    const utmCampaignName = $('input[name="utm_campaign"]');
82    const utmContentName = $('input[name="utm_content"]');
83    const isAmbassador =
84      getCookie('ref_id') || getCookie('red_code') ? 'Affiliate Program' : false;
85
86    if (utmSource || utmCampaign || utmContent) {
87      setUtmCookie(utmSource, utmCampaign, utmContent);
88    }
89
90    setSessionStorageItem('utmSource', utmSource, isAmbassador);
91    setSessionStorageItem('utmCampaign', utmCampaign);
92    setSessionStorageItem('utmContent', utmContent);
93
94    setUtmValue(utmSourceDataName, utmSource, 'utmSource');
95    setUtmValue(utmCampaignDataName, utmCampaign, 'utmCampaign');
96    setUtmValue(utmContentDataName, utmContent, 'utmContent');
97    setUtmValue(utmSourceName, utmSource, 'utmSource');
98    setUtmValue(utmCampaignName, utmCampaign, 'utmCampaign');
99    setUtmValue(utmContentName, utmContent, 'utmContent');
100  }
101
102  function getThemeBase() {
103    const g = typeof themeple_global !== 'undefined' ? themeple_global : null;
104    if (g && g.templateUri) {
105      return String(g.templateUri).replace(/\/+$/, '');
106    }
107
108    const mainScript = document.querySelector(
109      'script[src*="/wp-content/themes/"][src*="/js/main.js"]',
110    );
111    if (mainScript && mainScript.src) {
112      return String(mainScript.src).replace(/\/js\/main\.js(\?.*)?$/, '');
113    }
114
115    return '';
116  }
117
118  function abTestNLLogos() {
119    if (!window.AB_TEST_NL_LOGOS) {
120      return;
121    }
122    if (!document.body.classList.contains('home')) {
123      return;
124    }
125    const container = document.getElementById('homepageLogos');
126    if (!container) {
127      return;
128    }
129    const base = getThemeBase();
130    if (!base) {
131      return;
132    }
133
134    const logos = [
135      { file: 'wehkamp.svg', alt: 'Wehkamp', width: '130px' },
136      { file: 'fletcher.svg', alt: 'Fletcher', width: '256px' },
137      { file: 'kwantum.svg', alt: 'Kwantum', width: '140px' },
138      { file: 'bugaboo.svg', alt: 'Bugaboo', width: '140px' },
139      { file: 'dille-kamille.svg', alt: 'Dille Kamille', width: '70px' },
140      { file: 'beterbed.svg', alt: 'Beter Bed', width: '65px' },
141    ];
142
143    // Stop the hero marquee: this variant shows the logos as a static row
144    const marquee = container.closest('.features-marquee');
145    if (marquee) {
146      marquee.classList.remove('features-marquee');
147    }
148    container.className =
149      'flex flex-wrap items-center justify-center gap-8 md:gap-12';
150    container.replaceChildren();
151
152    logos.forEach(({ file, alt, width }) => {
153      const img = document.createElement('img');
154      img.src = `${base}/img/nl/${file}`;
155      img.alt = alt;
156      img.style.width = width;
157      img.style.height = 'auto';
158      img.className = 'object-contain';
159      img.loading = 'lazy';
160      container.appendChild(img);
161    });
162  }
163
164  function abTestAgencyLogos() {
165    if (!window.AB_TEST_AGENCY_LOGOS) {
166      return;
167    }
168    if (!window.location.pathname.replace(/\/+$/, '').endsWith('/why-convert-agency')) {
169      return;
170    }
171    const wrapper = document.getElementById('why-convert-agency-logos');
172    if (!wrapper) {
173      return;
174    }
175    const grid = wrapper.querySelector('.grid');
176    if (!grid) {
177      return;
178    }
179    const base = getThemeBase();
180    if (!base) {
181      return;
182    }
183
184    const slots = Array.from(grid.children);
185    const kept = slots.slice(-2);
186
187    const newLogos = [
188      { file: 'online-dialogue.svg', alt: 'Online Dialogue' },
189      { file: 'valantic.svg', alt: 'Valantic' },
190    ];
191
192    grid.replaceChildren();
193    grid.classList.remove('grid-cols-2', 'md:grid-cols-5');
194    grid.classList.add('grid-cols-2', 'md:grid-cols-4');
195
196    newLogos.forEach(({ file, alt }) => {
197      const div = document.createElement('div');
198      const img = document.createElement('img');
199      img.src = `${base}/img/nl/${file}`;
200      img.alt = alt;
201      img.className = 'w-full h-12 object-contain';
202      img.loading = 'lazy';
203      div.appendChild(img);
204      grid.appendChild(div);
205    });
206
207    kept.forEach((el) => grid.appendChild(el));
208  }
209
210  window.abTestNLLogos = abTestNLLogos;
211  window.abTestAgencyLogos = abTestAgencyLogos;
212  setUtmSource(window.location.href);
213  abTestNLLogos();
214  abTestAgencyLogos();
215});

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.