Skip to content

Instantly share code, notes, and snippets.

@skopp
Forked from optikfluffel/coderwall.coffee
Last active December 10, 2015 01:49
Show Gist options
  • Save skopp/4363046 to your computer and use it in GitHub Desktop.
Save skopp/4363046 to your computer and use it in GitHub Desktop.
Minor edits
# Display your coderwall.com badges without using a library like jQuery
# CONFIGURE your username
username = #'change me' - remove hashtag after changing and delete this helper text
url = "http://www.coderwall.com/#{username}.json?callback=processJSON"
loadJSON = (url) ->
head = document.getElementsByTagName('head')[0]
newScript = document.createElement('script')
newScript.type = 'text/javascript'
newScript.src = url
head.appendChild newScript
window.processJSON = (results) ->
# CONFIGURE the id of the element you want to add the badges to
element = document.getElementById('coderwall')
# CONFIGURE the size of the badges
badgeSize = 55
for item in results.data.badges
newLink = document.createElement('a')
newLink.href = "http://www.coderwall.com/#{username}"
newImage = document.createElement('img')
newImage.src = item.badge
newImage.title = "#{item.name}: #{item.description}"
newImage.alt = item.name
newImage.height == newImage.width = badgeSize
newLink.appendChild newImage
element.appendChild newLink
return
loadJSON url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment