Can't Find Your Device?
Give us a call or request a free quote and we'll help you out!
Need Help or Have Questions?
Give us a call or request a free quote and we'll help you out!
// iPad Search
document.addEventListener("DOMContentLoaded", function() {
const searchInput = document.getElementById("ipadSearch");
const clearButton = document.getElementById("clearSearch");
const deviceGrid = document.getElementById("deviceGrid");
const searchResults = document.getElementById("searchResults");
if (!searchInput || !deviceGrid) return;
const deviceCards = deviceGrid.querySelectorAll(".device-card");
function performSearch() {
const searchTerm = searchInput.value.toLowerCase().trim();
if (searchTerm === "") {
deviceCards.forEach(card => card.classList.remove("hidden", "highlight"));
clearButton.style.display = "none";
searchResults.style.display = "none";
return;
}
clearButton.style.display = "block";
let matchCount = 0;
deviceCards.forEach(card => {
const modelName = card.querySelector("h3").textContent.toLowerCase();
const modelNumbers = (card.getAttribute("data-model") || "").toLowerCase();
if (modelName.includes(searchTerm) || modelNumbers.includes(searchTerm)) {
card.classList.remove("hidden");
card.classList.add("highlight");
matchCount++;
setTimeout(() => card.classList.remove("highlight"), 500);
} else {
card.classList.add("hidden");
}
});
if (matchCount > 0) {
searchResults.textContent = "Found " + matchCount + " iPad model" + (matchCount > 1 ? "s" : "") + ' matching "' + searchInput.value + '"';
searchResults.style.display = "block";
} else {
searchResults.style.display = "none";
}
}
function clearSearch() {
searchInput.value = "";
performSearch();
searchInput.focus();
}
searchInput.addEventListener("input", performSearch);
clearButton.addEventListener("click", clearSearch);
searchInput.addEventListener("keypress", function(e) {
if (e.key === "Enter") {
e.preventDefault();
performSearch();
}