28 lines
939 B
JavaScript
28 lines
939 B
JavaScript
const xhr = new XMLHttpRequest()
|
|
|
|
xhr.open('GET', 'https://angels-dev.fr/twitch/panel/data', true)
|
|
xhr.onload = () => {
|
|
if (xhr.status === 200) {
|
|
let data = JSON.parse(xhr.responseText)
|
|
|
|
let tbodyRef = document.getElementById('table').getElementsByTagName('tbody')[0]
|
|
|
|
for (entry of data.scoreboard) {
|
|
let row = tbodyRef.insertRow()
|
|
|
|
row.insertCell().appendChild(document.createTextNode(data.scoreboard.indexOf(entry) + 1))
|
|
row.insertCell().appendChild(document.createTextNode(entry.viewer_name))
|
|
row.insertCell().appendChild(document.createTextNode(entry.count))
|
|
|
|
let i = 0
|
|
for (cell of row.cells) {
|
|
i++
|
|
if (i === 1) cell.className = "row__rank"
|
|
if (i === 2) cell.className = "row__pseudos"
|
|
if (i === 3) cell.className = "row__arrows"
|
|
}
|
|
}
|
|
} else console.error('Error:', xhr.statusText)
|
|
}
|
|
xhr.onerror = () => { console.error('Error:', xhr.statusText) }
|
|
xhr.send() |