
‎toggle‎
No definitions or references found
Skip to content
saudi-website-project
Repository navigation
Code
Issues
Pull requests
Agents
Actions
Projects
Wiki
Security and quality
Important update
On April 24 we'll start using GitHub Copilot interaction data for AI model training unless you opt out. Review this update and manage your preferences in your GitHub account settings.
saudi-website-project/js
/script.js
iRazan4
iRazan4
Improve name retrieval and clean up place data
269f8bf
 · 
2 days ago
32 lines (26 loc) · 1.02 KB

Code

Blame
function toggleMode() {
    document.body.classList.toggle("dark-mode");
}

function filterGallery() {
    var searchInput = document.getElementById("searchInput");
    var categorySelect = document.getElementById("categorySelect");
    var cards = document.querySelectorAll(".card");
    var count = 0;

    var searchText = searchInput ? searchInput.value.toLowerCase() : "";
    var category = categorySelect ? categorySelect.value : "all";

    cards.forEach(function(card) {
        var name = card.getAttribute("data-name") ? card.getAttribute("data-name").toLowerCase() : "";
        var matchSearch = name.includes(searchText);
        
        var matchCategory = category === "all" || card.classList.contains(category);

        if (matchSearch && matchCategory) {
            card.style.display = "block";
            count++;
        } else {
            card.style.display = "none";
        }
    });

    var resultCount = document.getElementById("resultCount");
    if (resultCount) {
        resultCount.textContent = count;
    }
}
