Created
October 20, 2018 02:35
-
-
Save johnallen3d/e6e6a0cfde9e8efe0d453472ac7d3e46 to your computer and use it in GitHub Desktop.
Very rough draft of a Übersicht NHL standings widget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
command: "curl -s 'https://statsapi.web.nhl.com/api/v1/standings'" | |
refreshFrequency: '60m' | |
render: (_) -> | |
""" | |
<fieldset> | |
<legend>NHL Standings</legend> | |
<table id="standings"> | |
<thead> | |
<tr> | |
<th>Conference</th> | |
<th>Division</th> | |
<th>Team</th> | |
<th>GP</th> | |
<th>W</th> | |
<th>L</th> | |
<th>OTL</th> | |
</tr> | |
</thead> | |
<tbody> | |
</tbody> | |
</table> | |
</fieldset> | |
""" | |
style: """ | |
background: #000000; | |
color: #FFFFFF; | |
top: 30px; | |
""" | |
update: (output, domEl) -> | |
divisions = JSON.parse(output).records | |
table = $(domEl).find('#standings > tbody') | |
table.empty() | |
for division in divisions | |
for team in division.teamRecords | |
divisionRow = """ | |
<tr> | |
<td>#{division.conference.name}</td> | |
<td>#{division.division.name}</td> | |
<td>#{team.team.name}</td> | |
<td>#{team.gamesPlayed}</td> | |
<td>#{team.leagueRecord.wins}</td> | |
<td>#{team.leagueRecord.losses}</td> | |
<td>#{team.leagueRecord.ot}</td> | |
</tr> | |
""" | |
table.append(divisionRow) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment