git.shiar.nl
/
sc2-widget
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4d46f04
)
replace contents message by javascript action and errors
author
Mischa POSLAWSKY
<perl@shiar.org>
Thu, 6 Jun 2019 16:02:24 +0000
(18:02 +0200)
committer
Mischa POSLAWSKY
<perl@shiar.org>
Thu, 6 Jun 2019 16:02:24 +0000
(18:02 +0200)
widget.html
patch
|
blob
|
history
diff --git
a/widget.html
b/widget.html
index 26bdd168836cf38547ac14f277a68e7bf195658e..7fc2389eef13d830d011ebe96976e3d7a944d296 100644
(file)
--- a/
widget.html
+++ b/
widget.html
@@
-12,18
+12,20
@@
<body>
<p id="clan">No clan data</p>
<script>
<body>
<p id="clan">No clan data</p>
<script>
- let request = this.location.pathname.split('/')
- fetch('/schtarr/data/' + request.pop() + '.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 = `
+
outcont
.outerHTML = `
<h1>${clan.tag || clan.members[0].name}</h1>
<ul class=ladders>
${clan.ladders.map(ladder => `
<h1>${clan.tag || clan.members[0].name}</h1>
<ul class=ladders>
${clan.ladders.map(ladder => `
@@
-61,7
+63,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>