PageSourceSearch

https://enamine.net/media/templates/site/enamine/js/template.js?9b6ee2

js enamine.net collected 2026-09-24 09:25:50 UTC 10,858 bytes, 319 lines download raw bytes

1/**
2 * @package     Joomla.Site
3 * @subpackage  Templates.Cassiopeia
4 * @copyright   (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
5 * @license     GNU General Public License version 2 or later; see LICENSE.txt
6 * @since       4.0.0
7 */
8
9Joomla = window.Joomla || {};
10
11window.amplitude = window.amplitude || {
12  getInstance() {
13    return window.amplitude;
14  }
15};
16
17(function (Joomla, document) {
18  'use strict';
19
20  function initTemplate(event) {
21    var target = event && event.target ? event.target : document;
22
23    /**
24     * Prevent clicks on buttons within a disabled fieldset
25     */
26    var fieldsets = target.querySelectorAll('fieldset.btn-group');
27    for (var i = 0; i < fieldsets.length; i++) {
28      var self = fieldsets[i];
29      if (self.getAttribute('disabled') === true) {
30        self.style.pointerEvents = 'none';
31        var btns = self.querySelectorAll('.btn');
32        for (var ib = 0; ib < btns.length; ib++) {
33          btns[ib].classList.add('disabled');
34        }
35      }
36    }
37  }
38
39  document.addEventListener('DOMContentLoaded', function (event) {
40    initTemplate(event);
41
42    /**
43     * Back to top
44     */
45    var backToTop = document.getElementById('back-top');
46
47    if (backToTop) {
48
49      function checkScrollPos() {
50        if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
51          backToTop.classList.add('visible');
52        } else {
53          backToTop.classList.remove('visible')
54        }
55      }
56
57      checkScrollPos();
58
59      window.onscroll = function () {
60        checkScrollPos();
61      };
62
63      backToTop.addEventListener('click', function (event) {
64        event.preventDefault();
65        window.scrollTo(0, 0);
66      });
67    }
68
69    [].slice.call(document.head.querySelectorAll('link[rel="lazy-stylesheet"]'))
70      .forEach(function ($link) {
71        $link.rel = "stylesheet";
72      });
73     /**
74       * Append UTM params to links pointing to enaminestore.com.
75       * UTM params are derived from the current enamine.net page structure.
76       */
77      function buildUtmFromLocation() {
78        var pathname = window.location.pathname || '/';
79        var s = pathname.replace(/^\/+|\/+$/g, '');
80        var segments = s ? s.split('/') : [];
81
82        var medium = 'page';
83        var campaign = 'page';
84
85        if (segments.length) {
86          var first = segments[0];
87
88          if (first === 'building-blocks') {
89            if (segments.length > 1) {
90              medium = segments[1] || 'page';
91              if (medium === 'medchem') medium = 'medchem_page';
92              campaign = segments.length > 2 ? segments[2] : 'page';
93            }
94          } else if (first === 'compound-collections') {
95            if (segments.length > 1) {
96              medium = segments[1] || 'page';
97              campaign = segments.length > 2 ? segments.slice(2).join('/') : 'page';
98            }
99          } else if (first === 'compound-libraries') {
100            if (segments.length > 1) {
101              medium = segments[1] || 'page';
102              campaign = segments.length > 2 ? segments.slice(2).join('/') : 'page';
103            }
104          } else if (first === 'news-press-releases') {
105            if (segments.length > 1) {
106              medium = segments[1] || 'page';
107              campaign = segments.length > 2 ? segments.slice(2).join('/') : 'page';
108            }
109          } else if (first === 'blog') {
110            medium = 'blog';
111            campaign = segments.length > 1 ? segments.slice(1).join('/') : 'page';
112          } else {
113            // fallback: use first segment as medium and remainder as campaign
114            medium = segments[0] || 'page';
115            campaign = segments.length > 1 ? segments.slice(1).join('/') : 'page';
116          }
117        }
118
119        return {
120          utm_source: 'enamine.net',
121          utm_medium: medium,
122          utm_campaign: campaign
123        };
124      }
125
126      function appendUtmToEnaminestoreLinks() {
127        var utm = buildUtmFromLocation();
128
129        if (console && console.debug) console.debug('buildUtmFromLocation ->', utm);
130
131        // First, handle medchem-main block if present: apply special UTM values
132        try {
133          var medchemMain = document.getElementById('medchem-main');
134          if (medchemMain) {
135            var medAnchors = [].slice.call(medchemMain.querySelectorAll('a[href^="https://enaminestore.com"], a[href^="https://www.enaminestore.com"]'));
136            medAnchors.forEach(function (anchor) {
137              try {
138                if (anchor.hasAttribute('data-utm-processed')) return;
139                var url = new URL(anchor.href);
140
141                var hasUtm = false;
142                url.searchParams.forEach(function (value, key) {
143                  if (key.toLowerCase().indexOf('utm_') === 0) hasUtm = true;
144                });
145
146                if (hasUtm) {
147                  if (console && console.debug) console.debug('medchem-main: skipping (already has UTM):', anchor.href);
148                  anchor.setAttribute('data-utm-processed', '1');
149                  return;
150                }
151
152                url.searchParams.set('utm_source', 'enamine.net');
153                url.searchParams.set('utm_medium', 'main-page');
154                url.searchParams.set('utm_campaign', 'medchem-month');
155
156                anchor.href = url.toString();
157                anchor.setAttribute('data-utm-processed', '1');
158                if (console && console.debug) console.debug('medchem-main: appended UTM to:', anchor.href);
159              } catch (e) {
160                if (console && console.error) console.error('medchem-main: failed to append UTM to link:', anchor && anchor.href, e);
161              }
162            });
163          }
164        } catch (e) {
165          if (console && console.error) console.error('Error processing medchem-main block:', e);
166        }
167
168        [].slice.call(document.querySelectorAll('a[href^="https://enaminestore.com"], a[href^="https://www.enaminestore.com"]'))
169          .forEach(function (anchor) {
170            try {
171              if (anchor.hasAttribute('data-utm-processed')) return;
172              var url = new URL(anchor.href);
173
174              if (!/(^|\.)enaminestore\.com$/.test(url.hostname)) {
175                if (console && console.debug) console.debug('Not an enaminestore domain, skipping:', url.hostname);
176                return;
177              }
178
179              // If any utm_ param already exists, skip this link entirely
180              var hasUtm = false;
181              url.searchParams.forEach(function (value, key) {
182                if (key.toLowerCase().indexOf('utm_') === 0) hasUtm = true;
183              });
184
185              if (hasUtm) {
186                if (console && console.debug) console.debug('Skipping link (already has UTM):', anchor.href);
187                return;
188              }
189
190              url.searchParams.set('utm_source', utm.utm_source);
191              url.searchParams.set('utm_medium', utm.utm_medium);
192              url.searchParams.set('utm_campaign', utm.utm_campaign);
193
194              anchor.href = url.toString();
195              if (console && console.debug) console.debug('Appended UTM to:', anchor.href);
196            } catch (e) {
197              if (console && console.error) console.error('Failed to append UTM to link:', anchor && anchor.href, e);
198            }
199          });
200      }
201
202      appendUtmToEnaminestoreLinks();
203
204      /**
205       * End UTM params
206       */
207  });
208
209  /**
210   * Initialize when a part of the page was updated
211   */
212  document.addEventListener('joomla:updated', initTemplate);
213})(Joomla, document);
214
215function redirectToContactForm(event) {
216  let destination_url = '/contact?page=' + encodeURIComponent(window.location.pathname);
217  window.location.href = destination_url;
218}
219function openMoreDetailsForm(event) {
220  let popupId = "#cf_2";
221  if (event.target.dataset['popup']) {
222    popupId = event.target.dataset['popup'];
223    console.log('openMoreDetailsForm.popupId = ', popupId);
224  }
225  $(popupId).show();
226}
227function closeMoreDetailsForm(event) {
228  if (event.target.classList.contains('pop-up-close') || event.target.id == 'cf_2') {
229    $("#cf_2").hide();
230  } else {
231    console.log('closeMoreDetailsForm', event.target);
232  }
233}
234function closeMoreDetailsForm2(event) {
235  if (event.target.classList.contains('pop-up-close') || event.target.id == 'cf_3') {
236    $("#cf_3").hide();
237  } else {
238    console.log('closeMoreDetailsForm2', event.target);
239  }
240}
241function closeMoreDetailsForm5(event) {
242  if (event.target.classList.contains('pop-up-close') || event.target.id == 'cf_5') {
243    $("#cf_5").hide();
244  } else {
245    console.log('closeMoreDetailsForm5', event.target);
246  }
247}
248function openRequestForm6(event) {
249  event.preventDefault();
250  let catalog_id = event.target.dataset['catalog'];
251  if (catalog_id) {
252    let message_text = $('#form6_message').val();
253    $('#form6_message').val(message_text + catalog_id + ' \n');
254  }
255  $('#cf_6').show();
256}
257function closeRequestForm6(event) {
258  if (event.target.classList.contains('pop-up-close') || event.target.id == 'cf_6') {
259    $("#cf_6").hide();
260  } else {
261    console.log('closeRequestForm6', event.target);
262  }
263}
264
265function closeRequestForm7(event) {
266  if (event.target.classList.contains('pop-up-close') || event.target.id == 'cf_7') {
267    $("#cf_7").hide();
268  } else {
269    console.log('closeRequestForm7', event.target);
270  }
271}
272
273$(document).ready(function () {
274  $('.button button.ico-envelopes').on('click', openMoreDetailsForm);
275  $("a[href^='mailto:'], .request-quote").on('click', openRequestForm6);
276  $('#cf_2').on('click', closeMoreDetailsForm);
277  $('#cf_3').on('click', closeMoreDetailsForm2);
278  $('#cf_5').on('click', closeMoreDetailsForm5);
279  $('#cf_6').on('click', closeRequestForm6);
280  $('#cf_7').on('click', closeRequestForm7);
281  $('.molecular-properties').slick({
282    slidesToShow: 3,
283    slidesToScroll: 3,
284    autoplay: true,
285    autoplaySpeed: 5000,
286    arrows: false,
287    dots: true,
288  });
289  $('.cards-slider').slick({
290    slidesToShow: 1,
291    slidesToScroll: 1,
292    autoplay: true,
293    autoplaySpeed: 5000,
294    arrows: false,
295    dots: false
296  });
297
298  // attach return path to login link
299  if (window.location.pathname === '/login') {
300    const params = new URLSearchParams(window.location.search);
301    const returnParam = params.get('return');
302    if (returnParam) {
303      const hiddenInput = document.querySelector('form input[name="return"]');
304      if (hiddenInput) {
305        hiddenInput.value = returnParam;
306      }
307    }
308  } else {
309    const currentPageURL = window.location.href;
310    const encodedURL = encodeURIComponent(btoa(currentPageURL));
311
312    // Find all anchor tags (<a>) on the page
313    document.querySelectorAll('a[href="/login"]').forEach(anchor => {
314      // Append the encoded current page URL as a query string
315      const newHref = `/login?return=${encodedURL}`;
316      anchor.href = newHref;
317    });
318  }
319});

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.