Back to Top JS

document.addEventListener(“DOMContentLoaded”, function() { var btn = document.getElementById(“back-to-top”); window.addEventListener(“scroll”, function() { if (window.scrollY > 300) { btn.style.display = “block”; } else { btn.style.display = “none”; } }); btn.addEventListener(“click”, function(e) { e.preventDefault(); window.scrollTo({ top: 0, behavior: “smooth” }); }); });Continue reading

Add GA click events

document.addEventListener(‘click’, function (e) { const a = e.target.closest(‘a’); if (!a) return; if (a.href.startsWith(‘tel:’)) { gtag(‘event’, ‘click_phone’, { link_url: a.href }); } if (a.href.startsWith(‘mailto:’)) { gtag(‘event’, ‘click_email’, { link_url: a.href }); } });Continue reading

Cookie Consent Event

(function () { var dl = window.dataLayer = window.dataLayer || []; var push = dl.push; dl.push = function () { var r = push.apply(this, arguments); try { var a = arguments[0]; if (a && a[0] === ‘consent’ && a[1] ===…Continue reading

Insert Title Into Page Banner

jQuery(document).ready(function($) { var $titleSource = $(‘.banner-overlay-title’).first(); if ($titleSource.length && $(‘.innerbanner’).length) { $(‘.innerbanner’).html(‘ ‘ + $titleSource.html() + ‘ ‘); $titleSource.hide(); } });Continue reading

Wrap Phone Number As Link

jQuery(document).ready(function($) { var $phone = $(‘.header-phone’); if ($phone.length) { var digits = $phone.text().replace(/\D/g, ”); var html = $phone.html(); $phone.html(‘‘ + html + ‘‘); } });Continue reading

Resize IFrame Child JavaScript

(function(window, undefined) { const document = window.document, parent = window.parent; // Inside iframe content function resizeIframe() { if(!document.body) return; // Get the actual content height const contentHeight = Math.max( document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight ); // Tell parent window the…Continue reading

Resize IFrame Parent JavaScript

(function(window, undefined) { const document = window.document; // Parent page JavaScript window.addEventListener(‘message’, function(event) { // Security check (optional but recommended) if (event.origin !== ‘https://environment.asj-net.com’) return; if (event.data.type === ‘resize’) { const iframe = document.querySelector(‘.auto-resize-iframe’) iframe.style.height = event.data.height + ‘px’; }…Continue reading

Re-Scroll to Anchor

(function () { var id = location.hash.slice(1); if (!id) { return; } function scrollToAnchor() { var el = document.getElementById(id); if (el) { el.scrollIntoView({ block: ‘start’ }); } } scrollToAnchor(); // initial attempt window.addEventListener(‘load’, scrollToAnchor); // after images/etc. if (document.fonts &&…Continue reading

To create the map and mapper as written by kodee

document.addEventListener(‘DOMContentLoaded’, function () { const map = L.map(‘treasure-map’).setView([51.5033, -0.1196], 12); L.tileLayer(‘https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png’, { attribution: ‘© OpenStreetMap contributors’ }).addTo(map); const items = document.querySelectorAll(‘.treasure-item’); const markers = []; items.forEach(function (item) { const lat = Number(item.dataset.lat); const lng = Number(item.dataset.lng); if (!Number.isFinite(lat) || !Number.isFinite(lng))…Continue reading