function getStanding() {
getData('fixtures/' + fixtureId + '/analysis/standing',
null,
(data) => {
// console.log(data);
if (!data?.list?.length) {
return;
}
const teams = {};
for (const k in data.labels) {
const value = data.labels[k];
teams[value.team] = {
label: value.name,
data: [],
};
}
for (const k in data.list) {
const value = data.list[k];
if(!teams[value.team]){
teams[value.team] = {
label: value.name,
data: [],
};
}
teams[value.team]['data'].push(value);
}
const cls = {
'ทีมเหย้า': 'text-team-home',
'ทีมเยือน': 'text-team-away',
};
let html = `
ตารางคะแนน
`;
html += ``;
if (teams.other?.data?.length) {
html += `
`;
html += `
`;
html += ``;
html += ``;
html += `อันดับ | `;
html += `ทีม | `;
html += `นัด | `;
html += `ชนะ | `;
html += `เสมอ | `;
html += `แพ้ | `;
html += `ได้ | `;
html += `เสีย | `;
html += `แต้ม | `;
html += `
`;
html += ``;
html += ``;
for (const key in teams.other.data) {
const item = teams.other.data[key];
html += ``;
html += `${item.rank} | `;
html += `${item.team_name} | `;
html += `${item.gp} | `;
html += `${item.w} | `;
html += `${item.d} | `;
html += `${item.l} | `;
html += `${item.gf} | `;
html += `${item.ga} | `;
html += `${item.p} | `;
html += `
`;
}
html += ``;
html += `
`;
html += `
`;
}
for (const key in teams) {
if (key === 'home' || key === 'away') {
const team = teams[key];
html += `
`;
html += `
`;
html += ``;
html += ``;
html += ``;
html += `${team['label'] ?? ''}`;
html += ` | `;
html += `
`;
html += ``;
html += `เต็มรอบ | `;
html += `นัด | `;
html += `ชนะ | `;
html += `เสมอ | `;
html += `แพ้ | `;
html += `ได้ | `;
html += `เสีย | `;
html += `แต้ม | `;
html += `อันดับ | `;
html += `Rate | `;
html += `
`;
html += ``;
html += ``;
for (const key2 in team.data) {
const item = team.data[key2];
html += ``;
html += `${item.type} | `;
html += `${item.gp} | `;
html += `${item.w} | `;
html += `${item.d} | `;
html += `${item.l} | `;
html += `${item.gf} | `;
html += `${item.ga} | `;
html += `${item.p} | `;
html += `${item.rank} | `;
html += `${item.rate} | `;
html += `
`;
}
html += ``;
html += `
`;
html += `
`;
}
}
html += `
`;
// console.log(html);
$('#standingSection').html(html);
},
(error) => {
console.log(error);
});
}