File size: 2,060 Bytes
a02680e 90a91d5 cd3439f 90a91d5 cd3439f 90a91d5 a02680e 90a91d5 a02680e 90a91d5 a02680e 90a91d5 a02680e 90a91d5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
// Initialize app
document.addEventListener('DOMContentLoaded', function() {
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Mobile menu toggle
const mobileMenuButton = document.querySelector('.mobile-menu-button');
const mobileMenu = document.querySelector('.mobile-menu');
if (mobileMenuButton && mobileMenu) {
mobileMenuButton.addEventListener('click', function() {
mobileMenu.classList.toggle('hidden');
});
}
// Initialize tooltips
const tooltipTriggers = document.querySelectorAll('[data-tooltip]');
tooltipTriggers.forEach(trigger => {
new Tooltip(trigger, {
placement: 'top',
title: trigger.getAttribute('data-tooltip')
});
});
// Form validation helper
window.validateForm = function(form) {
let isValid = true;
const inputs = form.querySelectorAll('input[required], select[required], textarea[required]');
inputs.forEach(input => {
if (!input.value.trim()) {
input.classList.add('border-red-500');
isValid = false;
} else {
input.classList.remove('border-red-500');
}
});
return isValid;
};
// Format currency helper
window.formatCurrency = function(value) {
return new Intl.NumberFormat('it-IT', {
style: 'currency',
currency: 'EUR',
minimumFractionDigits: 0,
maximumFractionDigits: 0
}).format(value);
};
// ROI calculator
window.calculateROI = function(purchasePrice, annualRevenue) {
if (!purchasePrice) return 0;
return ((annualRevenue / purchasePrice) * 100).toFixed(1);
};
});
|