function getPlayer(fixtureId, thn, tan, imageURL, showLastFixturePlayer) { getData('fixtures/' + fixtureId + '/analysis/player', null, (data) => { // console.log(data); if (!data?.players?.length) { return; } const teamTypes = ['home', 'away']; const teams = { 'home': { 'first-string': [], 'substitute': [] }, 'away': { 'first-string': [], 'substitute': [] }, }; const teams2 = { 'home': { 'injury': [], 'ban': [] }, 'away': { 'injury': [], 'ban': [] }, }; const players = data.players; for (const i in players) { const p = players[i]; if (p.type == 'first-string' || p.type == 'substitute') { teams[p.team][p.type].push(p); } else { teams2[p.team][p.type].push(p); } } html = ``; html += `
`; html += `

ข้อมูลบาดเจ็บและแบน

`; html += `
`; for (const i in teamTypes) { const team = teamTypes[i]; const types = teams2[team]; html += `
`; html += `
`; if (team === 'home') { html += `
`; html += `
${thn}
`; html += `
`; } else { html += `
`; html += `
${tan}
`; html += `
`; } for (const type in types) { const ps = types[type]; html += `
`; if (type == 'injury') { html += `
ผู้เล่นบาดเจ็บ
`; } else { html += `
ผู้เล่นถูกแบน
`; } html += `
`; for (const k in ps) { const p = ps[k]; html += `
`; html += `
${p.position}
`; html += `${p.no}`; html += `${p.name}`; html += `
`; } } html += `
`; html += `
`; } html += `
`; html += `
`; if (showLastFixturePlayer != false) { html += `
`; html += `

รายชื่อผู้เล่นนัดที่ผ่านมา

`; html += `
`; for (const i in teamTypes) { const team = teamTypes[i]; const types = teams[team]; html += `
`; html += `
`; if (team === 'home') { html += `
`; html += `
${thn}
`; html += `
`; } else { html += `
`; html += `
${tan}
`; html += `
`; } for (const type in types) { const ps = types[type]; html += `
`; if (type === 'first-string') { html += `
ผู้เล่น 11 ตัวจริง
`; } else { html += `
ผู้เล่นตัวสำรอง
`; } html += `
`; for (const k in ps) { const p = ps[k]; html += `
`; html += `
${p.position}
`; html += `${p.no}`; html += `${p.name}`; html += `
`; } } html += `
`; html += `
`; } html += `
`; html += `
`; } $('#playerSection').html(html); }, (error) => { console.log(error); }); }