Spaces:
Running
Running
File size: 8,963 Bytes
fb33344 |
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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
// Search functionality for the TN Medical Connect site
document.addEventListener('DOMContentLoaded', function() {
// Set up search forms
const searchForms = document.querySelectorAll('.search-form');
searchForms.forEach(form => {
form.addEventListener('submit', function(e) {
e.preventDefault();
const searchInput = this.querySelector('input[type="text"]');
const searchTerm = searchInput.value.trim();
if (searchTerm) {
// Get search category if available (podcasts, research, etc.)
const category = this.dataset.category || '';
const finalSearchTerm = category ? `${category} ${searchTerm}` : searchTerm;
// Show loading state
const resultsContainer = document.getElementById('search-results');
if (resultsContainer) {
resultsContainer.innerHTML = '<div class="text-center py-4"><i class="fas fa-spinner fa-spin text-primary text-2xl"></i><p class="mt-2 text-gray-600">Searching...</p></div>';
}
// In a real implementation, this would call a server-side API
// For this demo, we'll simulate results after a delay
setTimeout(() => {
simulateSearchResults(finalSearchTerm, resultsContainer);
}, 1000);
}
});
});
// Function to simulate search results (in a real app, this would call the server)
function simulateSearchResults(searchTerm, container) {
if (!container) return;
// Simulate different results based on search term
const termLower = searchTerm.toLowerCase();
if (termLower.includes('podcast') || termLower.includes('audio')) {
showPodcastResults(container);
} else if (termLower.includes('research') || termLower.includes('paper') || termLower.includes('study')) {
showResearchResults(container);
} else if (termLower.includes('ai') || termLower.includes('artificial intelligence')) {
showAIResults(container);
} else {
showGeneralResults(container);
}
}
// Simulate podcast results
function showPodcastResults(container) {
container.innerHTML = `
<h3 class="text-xl font-semibold text-gray-800 mb-4">Search Results</h3>
<div class="grid gap-4 md:grid-cols-2">
<div class="p-4 bg-gray-50 border border-gray-200 rounded-lg">
<h4 class="text-lg font-medium">Recent Advances in Cardiology</h4>
<p class="text-sm text-gray-600">A discussion with Dr. Ramesh about the latest treatments.</p>
<audio controls class="mt-2 w-full">
<source src="#" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</div>
<div class="p-4 bg-gray-50 border border-gray-200 rounded-lg">
<h4 class="text-lg font-medium">Public Health Initiatives in Tamil Nadu</h4>
<p class="text-sm text-gray-600">How local communities are benefiting from new programs.</p>
<audio controls class="mt-2 w-full">
<source src="#" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</div>
</div>
`;
}
// Simulate research results
function showResearchResults(container) {
container.innerHTML = `
<h3 class="text-xl font-semibold text-gray-800 mb-4">Research Results</h3>
<div class="space-y-4">
<div class="p-4 bg-gray-50 border border-gray-200 rounded-lg">
<h4 class="text-lg font-medium">Impact of Climate Change on Vector-borne Diseases in South India</h4>
<p class="text-sm text-gray-500">Journal of Tropical Medicine • March 2025</p>
<p class="text-sm text-gray-600 mt-1">This study examines the correlation between rising temperatures and the spread of dengue and malaria in Tamil Nadu.</p>
<a href="#" class="text-primary text-sm hover:underline mt-2 inline-block">Read Abstract</a>
</div>
<div class="p-4 bg-gray-50 border border-gray-200 rounded-lg">
<h4 class="text-lg font-medium">Efficacy of Traditional Medicines in Managing Type 2 Diabetes</h4>
<p class="text-sm text-gray-500">Indian Journal of Medical Research • January 2025</p>
<p class="text-sm text-gray-600 mt-1">A randomized controlled trial comparing traditional herbal preparations with standard pharmaceutical interventions.</p>
<a href="#" class="text-primary text-sm hover:underline mt-2 inline-block">Read Abstract</a>
</div>
</div>
`;
}
// Simulate AI results
function showAIResults(container) {
container.innerHTML = `
<h3 class="text-xl font-semibold text-gray-800 mb-4">AI in Healthcare Results</h3>
<div class="space-y-4">
<div class="p-4 bg-gray-50 border border-gray-200 rounded-lg">
<h4 class="text-lg font-medium">AI-Powered Diagnostic Tools for Rural Healthcare</h4>
<p class="text-sm text-gray-600 mt-1">How machine learning is helping bridge the healthcare gap in remote areas of Tamil Nadu.</p>
<div class="flex justify-between items-center mt-2">
<span class="text-xs text-gray-500">Resource Type: Case Study</span>
<a href="#" class="text-primary text-sm hover:underline">View Details</a>
</div>
</div>
<div class="p-4 bg-gray-50 border border-gray-200 rounded-lg">
<h4 class="text-lg font-medium">Implementing AI Chatbots in Patient Triage</h4>
<p class="text-sm text-gray-600 mt-1">A guide for hospitals looking to adopt AI-powered patient screening systems.</p>
<div class="flex justify-between items-center mt-2">
<span class="text-xs text-gray-500">Resource Type: Implementation Guide</span>
<a href="#" class="text-primary text-sm hover:underline">View Details</a>
</div>
</div>
</div>
`;
}
// General mixed results
function showGeneralResults(container) {
container.innerHTML = `
<h3 class="text-xl font-semibold text-gray-800 mb-4">Search Results</h3>
<div class="space-y-4">
<div class="p-4 bg-gray-50 border border-gray-200 rounded-lg">
<h4 class="text-lg font-medium">Upcoming Medical Conferences in Chennai</h4>
<p class="text-sm text-gray-600">View the schedule of medical conferences happening in the next 6 months.</p>
<a href="#" class="text-primary text-sm hover:underline mt-2 inline-block">View Calendar</a>
</div>
<div class="p-4 bg-gray-50 border border-gray-200 rounded-lg">
<h4 class="text-lg font-medium">Grant Opportunities for Medical Researchers</h4>
<p class="text-sm text-gray-600">Current funding opportunities for research in various medical fields.</p>
<a href="#" class="text-primary text-sm hover:underline mt-2 inline-block">Browse Grants</a>
</div>
<div class="p-4 bg-gray-50 border border-gray-200 rounded-lg">
<h4 class="text-lg font-medium">Latest Podcast: Healthcare Challenges in 2025</h4>
<p class="text-sm text-gray-600">A discussion with leading experts about what to expect this year.</p>
<a href="#" class="text-primary text-sm hover:underline mt-2 inline-block">Listen Now</a>
</div>
</div>
`;
}
// Initialize any search fields with the search parameter if present in URL
const urlParams = new URLSearchParams(window.location.search);
const searchParam = urlParams.get('search');
if (searchParam) {
const searchInputs = document.querySelectorAll('.search-form input[type="text"]');
searchInputs.forEach(input => {
input.value = searchParam;
});
// Auto-submit the first search form if a search term is provided in URL
const firstForm = document.querySelector('.search-form');
if (firstForm) {
firstForm.dispatchEvent(new Event('submit'));
}
}
});
|