{"id":5902,"date":"2025-07-14T18:44:36","date_gmt":"2025-07-14T16:44:36","guid":{"rendered":"https:\/\/beinbag.com\/?page_id=5902"},"modified":"2025-09-16T15:10:42","modified_gmt":"2025-09-16T13:10:42","slug":"%d9%86%d8%aa%d8%a7%d8%a6%d8%ac-%d9%85%d8%a8%d8%a7%d8%b1%d9%8a%d8%a7%d8%aa-%d8%a7%d9%84%d9%8a%d9%88%d9%85","status":"publish","type":"page","link":"https:\/\/beinbag.com\/en\/%d9%86%d8%aa%d8%a7%d8%a6%d8%ac-%d9%85%d8%a8%d8%a7%d8%b1%d9%8a%d8%a7%d8%aa-%d8%a7%d9%84%d9%8a%d9%88%d9%85\/","title":{"rendered":"Match Schedule"},"content":{"rendered":"<!-- \u0628\u062f\u0627\u064a\u0629 \u0648\u064a\u062f\u062c\u064a\u062a \u062c\u062f\u0648\u0644 \u0627\u0644\u0645\u0628\u0627\u0631\u064a\u0627\u062a -->\n<div id=\"matches-all\" style=\"direction: rtl; font-family: Tahoma, sans-serif; max-width: 980px; margin: auto; padding: 20px; background-color: #f5f5f5;\">\n  <h2 id=\"matches-title\" style=\"text-align: center; color: #333;\">Schedule of past, current and upcoming matches<\/h2>\n\n  <div style=\"text-align: center; margin-bottom: 12px;\">\n    <button onclick=\"setView('yesterday')\" style=\"padding:8px 12px; margin:0 4px;\">yesterday<\/button>\n    <button onclick=\"setView('today')\" style=\"padding:8px 12px; margin:0 4px;\">Today<\/button>\n    <button onclick=\"setView('tomorrow')\" style=\"padding:8px 12px; margin:0 4px;\">tomorrow<\/button>\n    <button onclick=\"showAllLeagues()\" style=\"padding:8px 12px; margin:0 4px;\">View all<\/button>\n  <\/div>\n\n  <div style=\"text-align:center; margin-bottom: 12px;\">\n    <input type=\"text\" id=\"match-search\" placeholder=\"\ud83d\udd0d Find a team...\" oninput=\"filterMatches()\" style=\"padding:8px;width:80%;max-width:420px;border:1px solid #ccc;border-radius:4px;\">\n  <\/div>\n\n  <div id=\"matches-content\">\ud83d\udd04 \u062c\u0627\u0631\u064a \u0627\u0644\u062a\u062d\u0645\u064a\u0644&#8230;<\/div>\n<\/div>\n\n<script>\n  const apiKey = \"c77074710daa24feb1d2554a329a68dd\";\n  let currentView = 'today';\n  let allRenderedHTML = \"\";\n  let forcedShowAll = false;\n\n  \/\/ \u0627\u0644\u062f\u0648\u0631\u064a\u0627\u062a \u0627\u0644\u0645\u0633\u0645\u0648\u062d \u0628\u0647\u0627 (\u0645\u0639 \u0625\u0636\u0627\u0641\u0629 \u0643\u0623\u0633 \u0627\u0644\u0639\u0631\u0628)\n  const allowedLeaguesKeywords = [\n    \"Premier League\",\n    \"La Liga\", \"Primera Division\", \"La Liga EA Sports\",\n    \"Serie A\",\n    \"Ligue 1\",\n    \"Bundesliga\",\n    \"UEFA Champions League\",\n    \"UEFA Europa League\",\n    \"UEFA Europa Conference League\",\n    \"FA Cup\",\n    \"EFL Cup\",\n    \"Copa del Rey\",\n    \"Major League Soccer\", \"MLS\",\n    \"J1 League\", \"J League\",\n    \"A-League\", \"Australian A-League\",\n    \"Leagues Cup\",\n    \"Roshn Saudi Pro League\",\n    \"CAF Champions League\",\n    \"Africa Cup of Nations\",\n    \"FIFA World Cup\",\n    \"World Cup Qualification\",\n    \"FIFA Club World Cup\",\n    \"FIFA Arab Cup\", \"\u0643\u0623\u0633 \u0627\u0644\u0639\u0631\u0628\" \/\/ \u2190 \u0625\u0636\u0627\u0641\u0629 \u0643\u0623\u0633 \u0627\u0644\u0639\u0631\u0628\n  ];\n\n  const africanTeams = [\n    \"Morocco\",\"Algeria\",\"Tunisia\",\"Libya\",\"Egypt\",\"Senegal\",\"Cameroon\",\"Nigeria\",\"Ghana\",\n    \"Ivory Coast\",\"C\u00f4te d'Ivoire\",\"Mali\",\"South Africa\",\"DR Congo\",\"Zambia\",\"Guinea\",\n    \"Burkina Faso\",\"Mauritania\",\"Cape Verde\",\"Tanzania\",\"Gabon\",\"Angola\",\"Equatorial Guinea\",\n    \"Sudan\",\"Ethiopia\",\"Uganda\",\"Kenya\",\"Central African Republic\",\"Benin\",\"Mozambique\",\"Zimbabwe\"\n  ];\n\n  const specialClubs = [\"Real Madrid\", \"Barcelona\", \"\u0631\u064a\u0627\u0644 \u0645\u062f\u0631\u064a\u062f\", \"\u0628\u0631\u0634\u0644\u0648\u0646\u0629\"];\n\n  const translations = {\n    \"La Liga\": \"\u0627\u0644\u062f\u0648\u0631\u064a \u0627\u0644\u0625\u0633\u0628\u0627\u0646\u064a\",\n    \"La Liga EA Sports\": \"\u0627\u0644\u062f\u0648\u0631\u064a \u0627\u0644\u0625\u0633\u0628\u0627\u0646\u064a\",\n    \"Primera Division\": \"\u0627\u0644\u062f\u0648\u0631\u064a \u0627\u0644\u0625\u0633\u0628\u0627\u0646\u064a\",\n    \"Premier League\": \"\u0627\u0644\u062f\u0648\u0631\u064a \u0627\u0644\u0625\u0646\u062c\u0644\u064a\u0632\u064a \u0627\u0644\u0645\u0645\u062a\u0627\u0632\",\n    \"Serie A\": \"\u0627\u0644\u062f\u0648\u0631\u064a \u0627\u0644\u0625\u064a\u0637\u0627\u0644\u064a\",\n    \"Ligue 1\": \"\u0627\u0644\u062f\u0648\u0631\u064a \u0627\u0644\u0641\u0631\u0646\u0633\u064a\",\n    \"Bundesliga\": \"\u0627\u0644\u062f\u0648\u0631\u064a \u0627\u0644\u0623\u0644\u0645\u0627\u0646\u064a\",\n    \"UEFA Champions League\": \"\u062f\u0648\u0631\u064a \u0623\u0628\u0637\u0627\u0644 \u0623\u0648\u0631\u0648\u0628\u0627\",\n    \"UEFA Europa League\": \"\u0627\u0644\u062f\u0648\u0631\u064a \u0627\u0644\u0623\u0648\u0631\u0648\u0628\u064a\",\n    \"UEFA Europa Conference League\": \"\u062f\u0648\u0631\u064a \u0627\u0644\u0645\u0624\u062a\u0645\u0631 \u0627\u0644\u0623\u0648\u0631\u0648\u0628\u064a\",\n    \"FA Cup\": \"\u0643\u0623\u0633 \u0625\u0646\u062c\u0644\u062a\u0631\u0627\",\n    \"EFL Cup\": \"\u0643\u0623\u0633 \u0627\u0644\u0631\u0627\u0628\u0637\u0629 \u0627\u0644\u0625\u0646\u062c\u0644\u064a\u0632\u064a\u0629\",\n    \"Copa del Rey\": \"\u0643\u0623\u0633 \u0625\u0633\u0628\u0627\u0646\u064a\u0627\",\n    \"Major League Soccer\": \"\u0627\u0644\u062f\u0648\u0631\u064a \u0627\u0644\u0623\u0645\u0631\u064a\u0643\u064a \u0644\u0644\u0645\u062d\u062a\u0631\u0641\u064a\u0646 (MLS)\",\n    \"MLS\": \"\u0627\u0644\u062f\u0648\u0631\u064a \u0627\u0644\u0623\u0645\u0631\u064a\u0643\u064a \u0644\u0644\u0645\u062d\u062a\u0631\u0641\u064a\u0646 (MLS)\",\n    \"J1 League\": \"\u0627\u0644\u062f\u0648\u0631\u064a \u0627\u0644\u064a\u0627\u0628\u0627\u0646\u064a (J1)\",\n    \"J League\": \"\u0627\u0644\u062f\u0648\u0631\u064a \u0627\u0644\u064a\u0627\u0628\u0627\u0646\u064a\",\n    \"A-League\": \"\u0627\u0644\u062f\u0648\u0631\u064a \u0627\u0644\u0623\u0633\u062a\u0631\u0627\u0644\u064a\",\n    \"Australian A-League\": \"\u0627\u0644\u062f\u0648\u0631\u064a \u0627\u0644\u0623\u0633\u062a\u0631\u0627\u0644\u064a\",\n    \"Leagues Cup\": \"\u0643\u0623\u0633 \u0627\u0644\u062f\u0648\u0631\u064a\u0627\u062a\",\n    \"Roshn Saudi Pro League\": \"\u062f\u0648\u0631\u064a \u0631\u0648\u0634\u0646 \u0627\u0644\u0633\u0639\u0648\u062f\u064a\",\n    \"CAF Champions League\": \"\u062f\u0648\u0631\u064a \u0623\u0628\u0637\u0627\u0644 \u0625\u0641\u0631\u064a\u0642\u064a\u0627\",\n    \"Africa Cup of Nations\": \"\u0643\u0623\u0633 \u0623\u0645\u0645 \u0625\u0641\u0631\u064a\u0642\u064a\u0627\",\n    \"FIFA World Cup\": \"\u0643\u0623\u0633 \u0627\u0644\u0639\u0627\u0644\u0645\",\n    \"World Cup Qualification\": \"\u062a\u0635\u0641\u064a\u0627\u062a \u0643\u0623\u0633 \u0627\u0644\u0639\u0627\u0644\u0645\",\n    \"FIFA Club World Cup\": \"\u0643\u0623\u0633 \u0627\u0644\u0639\u0627\u0644\u0645 \u0644\u0644\u0623\u0646\u062f\u064a\u0629\",\n    \"FIFA Arab Cup\": \"\u0643\u0623\u0633 \u0627\u0644\u0639\u0631\u0628\",\n    \"\u0643\u0623\u0633 \u0627\u0644\u0639\u0631\u0628\": \"\u0643\u0623\u0633 \u0627\u0644\u0639\u0631\u0628\"\n  };\n\n  function translate(text) {\n    return translations[text] || text;\n  }\n\n  function formatDate(d) {\n    return d.toISOString().split(\"T\")[0];\n  }\n\n  function getDateStr(key) {\n    const d = new Date();\n    if (key === 'yesterday') d.setDate(d.getDate() - 1);\n    if (key === 'tomorrow') d.setDate(d.getDate() + 1);\n    return formatDate(d);\n  }\n\n  function setView(key) {\n    currentView = key;\n    forcedShowAll = false;\n    loadMatches();\n  }\n\n  function showAllLeagues() {\n    forcedShowAll = true;\n    loadMatches();\n  }\n\n  function getTeamLogo(logoUrl) {\n    return logoUrl && logoUrl.trim() !== \"\" ? logoUrl : \"https:\/\/via.placeholder.com\/24?text=\u061f\";\n  }\n\n  function renderMatches(matches) {\n    const now = new Date(), grouped = {};\n\n    matches.forEach(m => {\n      const leagueOriginal = m.league && m.league.name ? m.league.name : \"\";\n      const leagueTranslated = translate(leagueOriginal);\n      const homeName = m.teams && m.teams.home ? m.teams.home.name : \"\";\n      const awayName = m.teams && m.teams.away ? m.teams.away.name : \"\";\n\n      const isAllowedLeague = allowedLeaguesKeywords.some(l => leagueOriginal.includes(l));\n      const isAfricanMatch = africanTeams.includes(homeName) || africanTeams.includes(awayName);\n      const isSpecialClub = specialClubs.includes(homeName) || specialClubs.includes(awayName);\n\n      if (!forcedShowAll && !(isAllowedLeague || isAfricanMatch || isSpecialClub)) return;\n\n      const matchDate = new Date(m.fixture.date);\n      const diffH = Math.abs(now - matchDate) \/ (1000 * 60 * 60);\n      if (diffH > 48) return;\n\n      const key = leagueTranslated || leagueOriginal || \"\u062f\u0648\u0631\u064a \/ \u0645\u0633\u0627\u0628\u0642\u0629 \u0623\u062e\u0631\u0649\";\n      grouped[key] = grouped[key] || [];\n      grouped[key].push(m);\n    });\n\n    const container = document.getElementById(\"matches-content\");\n    if (!Object.keys(grouped).length) {\n      container.innerHTML = `<div style='text-align:center;color:red;padding:20px;'>\u274c \u0644\u0627 \u062a\u0648\u062c\u062f \u0645\u0628\u0627\u0631\u064a\u0627\u062a ${(currentView === 'today' ? '\u0627\u0644\u064a\u0648\u0645' : currentView === 'yesterday' ? '\u0623\u0645\u0633' : '\u063a\u062f\u064b\u0627')}<\/div>`;\n      return;\n    }\n\n    let html = \"\";\n    Object.keys(grouped).forEach(league => {\n      html += `<div class=\"league-group\" style=\"margin-bottom:20px;border-bottom:1px solid #ddd;\">\n        <h3 style=\"background:#2c2c2c;color:#fff;padding:10px;border-radius:4px;\">\ud83c\udfc6 ${league}<\/h3>`;\n      grouped[league].forEach(m => {\n        const home = { ...m.teams.home, name: translate(m.teams.home.name) };\n        const away = { ...m.teams.away, name: translate(m.teams.away.name) };\n        const time = new Date(m.fixture.date).toLocaleTimeString(\"ar-MA\", { hour: \"2-digit\", minute: \"2-digit\", timeZone: \"Africa\/Casablanca\" });\n        const isFinished = [\"FT\", \"FT_PEN\", \"AET\"].includes(m.fixture.status && m.fixture.status.short);\n        const result = isFinished ? `${m.goals.home} - ${m.goals.away}` : time;\n\n        html += `\n          <div class=\"match-item\" data-names=\"${home.name.toLowerCase()} ${away.name.toLowerCase()}\" style=\"display:flex;justify-content:space-between;align-items:center;padding:8px;background:#fff;margin:4px 0;border-radius:4px;\">\n            <div style=\"width:35%;display:flex;align-items:center;\">\n              <img decoding=\"async\" src=\"${getTeamLogo(home.logo)}\" style=\"width:24px;height:24px;margin-right:6px;\" alt=\"${home.name}\"> ${home.name}\n            <\/div>\n            <div style=\"width:20%;text-align:center;font-weight:bold;color:#d00;\">${result}<\/div>\n            <div style=\"width:35%;display:flex;align-items:center;justify-content:flex-end;\">\n              ${away.name} <img decoding=\"async\" src=\"${getTeamLogo(away.logo)}\" style=\"width:24px;height:24px;margin-left:6px;\" alt=\"${away.name}\">\n            <\/div>\n          <\/div>`;\n      });\n      html += `<\/div>`;\n    });\n\n    allRenderedHTML = html;\n    container.innerHTML = html;\n  }\n\n  function filterMatches() {\n    const query = document.getElementById(\"match-search\").value.toLowerCase().trim();\n    const container = document.getElementById(\"matches-content\");\n\n    if (!query) {\n      container.innerHTML = allRenderedHTML;\n      return;\n    }\n\n    const tempDiv = document.createElement(\"div\");\n    tempDiv.innerHTML = allRenderedHTML;\n\n    const leagues = tempDiv.querySelectorAll(\".league-group\");\n\n    leagues.forEach(league => {\n      const matches = league.querySelectorAll(\".match-item\");\n      let hasMatch = false;\n\n      matches.forEach(match => {\n        const names = match.dataset.names;\n        if (names.includes(query)) {\n          match.style.display = \"flex\";\n          hasMatch = true;\n        } else {\n          match.style.display = \"none\";\n        }\n      });\n\n      league.style.display = hasMatch ? \"block\" : \"none\";\n    });\n\n    container.innerHTML = tempDiv.innerHTML;\n  }\n\n  async function loadMatches() {\n    const d = getDateStr(currentView);\n    document.getElementById(\"matches-content\").innerHTML = \"\ud83d\udd04 \u062c\u0627\u0631\u064a \u0627\u0644\u062a\u062d\u0645\u064a\u0644...\";\n    try {\n      const res = await fetch(`https:\/\/v3.football.api-sports.io\/fixtures?date=${d}`, {\n        headers: { \"x-apisports-key\": apiKey }\n      });\n      const data = await res.json();\n      renderMatches(data.response || []);\n    } catch (e) {\n      console.error(e);\n      document.getElementById(\"matches-content\").innerHTML = `<div style='text-align:center;color:red;'>\u26a0\ufe0f \u0641\u0634\u0644 \u0627\u0644\u062a\u062d\u0645\u064a\u0644.<\/div>`;\n    }\n  }\n\n  loadMatches();\n  setInterval(loadMatches, 300000);\n<\/script>\n<!-- \u0646\u0647\u0627\u064a\u0629 \u0648\u064a\u062f\u062c\u064a\u062a \u062c\u062f\u0648\u0644 \u0627\u0644\u0645\u0628\u0627\u0631\u064a\u0627\u062a -->\n\n\n\n\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>\u062c\u062f\u0648\u0644 \u0627\u0644\u0645\u0628\u0627\u0631\u064a\u0627\u062a \u0627\u0644\u0633\u0627\u0628\u0642\u0629 \u0648\u0627\u0644\u062d\u0627\u0644\u064a\u0629 \u0648\u0627\u0644\u0645\u0642\u0628\u0644\u0629 \u0627\u0644\u0628\u0627\u0631\u062d\u0629 \u0627\u0644\u064a\u0648\u0645 \u063a\u062f\u064b\u0627 \u0639\u0631\u0636 \u0627\u0644\u0643\u0644 \ud83d\udd04 \u062c\u0627\u0631\u064a \u0627\u0644\u062a\u062d\u0645\u064a\u0644&#8230;<\/p>","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"class_list":["post-5902","page","type-page","status-publish","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/beinbag.com\/en\/wp-json\/wp\/v2\/pages\/5902","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/beinbag.com\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/beinbag.com\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/beinbag.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/beinbag.com\/en\/wp-json\/wp\/v2\/comments?post=5902"}],"version-history":[{"count":108,"href":"https:\/\/beinbag.com\/en\/wp-json\/wp\/v2\/pages\/5902\/revisions"}],"predecessor-version":[{"id":6282,"href":"https:\/\/beinbag.com\/en\/wp-json\/wp\/v2\/pages\/5902\/revisions\/6282"}],"wp:attachment":[{"href":"https:\/\/beinbag.com\/en\/wp-json\/wp\/v2\/media?parent=5902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}