<p id="clan">No clan data</p>
<script>
fetch('/schtarr/inno.json')
- .then(res => res.json())
+ .then(res => {
+ if (res.status != 200) {
+ console.log('got %o', res)
+ throw `status ${res.status}`
+ }
+ return res.json()
+ })
.then(clan => {
+ let tiernum = (rank) => rank <= 8 ? 1 : rank <= 25 ? 2 : rank <= 50 ? 3 : 4;
document.getElementById('clan').outerHTML = `
<h1>${clan.tag}</h1>
<ul class=ladders>
${clan.ladders.map(ladder => `
- <li title="Division ${ladder.division}" class="rank ${ladder.league}">
+ <li class="rank ${ladder.league} tier${tiernum(ladder.rank)}"
+ title="Division ${ladder.division} (${ladder.wins}:${ladder.losses})">
${ladder.league} <small>#${ladder.rank}</small>
</li>
`).join('')}
}
})
})
- .catch(error => console.log(error))
+ .catch(msg => console.error('include failure:', msg))
</script>
</body>