// IIFE to avoid global scope pollution
(function() {
const searchInput = document.getElementById('mandal-search');
const filterContainer = document.getElementById('alphabet-filter');
const mandalCards = document.querySelectorAll('.mandal-link-card');
const divisionSections = document.querySelectorAll('.division-section');
// Function to filter mandals based on search input
function filterMandalsBySearch(query) {
const queryLowerCase = query.toLowerCase();
// Iterate through each mandal card to hide or show it
mandalCards.forEach(card => {
const mandalName = card.getAttribute('data-mandal-name').toLowerCase();
if (mandalName.includes(queryLowerCase)) {
card.style.display = ''; // Show the card
} else {
card.style.display = 'none'; // Hide the card
}
});
// Check and hide/show parent division sections if they are empty
divisionSections.forEach(section => {
const visibleCards = section.querySelectorAll('.mandal-link-card:not([style*="display: none"])');
if (visibleCards.length === 0) {
section.style.display = 'none';
} else {
section.style.display = '';
}
});
}
// Function to filter mandals based on the alphabet button clicked
function filterMandalsByLetter(letter) {
// First, show all mandal cards and division sections
mandalCards.forEach(card => card.style.display = '');
divisionSections.forEach(section => section.style.display = '');
// If a letter is selected, filter the mandals
if (letter !== 'all') {
const letterUpperCase = letter.toUpperCase();
mandalCards.forEach(card => {
const mandalName = card.getAttribute('data-mandal-name');
if (!mandalName.startsWith(letterUpperCase)) {
card.style.display = 'none'; // Hide mandals that don't start with the letter
}
});
// Hide parent division sections that have no visible cards
divisionSections.forEach(section => {
const visibleCards = section.querySelectorAll('.mandal-link-card:not([style*="display: none"])');
if (visibleCards.length === 0) {
section.style.display = 'none';
}
});
}
}
// Add event listener for the search input
searchInput.addEventListener('input', (event) => {
// When searching, deactivate all letter buttons and filter by the search query
document.querySelectorAll('.alphabet-filter button').forEach(btn => btn.classList.remove('active'));
filterMandalsBySearch(event.target.value);
});
// Add event listener for the alphabetical filter buttons
filterContainer.addEventListener('click', (event) => {
if (event.target.tagName === 'BUTTON') {
// Remove 'active' class from all buttons
document.querySelectorAll('.alphabet-filter button').forEach(btn => btn.classList.remove('active'));
// Add 'active' class to the clicked button
event.target.classList.add('active');
// Clear search input when a letter is clicked
searchInput.value = '';
const letter = event.target.getAttribute('data-letter');
filterMandalsByLetter(letter);
}
});
})();
Open Hours of Government: Mon - Fri: 8.00 am. - 6.00 pm.
Japan Technology Smart Toilets – First of Its Kind in India
Organized by Children’s Development Educational Changing Trust (CDECT)
Empanelled with the Ministry of Social Justice & Empowerment, Government of India
00
Days
00
Hours
00
Minutes
00
Seconds
October 15, 2025
4:45 PM
Social Welfare Girls’ Hostel, Guntur
Tribute to Dr. A.P.J. Abdul Kalam
On his birth anniversary, we honor the visionary who inspired a nation. This foundation symbolizes his vision of a Clean, Educated, and Empowered India.