$(document).ready(function () { //Forma //===========================================> function onClick(e) { e.preventDefault(); grecaptcha.ready(function() { grecaptcha.execute('6LexnsYmAAAAAOjql7Idndy_XTb2QUdiCuAQUOHu', {action: 'submit'}).then(function(token) { // Add your logic to submit to your backend server here. }); }); } // Obtener la URL actual var currentURL = window.location.href; // Obtener todos los elementos con la clase "nav-link" var navLinks = $('a.nav-link'); // Recorrer los enlaces y comparar con la URL actual navLinks.each(function () { if (this.href === currentURL) { $(this).addClass('active'); // Agregar la clase "active" return false; // Salir del bucle si se encuentra una coincidencia } }); // Verificar si el enlace con clase "nav-link active" estš¢ presente if ($('.nav-link.active').length > 0) { // Agregar la clase "show" al elemento padre con clase "collapse" $('.nav-link.active').closest('.collapse').addClass('show'); } //===========================================> }); // Funciones de la calculadora document.addEventListener("DOMContentLoaded", function () { const openCalculatorBtn = document.getElementById("openCalculator"); const calculatorModal = document.getElementById("calculatorModal"); const closeModalBtn = document.getElementById("closeModal"); const overlay = document.getElementById("overlay"); const resultInput = document.getElementById("result"); let currentInput = ""; let lastValue = 0; function updateResult() { resultInput.value = currentInput; } function clearResult() { currentInput = ""; updateResult(); } function calculate() { try { currentInput = eval(currentInput); updateResult(); } catch (error) { currentInput = "Error"; updateResult(); } } openCalculatorBtn.addEventListener("click", function () { calculatorModal.style.display = "block"; overlay.style.display = "block"; console.log("que paso"); }); closeModalBtn.addEventListener("click", function () { calculatorModal.style.display = "none"; overlay.style.display = "none"; clearResult(); }); calculatorModal.addEventListener("click", function (event) { const target = event.target; if (target.classList.contains("number")) { currentInput += target.textContent; updateResult(); } else if (target.classList.contains("operator")) { currentInput += target.textContent; updateResult(); } else if (target.id === "clear") { clearResult(); } else if (target.id === "equal") { calculate(); lastValue = currentInput; } else if (target.id === "backspace") { currentInput = currentInput.slice(0, -1); updateResult(); } }); document.addEventListener("keydown", function (event) { if (calculatorModal.style.display === "block") { const key = event.key; if (!isNaN(key) || key === "+" || key === "-" || key === "*" || key === "/" || key === ".") { currentInput += key; updateResult(); } else if (key === "Enter") { calculate(); lastValue = currentInput; } else if (key === "Escape") { clearResult(); } else if (key === "Backspace") { currentInput = currentInput.slice(0, -1); updateResult(); } } }); });