const matches = [ { title: "Betfred World Matchplay", page: "dartsevent1.html" }, { title: "Betfred World Matchplay (BACKUP)", page: "dartsevent2.html" }, { title: "Hansa Rostock vs Aston Villa", page: "footballevent1.html" }, { title: "Celtic vs Newcastle", page: "footballevent2.html" }, { title: "Manchester United vs Leeds", page: "footballevent3.html" }, { title: "Bournemouth vs Bristol", page: "footballevent4.html" }, { title: "Grasshopper vs West Ham", page: "footballevent5.html" }, { title: "Blackburn vs Everton", page: "footballevent6.html" }, { title: "Reading vs Tottenham Hotspur", page: "footballevent7.html" }, { title: "Nottingham Forest vs Monaco", page: "footballevent8.html" }, { title: "", page: "footballevent9.html" }, { title: "Usyk vs Dubois 2", page: "fightingevent1.html" }, { title: "UFC 318: Max Holloway vs Dustin Poirier", page: "fightingevent2.html" }, { title: "Manny Pacquiao vs Mario Barrios", page: "fightingevent3.html" }, { title: "Sky Sports MotoGP", page: "motorsportsevent1.html" }, { title: "Sky Sports Formula 1", page: "motorsportsevent2.html" }, { title: "Sky Sports Cricket", page: "otherevent1.html" }, { title: "Sky Sports Golf", page: "otherevent2.html" }, { title: "Sky Sports Tennis", page: "otherevent3.html" }, { title: "Sky Sports Action", page: "otherevent4.html" }, { title: "24/7 South Park", page: "247event1.html" }, { title: "24/7 The Simpsons", page: "247event2.html" }, { title: "24/7 Family Guy", page: "247event3.html" }, { title: "24/7 Spongebob Squarepants", page: "247event4.html" }, { title: "24/7 Dragonball Z", page: "247event5.html" }, { title: "Cartoon Network", page: "247event6.html" }, { title: "DAZN 1", page: "247event7.html" }, { title: "ESPN", page: "247event8.html" }, { title: "Bein Sports", page: "247event9.html" }, { title: "NBA TV", page: "247event10.html" }, { title: "CBS Sports", page: "247event11.html" }, { title: "Darts", page: "darts.html" }, { title: "Football", page: "football.html" }, { title: "Fighting", page: "fighting.html" }, { title: "Motorsports", page: "motorsports.html" }, { title: "Other", page: "other.html" }, { title: "24/7 TV", page: "247page.html" } ]; const inputField = document.getElementById("eventSearch"); const suggestionBox = document.getElementById("suggestions"); let currentIndex = -1; let filtered = []; function showSuggestions() { const input = inputField.value.toLowerCase().trim(); suggestionBox.innerHTML = ""; currentIndex = -1; filtered = matches .filter(match => match.title.toLowerCase().includes(input)) .slice(0, 5); if (!input) { suggestionBox.classList.remove("active"); return; } if (filtered.length === 0) { const div = document.createElement("div"); div.className = "suggestion-item no-results"; div.innerText = "No results found (Request in Discord)"; div.style.opacity = "0.5"; div.style.fontStyle = "italic"; div.style.padding = "12px 18px"; suggestionBox.appendChild(div); } else { filtered.forEach(match => { const div = document.createElement("div"); div.className = "suggestion-item"; div.innerText = match.title; div.style.padding = "12px 18px"; div.style.cursor = "pointer"; div.onclick = () => window.location.href = match.page; suggestionBox.appendChild(div); }); } suggestionBox.classList.add("active"); } function handleKey(e) { const items = suggestionBox.querySelectorAll(".suggestion-item:not(.no-results)"); if (!suggestionBox.classList.contains("active") || items.length === 0) return; if (e.key === "ArrowDown") { e.preventDefault(); if (currentIndex < items.length - 1) currentIndex++; highlightItem(items); } else if (e.key === "ArrowUp") { e.preventDefault(); if (currentIndex > 0) currentIndex--; highlightItem(items); } else if (e.key === "Enter" && currentIndex >= 0) { e.preventDefault(); items[currentIndex].click(); } } function highlightItem(items) { items.forEach(item => item.classList.remove("selected")); if (items[currentIndex]) { items[currentIndex].classList.add("selected"); items[currentIndex].scrollIntoView({ block: "nearest" }); } } document.addEventListener("click", function (e) { if (!document.getElementById("searchContainer").contains(e.target)) { suggestionBox.classList.remove("active"); } });