list last three match results
[sc2-widget] / widget.html
index 1184ab1c506ecd96774219d5f6e749cd4c1a1162..c2a351dc14951302d6881a810a87acb4f191dde8 100644 (file)
@@ -25,6 +25,8 @@
        })
        .then(clan => {
                let tiernum = (rank) => rank <= 8 ? 1 : rank <= 25 ? 2 : rank <= 50 ? 3 : 4;
+               let matchtime = (d) => d.getDate() + '/' + (d.getMonth() + 1) +
+                       ' ' + d.getHours() + ":" + ('0' + d.getMinutes()).slice(-2);
                outcont.outerHTML = `
                        <h1>${clan.tag || clan.members[0].name}</h1>
                        <ul class=ladders>
                                </figure></a></li>
                        `).join('')}
                        </ul>
+                       <ul class=matches>
+                       ${clan.matches.splice(0, 3).map(match => `
+                               <li data-members="${match.players}" class=${match.decision.toLowerCase()}>
+                                       ${matchtime(new Date(match.date * 1000))} ${match.type}
+                               </li>
+                       `).join('')}
+                       </ul>
                `
 
                document.querySelectorAll('[data-members]').forEach(li => {