// مصفوفة لتخزين المباريات
let matches = [
{
id: 1,
homeTeam: "فريق 1",
homeLogo: "https://example.com/team1.png",
awayTeam: "فريق 2",
awayLogo: "https://example.com/team2.png",
startTime: "2025-07-26T19:00:00",
endTime: "2025-07-26T21:00:00",
score: "",
link: "match.html?id=1"
},
{
id: 2,
homeTeam: "جيرونا",
homeLogo: "https://yala-shoot-tv.live/wp-content/uploads/2025/01/2014.png",
awayTeam: "مارسيليا",
awayLogo: "https://yala-shoot-tv.live/wp-content/uploads/2025/01/222.png",
startTime: "2025-07-26T21:00:00",
endTime: "2025-07-26T23:00:00",
score: "",
link: "match.html?id=2"
}
];
// دالة لإضافة مباراة جديدة
function addMatch(homeTeam, homeLogo, awayTeam, awayLogo, startTime, endTime, score = "") {
const newId = matches.length > 0 ? Math.max(...matches.map(match => match.id)) + 1 : 1;
const newMatch = {
id: newId,
homeTeam,
homeLogo,
awayTeam,
awayLogo,
startTime,
endTime,
score,
link: `match.html?id=${newId}`
};
matches.push(newMatch);
return newMatch;
}
// دالة لعرض جميع المباريات
function displayMatches() {
matches.forEach(match => {
console.log(`
{
id: ${match.id},
homeTeam: "${match.homeTeam}",
homeLogo: "${match.homeLogo}",
awayTeam: "${match.awayTeam}",
awayLogo: "${match.awayLogo}",
startTime: "${match.startTime}",
endTime: "${match.endTime}",
score: "${match.score}",
link: "${match.link}"
},
`);
});
}
// دالة للبحث عن مباراة بواسطة ID
function findMatchById(id) {
return matches.find(match => match.id === id);
}
// دالة لتوليد HTML لعرض المباريات
function generateMatchesHTML() {
const container = document.getElementById('matches-container');
if (!container) return;
container.innerHTML = '';
matches.forEach(match => {
const matchElement = document.createElement('div');
matchElement.className = 'match';
matchElement.innerHTML = `
${match.homeTeam}
${match.awayTeam}
VS
${new Date(match.startTime).toLocaleString()}
${match.score || 'لم تبدأ بعد'}
مشاهدة المباراة
`;
container.appendChild(matchElement);
});
}
// مثال على إضافة مباراة جديدة
addMatch(
"برشلونة",
"https://example.com/barcelona.png",
"ريال مدريد",
"https://example.com/realmadrid.png",
"2025-07-27T21:00:00",
"2025-07-27T23:00:00"
);
// عرض المباريات في الكونسول
displayMatches();
// توليد HTML عند تحميل الصفحة
document.addEventListener('DOMContentLoaded', generateMatchesHTML);