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

37 lines
911 B
CoffeeScript
Raw Normal View History

2018-07-11 00:36:43 +02: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 16:31:17 +01:00
str = "<table>"
2016-10-03 14:41:36 +02:00
for x in data
2018-07-11 00:36:43 +02:00
str += """
2017-02-08 16:31:17 +01:00
<tr>
2018-07-11 00:36:43 +02:00
<td class="picture">
2017-02-08 16:31:17 +01:00
<img class="coder-picture" src="#{x.avatar_url}">
2018-07-11 00:36:43 +02:00
</td>
<td class="name">
2017-02-08 16:31:17 +01:00
<a class="coder-name" href="#{x.github_url}">#{x.github_name}</a>
2018-07-11 00:36:43 +02:00
</td>
<td class="score">
2017-02-08 16:31:17 +01:00
#{x.score}
2018-07-11 00:36:43 +02:00
</td>
2017-02-08 16:31:17 +01:00
</tr>
2018-07-11 00:36:43 +02:00
"""
2017-02-08 16:31:17 +01:00
str += "</table>"
2016-10-03 14:41:36 +02:00
2018-07-11 00:36:43 +02: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()