return not found response for missing requests
[sc2-widget] / widget.html
index 12d83e6e653f8f0307edfa3d93f658fcc5e3f27c..d6f5f8d66ddeef85b5e32b721724e4873d38e5b2 100644 (file)
@@ -12,7 +12,9 @@
 <body>
 <p id="clan">No clan data</p>
 <script>
-       fetch('/schtarr/inno.json')
+       let request = this.location.pathname.split('/')
+       request.splice(2, 1) // strip page name
+       fetch(request.join('/') + '.json')
        .then(res => {
                if (res.status != 200) {
                        console.log('got %o', res)
@@ -23,7 +25,7 @@
        .then(clan => {
                let tiernum = (rank) => rank <= 8 ? 1 : rank <= 25 ? 2 : rank <= 50 ? 3 : 4;
                document.getElementById('clan').outerHTML = `
-                       <h1>${clan.tag}</h1>
+                       <h1>${clan.tag || clan.members[0].name}</h1>
                        <ul class=ladders>
                        ${clan.ladders.map(ladder => `
                                <li class="rank ${ladder.league} tier${tiernum(ladder.rank)}"