“Lazy Load Images”.

document.addEventListener(“DOMContentLoaded”, function() { const lazyLoadImages = () => { const images = document.querySelectorAll(‘img.lazy’); const observer = new IntersectionObserver((entries, observer) => { entries.forEach(entry => { if (entry.isIntersecting) { const img = entry.target; img.src = img.dataset.src; img.classList.remove(‘lazy’); observer.unobserve(img); } }); }); images.forEach(img…Continue reading

Gravity Forms JavaScript Helpers

jQuery(function($) { $(‘.gform_wrapper FORM’).on(‘change’, ‘.post-code INPUT’, function(evt) { evt.stopImmediatePropagation(); const field = $(this), postCode = field.val(); $.get({ url: `https://apis.postcode-jp.com/api/v6/postcodes/${postCode}?apiKey=BJ7qtSrq0iYgWj9AV0P4esvTTX1gmq48813DoE1&normalize=true&fields=allAddress,prefCode,city,town` }).always(function(response) { console.log(‘RESPONSE:’, response); if(!Array.isArray(response)) return; const form = field.closest(‘FORM’), result = response[0]; if(result.prefCode) $(‘.prefecture SELECT’, form).val(result.prefCode); if(result.city) $(‘.street INPUT’, form).val(`${result.city}${result.town}`);…Continue reading

HashBars and Responsive Menu Pro Adjustment

jQuery(document).ready(function($) { if($(‘.hthb-notification’).length){ var wpadminBar = 0; if($( “#wpadminbar” ).length){ wpadminBar = $( “#wpadminbar” ).height(); } setTimeout(() => { var hthbNotification = $( “.hthb-notification:visible” ).height(); $(‘body’).css(‘margin-top’,hthbNotification + ‘px’);hthbNotification $(‘#responsive-menu-pro-button’).css(‘margin-top’,hthbNotification + wpadminBar + 20 + ‘px’); $(window).resize(function(){ var hthbNotification = $(…Continue reading

FB Events App.js

window.fbAsyncInit = function() { FB.init({ appId : ‘247399214359492’, cookie : true, xfbml : true, version : ‘v16.0’ }); FB.AppEvents.logPageView(); }; (function(d, s, id){ var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = “https://connect.facebook.net/en_US/sdk.js”;…Continue reading

Thanksgiving popup

(function(w, d, t, h, s, n) { w.FlodeskObject = n; var fn = function() { (w[n].q = w[n].q || []).push(arguments); }; w[n] = w[n] || fn; var f = d.getElementsByTagName(t)[0]; var v = ‘?v=’ + Math.floor(new Date().getTime() / (120 *…Continue reading

Clear Content Area

function clearContentArea() { let contentArea = document.querySelector(‘#content’); let siteContainer = document.querySelector(‘.site’); // Remove title & date if (contentArea) { contentArea.remove(); } // Reapply site styling to correct footer height. if (siteContainer) { siteContainer.style.minHeight = ‘100%’; } } clearContentArea();Continue reading

Untitled Snippet

const showHidePass = document.getElementById(‘showHidePassword’); const userPassword = document.getElementById(‘password’); showHidePass.addEventListener(‘click’, function(e) { let showHideAttr = userPassword.getAttribute(‘type’); if (showHideAttr === ‘password’) { showHideAttr = ‘text’; } else { showHideAttr = ‘password’; } userPassword.setAttribute(‘type’, showHideAttr); this.classList.toggle(‘fa-eye-slash’); });Continue reading

Retain Query Params

document.addEventListener(‘DOMContentLoaded’, function() { var queryString = window.location.search; var links = document.querySelectorAll(‘.elementor a’); // Target elementor links if (queryString) { links.forEach(function(link) { var originalUrl = link.href; // Ensure the query parameters are appended correctly without creating duplicates if (originalUrl.indexOf(‘?’) === -1)…Continue reading

Show more Landings

document.addEventListener(“DOMContentLoaded”, function () { // Get all Read More buttons const readMoreButtons = document.querySelectorAll(‘.read-more’); readMoreButtons.forEach(button => { button.addEventListener(‘click’, function (event) { event.preventDefault(); const feature = this.closest(‘.feature’); const longDesc = feature.querySelector(‘.long-desc’); const shortDesc = feature.querySelector(‘.short-desc’); if (longDesc.style.display === “none”) { longDesc.style.display…Continue reading

Untitled Snippet

// Define the API URL const apiUrl = ‘https://api.example.com/data’; // Make a GET request fetch(apiUrl) .then(response => { if (!response.ok) { throw new Error(‘Network response was not ok’); } return response.json(); }) .then(data => { console.log(data); }) .catch(error => {…Continue reading