CommanderLazarus's picture
How do I join CSIS? Add to the bottom of the page.
f59e1ef verified
// Main JavaScript functionality
document.addEventListener('DOMContentLoaded', function() {
// Initialize tooltips
const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
if (tooltipTriggerList.length > 0) {
tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
});
}
// Smooth scroll for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Age calculator for demonstration purposes
const currentYear = new Date().getFullYear();
const targetYear = 2025;
const cutoffAge = 42;
const ageCalcForm = document.getElementById('age-calculator');
if (ageCalcForm) {
ageCalcForm.addEventListener('submit', function(e) {
e.preventDefault();
const birthYear = parseInt(document.getElementById('birth-year').value);
const ageIn2025 = targetYear - birthYear;
const resultElement = document.getElementById('age-result');
resultElement.innerHTML = `
<div class="mt-4 p-4 rounded-lg ${ageIn2025 > cutoffAge ? 'bg-red-100 text-red-800' : 'bg-green-100 text-green-800'}">
<p>In 2025, you will be <strong>${ageIn2025} years old</strong>.</p>
<p class="mt-2">${ageIn2025 > cutoffAge ?
'This exceeds the standard cutoff age, but waiver options may be available.' :
'You meet the standard age requirements!'}</p>
</div>
`;
});
}
});
// Back to top button functionality
window.addEventListener('scroll', function() {
const backToTopButton = document.getElementById('back-to-top');
if (backToTopButton) {
if (window.pageYOffset > 300) {
backToTopButton.classList.remove('opacity-0', 'invisible');
backToTopButton.classList.add('opacity-100', 'visible');
} else {
backToTopButton.classList.remove('opacity-100', 'visible');
backToTopButton.classList.add('opacity-0', 'invisible');
}
}
});
// Initialize any modals or popups
function initModal(modalId) {
const modal = document.getElementById(modalId);
if (modal) {
const openButtons = document.querySelectorAll(`[data-modal-target="${modalId}"]`);
const closeButton = modal.querySelector('.modal-close');
openButtons.forEach(btn => {
btn.addEventListener('click', () => {
modal.classList.remove('hidden');
document.body.style.overflow = 'hidden';
});
});
closeButton.addEventListener('click', () => {
modal.classList.add('hidden');
document.body.style.overflow = 'auto';
});
window.addEventListener('click', (e) => {
if (e.target === modal) {
modal.classList.add('hidden');
document.body.style.overflow = 'auto';
}
});
}
}