git.shiar.nl
/
sc2-widget
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
prefer get parameter for apache redirects
[sc2-widget]
/
widget.html
diff --git
a/widget.html
b/widget.html
index 12d83e6e653f8f0307edfa3d93f658fcc5e3f27c..c070def7b3363db632c73eb244fa65e1f16a0984 100644
(file)
--- a/
widget.html
+++ b/
widget.html
@@
-12,21
+12,28
@@
<body>
<p id="clan">No clan data</p>
<script>
<body>
<p id="clan">No clan data</p>
<script>
- fetch('/schtarr/inno.json')
+ let outcont = document.getElementById('clan')
+ let request = this.location.pathname.split('/').pop()
+ outcont.innerHTML = `Loading clan data for <q>${request}</q>`
+ fetch('/schtarr/data/' + request + '.json')
.then(res => {
if (res.status != 200) {
console.log('got %o', res)
.then(res => {
if (res.status != 200) {
console.log('got %o', res)
- throw `
status
${res.status}`
+ throw `
include
${res.status}`
}
return res.json()
})
.then(clan => {
let tiernum = (rank) => rank <= 8 ? 1 : rank <= 25 ? 2 : rank <= 50 ? 3 : 4;
}
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>
+
outcont
.outerHTML = `
+ <h1>${clan.tag
|| clan.members[0].name
}</h1>
<ul class=ladders>
${clan.ladders.map(ladder => `
<ul class=ladders>
${clan.ladders.map(ladder => `
- <li class="rank ${ladder.league} tier${tiernum(ladder.rank)}"
+ <li class="rank ${[
+ ladder.league,
+ ' tier' + tiernum(ladder.rank),
+ ladder.season ? ' old' : null,
+ ].join('')}"
title="Division ${ladder.division} (${ladder.wins}:${ladder.losses})">
${ladder.league} <small>#${ladder.rank}</small>
</li>
title="Division ${ladder.division} (${ladder.wins}:${ladder.losses})">
${ladder.league} <small>#${ladder.rank}</small>
</li>
@@
-60,7
+67,10
@@
}
})
})
}
})
})
- .catch(msg => console.error('include failure:', msg))
+ .catch(msg => {
+ outcont.innerHTML = `Error loading clan data: ${msg}`
+ console.error('include failure:', msg)
+ })
</script>
</body>
</script>
</body>