zeus.ugent.be/content/assets/scripts/gamification.coffee

37 lines
911 B
CoffeeScript
Raw Normal View History

2018-07-10 22:36:43 +00:00
request = new XMLHttpRequest
request.open 'GET', 'https://zeus.ugent.be/game/top4/show.json', true
request.onload = ->
if request.status >= 200 and request.status < 400
# Success!
data = JSON.parse(request.responseText)
2017-02-08 15:31:17 +00:00
str = "<table>"
2016-10-03 12:41:36 +00:00
for x in data
2018-07-10 22:36:43 +00:00
str += """
2017-02-08 15:31:17 +00:00
<tr>
2018-07-10 22:36:43 +00:00
<td class="picture">
2017-02-08 15:31:17 +00:00
<img class="coder-picture" src="#{x.avatar_url}">
2018-07-10 22:36:43 +00:00
</td>
<td class="name">
2017-02-08 15:31:17 +00:00
<a class="coder-name" href="#{x.github_url}">#{x.github_name}</a>
2018-07-10 22:36:43 +00:00
</td>
<td class="score">
2017-02-08 15:31:17 +00:00
#{x.score}
2018-07-10 22:36:43 +00:00
</td>
2017-02-08 15:31:17 +00:00
</tr>
2018-07-10 22:36:43 +00:00
"""
2017-02-08 15:31:17 +00:00
str += "</table>"
2016-10-03 12:41:36 +00:00
2018-07-10 22:36:43 +00:00
el = document.getElementById('gamification-coders')
el.innerHTML = str
else
# We reached our target server, but it returned an error
return
request.onerror = ->
# There was a connection error of some sort
return
request.send()