Skip to content

Instantly share code, notes, and snippets.

@optikfluffel
Created November 19, 2012 10:13
Show Gist options
  • Select an option

  • Save optikfluffel/4109968 to your computer and use it in GitHub Desktop.

Select an option

Save optikfluffel/4109968 to your computer and use it in GitHub Desktop.

Revisions

  1. Udo Kramer revised this gist Nov 19, 2012. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions coderwall.coffee
    Original file line number Diff line number Diff line change
    @@ -13,18 +13,19 @@ loadJSON = (url) ->
    head.appendChild newScript

    window.processJSON = (results) ->

    newLink = document.createElement('a')
    newLink.href = "http://www.coderwall.com/#{username}"

    # 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
  2. Udo Kramer created this gist Nov 19, 2012.
    34 changes: 34 additions & 0 deletions coderwall.coffee
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    # Display your coderwall.com badges without using a library like jQuery

    # CONFIGURE your username
    username = 'optikfluffel'

    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) ->

    newLink = document.createElement('a')
    newLink.href = "http://www.coderwall.com/#{username}"

    # 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
    newImage = document.createElement('img')
    newImage.src = item.badge
    newImage.height == newImage.width = badgeSize

    newLink.appendChild newImage
    element.appendChild newLink
    return

    loadJSON url