Select Git revision
matchDetail.js
Haoyu Sun authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
matchDetail.js 1.29 KiB
const urlParams = new URLSearchParams(window.location.search);
const matchId = urlParams.get(`id`);
// 获取比赛详情
async function fetchMatchDetails(id) {
try {
const response = await fetch(`/match/${id}`);
const matchData = await response.json();
const matchInfo = document.getElementById('matchInfo');
const matchScore = document.getElementById('matchScore');
// btn give the id
const updateBtn = document.getElementById("updateBtn");
updateBtn.addEventListener('click', function (){
window.location.href = `/html/matchDetailChangeScore.html?id=${id}`;
})
matchScore.innerHTML = `<p><strong></strong>${matchData.scoreA} - ${matchData.scoreB}</p>
`
matchInfo.innerHTML = `
<p><strong>Sport: </strong>${matchData.sport}</p>
<p><strong>Players: </strong>${matchData.playerAId} vs ${matchData.playerBId}</p>
<p><strong>Scheduled Time: </strong>${new Date(matchData.planTime).toLocaleString()}</p>
<p><strong>Status: </strong>${matchData.status}</p>
<p><strong>Winner: </strong>${matchData.winnerId ? matchData.winnerId : 'N/A'}</p>
`;
} catch (error) {
console.error('Error fetching match details:', error);
}
}
fetchMatchDetails(matchId);