//= require pagy function sendEmail(email) { location.href="mailto:"+email.split("").reverse().join(""); } const resetRecaptcha = async (element) => { const token = await grecaptcha.execute( "<%= Rails.application.credentials.recaptcha.recaptcha_site_key %>", { action: "checkrecaptcha" } ); element.val(token); }; /* <% =begin %> const resetRecaptchaEnterprise = async (element) => { const token = await grecaptcha.enterprise.execute( "<%= Rails.application.credentials.recaptcha_enterprise.recaptcha_site_key %>", { action: "checkrecaptcha" } ); element.val(token); }; <% =end %> */ document.addEventListener("turbo:load", function () { const missingTranslations = document.querySelectorAll(".translation_missing"); if (missingTranslations.length > 0) { console.error( "Found " + missingTranslations.length + " missing translations:", missingTranslations ); } }); function hexToRgb(hex) { // Remove the hash at the start if it's there hex = hex.replace(/^#/, ''); // Parse the r, g, b values const bigint = parseInt(hex, 16); const r = (bigint >> 16) & 255; const g = (bigint >> 8) & 255; const b = bigint & 255; return { r, g, b }; } function rgbToHex(r, g, b) { return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1).toUpperCase(); } function clamp(value, min, max) { return Math.max(min, Math.min(max, value)); } function generateGradient(startColor, endColor, steps) { const startRgb = hexToRgb(startColor); const endRgb = hexToRgb(endColor); const colors = []; for (let i = 0; i <= steps; i++) { const r = clamp(Math.round(startRgb.r + (endRgb.r - startRgb.r) * (i / steps)),0,255); const g = clamp(Math.round(startRgb.g + (endRgb.g - startRgb.g) * (i / steps) * 1.5),0,255); const b = clamp(Math.round(startRgb.b + (endRgb.b - startRgb.b) * (i / steps)),0,255); colors.push(rgbToHex(r, g, b)); } return colors; } // Cookie functions, sourced from w3schools function setCookie(cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); var expires = "expires=" + d.toUTCString(); document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; } function getCookie(cname) { var name = cname + "="; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) === ' ') { c = c.substring(1); } if (c.indexOf(name) === 0) { return c.substring(name.length, c.length); } } return ""; } function dismissConstructionNotice() { const noticeContainer = document.getElementById("construction-notice"); setCookie('notice_dismissed', 'true', 1); noticeContainer.remove(); }