
<style>
body {font-family: Arial, Helvetica, sans-serif;}h1 {text-align: center;}
.container {display: flex;justify-content: center;align-items: center;flex-direction: column;}.form-container {display: flex;justify-content: center;align-items: center;flex-direction: column;gap: 1rem;}.input-container {display: flex;justify-content: center;align-items: center;gap: 1rem;}.inputcontainer">
<script>const form = document.getElementById('form');const results = document.getElementById('results');const resultsHeading = document.getElementById('results-heading');const resultsList = document.getElementById('results-list');form.addEventListener('submit', (e) => {e.preventDefault();const teamInput = document.getElementById('team').value;const matchInput = document.getElementById('match').value;if (!teamInput && !matchInput) {alert('請至少提供一個查詢條件。');return;}results.classList.remove('visually-hidden');let query = '';if (teamInput) {query += `team=${teamInput}`;}if (matchInput) {if (query) {query += '&';}query += `match=${matchInput}`;}const url = `${query}`;const headers = {'X-Auth-Token': '3674039c3f1240a88d8353b43a33bdd3'};fetch(url, { headers }).then(res => res.json()).then(data => {if (data.count === 0) {resultsHeading.innerText = `沒有找到與 "${teamInput || matchInput}" 匹配的結果。`;} else {resultsHeading.innerText = `查詢結果:`;data.matches.forEach(match => {const resultItem = document.createElement('li');resultItem.classList.add('result-item');resultItem.innerHTML = `
${match.homeTeam.name} ${match.score.fullTime.homeTeam} - ${match.score.fullTime.awayTeam} ${match.awayTeam.name}${match.competition.name}`;resultsList.appendChild(resultItem);});}}).catch(err => {alert('查詢失敗。請稍后再試。');console.error(err);});});form.addEventListener('reset', () => {window.location.reload();});</script>