Think of this like a digital health passport that remembers every immunization for your whole family! Track vaccination records, get reminders for upcoming shots, and follow CDC guidelines all in one place. Never miss an important vaccine or scramble to find records again!
`;
}).join('');
}
// Get vaccines for member based on age
function getVaccinesForMember(member) {
const category = getAgeCategory(member.age);
return vaccineSchedule[category] || [];
}
// Get completed vaccines for member
function getCompletedVaccines(memberId) {
return vaccineState.vaccineRecords
.filter(record => record.memberId === memberId)
.map(record => record.vaccine);
}
// Select member for detailed view
function selectMember(memberId) {
vaccineState.selectedMember = memberId;
const member = vaccineState.familyMembers.find(m => m.id === memberId);
if (!member) return;
// Switch to schedule tab and show member's vaccines
switchTab('schedule');
displayMemberSchedule(member);
}
// Display member-specific schedule
function displayMemberSchedule(member) {
const container = document.getElementById('vaccineScheduleDisplay');
const vaccinesForAge = getVaccinesForMember(member);
const completedVaccines = getCompletedVaccines(member.id);
container.innerHTML = `
Vaccination Schedule for ${member.name} (Age ${member.age})
${vaccinesForAge.map(vaccine => {
const isCompleted = completedVaccines.includes(vaccine.name);
const status = isCompleted ? 'completed' : 'due';
return `
Recommended age: ${vaccine.age}
Description: ${vaccine.description}
${!isCompleted ? `
Mark as Completed
` : ''}
`;
}).join('')}
`;
}
// Display vaccine schedule
function displayVaccineSchedule() {
const filter = document.getElementById('scheduleFilter').value;
const container = document.getElementById('vaccineScheduleDisplay');
if (filter === 'all') {
container.innerHTML = Object.keys(vaccineSchedule).map(category => `
${category} Vaccines
${vaccineSchedule[category].map(vaccine => `
`).join('')}
`).join('');
} else {
const vaccines = vaccineSchedule[filter] || [];
container.innerHTML = vaccines.map(vaccine => `
`).join('');
}
}
// Filter schedule
function filterSchedule() {
displayVaccineSchedule();
}
// Update family overview
function updateFamilyOverview() {
const totalMembers = vaccineState.familyMembers.length;
let totalDue = 0;
let totalCompleted = 0;
let totalOverdue = 0;
vaccineState.familyMembers.forEach(member => {
const vaccinesForAge = getVaccinesForMember(member);
const completedVaccines = getCompletedVaccines(member.id);
const dueVaccines = vaccinesForAge.filter(v => !completedVaccines.includes(v.name));
totalCompleted += completedVaccines.length;
totalDue += dueVaccines.length;
});
const summaryCards = document.querySelectorAll('#familyOverview .summary-value');
if (summaryCards.length >= 4) {
summaryCards[0].textContent = totalMembers;
summaryCards[1].textContent = totalDue;
summaryCards[2].textContent = totalCompleted;
summaryCards[3].textContent = totalOverdue;
}
}
// Update record dropdowns
function updateRecordDropdowns() {
const personSelect = document.getElementById('recordPerson');
const vaccineSelect = document.getElementById('recordVaccine');
// Update person dropdown
personSelect.innerHTML = 'Select family member... ' +
vaccineState.familyMembers.map(member =>
`${member.name} `
).join('');
// Update vaccine dropdown with all possible vaccines
const allVaccines = new Set();
Object.values(vaccineSchedule).forEach(vaccines => {
vaccines.forEach(v => allVaccines.add(v.name));
});
vaccineSelect.innerHTML = 'Select vaccine... ' +
Array.from(allVaccines).sort().map(vaccine =>
`${vaccine} `
).join('');
}
// Record vaccination
function recordVaccination() {
const memberId = parseInt(document.getElementById('recordPerson').value);
const vaccine = document.getElementById('recordVaccine').value;
const date = document.getElementById('recordDate').value;
const provider = document.getElementById('recordProvider').value.trim();
if (!memberId || !vaccine || !date) {
showNotification('Please fill in all required fields', 'error');
return;
}
const record = {
id: Date.now(),
memberId: memberId,
vaccine: vaccine,
date: date,
provider: provider
};
vaccineState.vaccineRecords.push(record);
saveVaccineRecords();
// Clear form
document.getElementById('recordPerson').value = '';
document.getElementById('recordVaccine').value = '';
document.getElementById('recordDate').value = '';
document.getElementById('recordProvider').value = '';
displayVaccinationHistory();
updateFamilyOverview();
showNotification('Vaccination recorded successfully!', 'success');
// Show OTA
showOTA();
}
// Mark vaccine as completed
function markAsCompleted(memberId, vaccineName) {
const today = new Date().toISOString().split('T')[0];
const record = {
id: Date.now(),
memberId: memberId,
vaccine: vaccineName,
date: today,
provider: 'Quick entry'
};
vaccineState.vaccineRecords.push(record);
saveVaccineRecords();
// Refresh display
const member = vaccineState.familyMembers.find(m => m.id === memberId);
if (member) {
displayMemberSchedule(member);
}
updateFamilyOverview();
showNotification(`${vaccineName} marked as completed!`, 'success');
}
// Display vaccination history
function displayVaccinationHistory() {
const container = document.getElementById('vaccinationHistory');
if (vaccineState.vaccineRecords.length === 0) {
container.innerHTML = `
No vaccination records yet
Record vaccinations above to track your family's immunization history
`;
return;
}
const groupedRecords = {};
vaccineState.vaccineRecords.forEach(record => {
const member = vaccineState.familyMembers.find(m => m.id === record.memberId);
if (member) {
if (!groupedRecords[member.name]) {
groupedRecords[member.name] = [];
}
groupedRecords[member.name].push(record);
}
});
container.innerHTML = `
Vaccination History
${Object.keys(groupedRecords).map(memberName => `
${memberName}
${groupedRecords[memberName].map(record => `
${record.vaccine}
Date: ${record.date} | Provider: ${record.provider}
Remove
`).join('')}
`).join('')}
`;
}
// Remove family member
function removeMember(memberId) {
if (confirm('Are you sure you want to remove this family member and all their vaccination records?')) {
vaccineState.familyMembers = vaccineState.familyMembers.filter(m => m.id !== memberId);
vaccineState.vaccineRecords = vaccineState.vaccineRecords.filter(r => r.memberId !== memberId);
saveFamilyMembers();
saveVaccineRecords();
updateFamilyMembersList();
updateFamilyOverview();
updateRecordDropdowns();
showNotification('Family member removed', 'success');
}
}
// Remove vaccination record
function removeRecord(recordId) {
if (confirm('Are you sure you want to remove this vaccination record?')) {
vaccineState.vaccineRecords = vaccineState.vaccineRecords.filter(r => r.id !== recordId);
saveVaccineRecords();
displayVaccinationHistory();
updateFamilyOverview();
showNotification('Vaccination record removed', 'success');
}
}
// Export records
function exportRecords() {
if (vaccineState.familyMembers.length === 0) {
showNotification('No family members to export', 'error');
return;
}
let exportData = "FAMILY VACCINATION RECORDS\n";
exportData += "Generated: " + new Date().toLocaleDateString() + "\n\n";
vaccineState.familyMembers.forEach(member => {
exportData += `${member.name} (Age: ${member.age})\n`;
exportData += "=" + "=".repeat(member.name.length + 10) + "\n";
const memberRecords = vaccineState.vaccineRecords.filter(r => r.memberId === member.id);
if (memberRecords.length > 0) {
memberRecords.forEach(record => {
exportData += `β’ ${record.vaccine} - ${record.date} (${record.provider})\n`;
});
} else {
exportData += "No vaccination records\n";
}
exportData += "\n";
});
// Create downloadable file
const blob = new Blob([exportData], { type: 'text/plain' });
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'family_vaccination_records.txt';
a.click();
window.URL.revokeObjectURL(url);
showNotification('Records exported successfully!', 'success');
}
// Save data to localStorage
function saveFamilyMembers() {
localStorage.setItem('familyMembers', JSON.stringify(vaccineState.familyMembers));
}
function saveVaccineRecords() {
localStorage.setItem('vaccineRecords', JSON.stringify(vaccineState.vaccineRecords));
}
// ========== SAMPLE SCENARIOS ==========
function useSample(sampleType) {
// Clear existing data
vaccineState.familyMembers = [];
vaccineState.vaccineRecords = [];
const today = new Date();
const currentYear = today.getFullYear();
switch(sampleType) {
case 'newborn':
vaccineState.familyMembers = [
{ id: 1, name: 'Sarah Johnson', birthdate: '1985-03-15', age: calculateAge('1985-03-15') },
{ id: 2, name: 'Mike Johnson', birthdate: '1983-07-22', age: calculateAge('1983-07-22') },
{ id: 3, name: 'Baby Emma', birthdate: `${currentYear}-01-10`, age: 0 }
];
break;
case 'school':
vaccineState.familyMembers = [
{ id: 1, name: 'Lisa Chen', birthdate: '1980-09-12', age: calculateAge('1980-09-12') },
{ id: 2, name: 'David Chen', birthdate: '1978-05-08', age: calculateAge('1978-05-08') },
{ id: 3, name: 'Alex Chen', birthdate: `${currentYear-5}-04-20`, age: 5 },
{ id: 4, name: 'Maya Chen', birthdate: `${currentYear-8}-11-15`, age: 8 },
{ id: 5, name: 'Sam Chen', birthdate: `${currentYear-12}-06-30`, age: 12 }
];
break;
case 'multi-gen':
vaccineState.familyMembers = [
{ id: 1, name: 'Robert Williams', birthdate: '1950-02-14', age: calculateAge('1950-02-14') },
{ id: 2, name: 'Martha Williams', birthdate: '1952-08-25', age: calculateAge('1952-08-25') },
{ id: 3, name: 'Jennifer Williams', birthdate: '1975-12-03', age: calculateAge('1975-12-03') },
{ id: 4, name: 'Tom Williams', birthdate: '1973-10-18', age: calculateAge('1973-10-18') },
{ id: 5, name: 'Ethan Williams', birthdate: `${currentYear-16}-07-12`, age: 16 },
{ id: 6, name: 'Sophia Williams', birthdate: `${currentYear-14}-03-28`, age: 14 }
];
break;
case 'travel':
vaccineState.familyMembers = [
{ id: 1, name: 'Amanda Rodriguez', birthdate: '1988-01-20', age: calculateAge('1988-01-20') },
{ id: 2, name: 'Carlos Rodriguez', birthdate: '1986-11-05', age: calculateAge('1986-11-05') },
{ id: 3, name: 'Diego Rodriguez', birthdate: `${currentYear-10}-09-14`, age: 10 },
{ id: 4, name: 'Sofia Rodriguez', birthdate: `${currentYear-7}-05-22`, age: 7 }
];
break;
}
saveFamilyMembers();
saveVaccineRecords();
// Switch to family tab and update display
switchTab('family');
showNotification(`Sample "${sampleType}" family loaded!`, 'success');
}
// ========== UTILITY FUNCTIONS ==========
function showNotification(message, type = 'success') {
const toast = document.createElement('div');
toast.className = `toast ${type}`;
toast.textContent = message;
document.body.appendChild(toast);
setTimeout(() => {
toast.remove();
}, 3000);
}
function showOTA() {
const otaContainer = document.getElementById('otaContainer');
if (otaContainer && (otaContainer.style.display === 'none' || !otaContainer.style.display)) {
otaContainer.style.display = 'block';
setTimeout(() => {
const otaHeader = document.querySelector('.ota-header h3');
if (otaHeader) {
otaHeader.style.animation = 'pulse 1s ease-in-out';
}
}, 100);
}
}
function trackEvent(eventName, data = {}) {
if (typeof gtag !== 'undefined') {
gtag('event', eventName, {
'event_category': TOOL_CONFIG.category,
'event_label': TOOL_CONFIG.name,
...data
});
}
}
// ========== AI ASSISTANT FUNCTIONS ==========
function openAIModal() {
const modal = document.getElementById('aiModal');
if(modal) modal.classList.add('show');
if (aiModalState.apiKey && aiModalState.currentView === 'gemini') {
showGeminiChat();
} else {
showAISelector();
}
updateAPIKeyStatus();
}
function closeAIModal() {
const modal = document.getElementById('aiModal');
if(modal) modal.classList.remove('show');
setTimeout(() => {
aiModalState.currentView = 'selector';
showAISelector();
}, 300);
}
function showAISelector() {
document.getElementById('aiModalTitle').textContent = 'Choose Your AI Assistant';
document.getElementById('aiSelector').style.display = 'flex';
document.getElementById('geminiChat').style.display = 'none';
document.getElementById('apiKeySetup').style.display = 'none';
aiModalState.currentView = 'selector';
}
function showGeminiChat() {
document.getElementById('aiModalTitle').innerHTML = 'β¨ Gemini AI Assistant';
document.getElementById('aiSelector').style.display = 'none';
document.getElementById('geminiChat').style.display = 'flex';
document.getElementById('apiKeySetup').style.display = 'none';
aiModalState.currentView = 'gemini';
const chatMessages = document.getElementById('chatMessages');
if (!chatMessages.innerHTML.trim()) {
addMessage('assistant', `Hello! I can help you with:
β’ Vaccine schedules and immunization guidelines
β’ Understanding CDC recommendations
β’ Age-appropriate vaccination timing
β’ Travel vaccination requirements
β’ Vaccine safety and side effects
β’ Catch-up schedules for missed vaccines
What vaccination questions do you have?`);
}
}
function showAPIKeySetup() {
document.getElementById('aiModalTitle').textContent = 'Setup Gemini API';
document.getElementById('aiSelector').style.display = 'none';
document.getElementById('geminiChat').style.display = 'none';
document.getElementById('apiKeySetup').style.display = 'block';
aiModalState.currentView = 'setup';
}
function selectAI(aiType) {
switch(aiType) {
case 'chatgpt':
const toolContext = `I need help with vaccination schedules and immunization tracking. I'm using a Vaccine Schedule Tracker tool that follows CDC guidelines for family vaccination management. Please help me understand vaccine schedules, immunization requirements, and health guidelines.`;
const chatUrl = `https://chat.openai.com/?q=${encodeURIComponent(toolContext)}`;
window.open(chatUrl, '_blank');
closeAIModal();
trackEvent('ai_selection', { ai_type: 'chatgpt' });
break;
case 'claude':
const claudeContext = `I need help with vaccine schedules and family health tracking. I'm using a Vaccine Schedule Tracker tool for managing immunization records and following CDC guidelines. Please help me understand vaccination requirements, timing, and health recommendations.`;
const claudeUrl = `https://claude.ai/chat?q=${encodeURIComponent(claudeContext)}`;
window.open(claudeUrl, '_blank');
closeAIModal();
trackEvent('ai_selection', { ai_type: 'claude' });
break;
case 'gemini':
if (!aiModalState.apiKey) {
showAPIKeySetup();
} else {
showGeminiChat();
}
trackEvent('ai_selection', { ai_type: 'gemini' });
break;
}
}
function saveGeminiApiKey() {
const apiKey = document.getElementById('geminiApiKeyInput').value.trim();
if (apiKey) {
localStorage.setItem('geminiApiKey', apiKey);
aiModalState.apiKey = apiKey;
showGeminiChat();
updateAPIKeyStatus();
} else {
alert('Please enter a valid API key');
}
}
function updateAPIKeyStatus() {
const statusEl = document.getElementById('apiKeyStatus');
if (aiModalState.apiKey) {
statusEl.innerHTML = 'Change API Key ';
} else {
statusEl.textContent = 'No API key set';
}
}
function addMessage(type, content) {
const chatMessages = document.getElementById('chatMessages');
const messageDiv = document.createElement('div');
messageDiv.className = `message ${type}`;
if (type === 'user') {
messageDiv.innerHTML = `You: ${content}`;
} else {
messageDiv.innerHTML = `β¨ Gemini: ${content.replace(/\n/g, ' ')}`;
}
chatMessages.appendChild(messageDiv);
chatMessages.scrollTop = chatMessages.scrollHeight;
}
async function sendToGemini() {
const input = document.getElementById('geminiInput');
const message = input.value.trim();
if (!message) return;
addMessage('user', message);
input.value = '';
const loadingMsg = document.createElement('div');
loadingMsg.className = 'message assistant';
loadingMsg.innerHTML = 'β¨ Gemini: Thinking...';
loadingMsg.id = 'loading-message';
document.getElementById('chatMessages').appendChild(loadingMsg);
try {
const response = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=${aiModalState.apiKey}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
contents: [{
parts: [{
text: `Context: User is using a Vaccine Schedule Tracker tool on WIA Pin Code platform. The tool helps families track vaccination schedules following CDC guidelines, manage immunization records, and monitor family health. WIA Pin Code is a universal address system for countries without postal codes.
Vaccine Schedule Tracker features:
- Family member management and age-based vaccine recommendations
- CDC-compliant vaccination schedules for all age groups
- Immunization record tracking and history management
- Vaccine reminders and due date monitoring
User question: ${message}
Please provide helpful, accurate health information while noting this is educational content and not medical advice. Always recommend consulting healthcare providers for medical decisions.`
}]
}],
generationConfig: {
temperature: 0.7,
maxOutputTokens: 1000
}
})
});
const data = await response.json();
document.getElementById('loading-message').remove();
if (data.candidates && data.candidates[0] && data.candidates[0].content) {
const reply = data.candidates[0].content.parts[0].text;
addMessage('assistant', reply);
} else {
addMessage('assistant', 'Sorry, I could not generate a response. Please try again.');
}
} catch (error) {
document.getElementById('loading-message')?.remove();
if (error.message.includes('API key')) {
addMessage('error', 'Invalid API key. Please check your API key and try again.');
showAPIKeySetup();
} else {
addMessage('error', 'Failed to connect to Gemini. Please check your internet connection and try again.');
}
}
}
// ========== EVENT LISTENERS ==========
document.addEventListener('DOMContentLoaded', function() {
// Initialize the tool
updateFamilyMembersList();
updateFamilyOverview();
updateRecordDropdowns();
// Set today's date as default for vaccine recording
document.getElementById('recordDate').value = new Date().toISOString().split('T')[0];
// AI button event
document.getElementById('aiBtn').addEventListener('click', openAIModal);
// Modal outside click
document.getElementById('aiModal').addEventListener('click', function(e) {
if (e.target === this) {
closeAIModal();
}
});
// Keyboard shortcuts
document.addEventListener('keydown', function(e) {
if (e.key === 'Enter') {
const geminiInput = document.getElementById('geminiInput');
if (document.activeElement === geminiInput) {
sendToGemini();
}
}
if (e.key === 'Escape') {
closeAIModal();
}
});
updateAPIKeyStatus();
updateCurrentYear();
updateToolCount();
});
// ========== DYNAMIC TOOL COUNT ==========
async function updateToolCount() {
try {
const response = await fetch('/api/tool-count.php');
const data = await response.json();
document.querySelectorAll('.dynamic-tools-count').forEach(el => {
el.textContent = `${data.count}+ free online tools in 211 languages. No signup, no fees, just tools that work.`;
});
document.querySelectorAll('.dynamic-count').forEach(el => {
const prefix = el.getAttribute('data-text') || '';
const suffix = el.getAttribute('data-suffix') || '';
const icon = el.textContent.split(' ')[0] || '';
el.textContent = `${icon} ${prefix} ${data.count}+ ${suffix}`;
});
} catch (error) {
const fallbackCount = 333;
document.querySelectorAll('.dynamic-tools-count').forEach(el => {
el.textContent = `${fallbackCount}+ free online tools in 211 languages. No signup, no fees, just tools that work.`;
});
document.querySelectorAll('.dynamic-count').forEach(el => {
const prefix = el.getAttribute('data-text') || '';
const suffix = el.getAttribute('data-suffix') || '';
const icon = el.textContent.split(' ')[0] || '';
el.textContent = `${icon} ${prefix} ${fallbackCount}+ ${suffix}`;
});
}
}
function updateCurrentYear() {
const currentYear = new Date().getFullYear();
document.querySelectorAll('.current-year').forEach(el => {
el.textContent = currentYear;
});
}
// ========== ANALYTICS ==========
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXX');
trackEvent('page_view', {
tool: TOOL_CONFIG.name,
category: TOOL_CONFIG.category
});