Setup for bl.ocks.org parsing...
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
/* http://meyerweb.com/eric/tools/css/reset/ | |
v2.0 | 20110126 | |
License: none (public domain) | |
*/ | |
#coderbits div, #coderbits span, | |
#coderbits h1, #coderbits h2, #coderbits p, | |
#coderbits a, #coderbits img, #coderbits strong, | |
#coderbits ol, #coderbits ul, #coderbits li, | |
#coderbits section { | |
margin: 0; | |
padding: 0; | |
border: 0; | |
font-size: 100%; | |
font: inherit; | |
vertical-align: baseline; | |
} | |
#coderbits section { | |
display: block; | |
} | |
#coderbits ol, #coderbits ul { | |
list-style: none; | |
} | |
#coderbits { | |
border: 1px solid #ddd; | |
border-radius: 4px; | |
font: normal 12px arial, sans-serif; | |
margin: 0 auto; | |
width: 198px; | |
background: #fafafa; /* Old browsers */ | |
background: -moz-linear-gradient(top, #fafafa 0%, #efefef 100%); /* FF3.6+ */ | |
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#fafafa), color-stop(100%,#efefef)); /* Chrome,Safari4+ */ | |
background: -webkit-linear-gradient(top, #fafafa 0%,#efefef 100%); /* Chrome10+,Safari5.1+ */ | |
background: -o-linear-gradient(top, #fafafa 0%,#efefef 100%); /* Opera 11.10+ */ | |
background: -ms-linear-gradient(top, #fafafa 0%,#efefef 100%); /* IE10+ */ | |
background: linear-gradient(to bottom, #fafafa 0%,#efefef 100%); /* W3C */ | |
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fafafa', endColorstr='#efefef',GradientType=0 ); /* IE6-9 */ | |
color: #000; | |
} | |
#coderbits a { | |
text-decoration: none; | |
color: #08C; | |
} | |
#coderbits a:hover { | |
text-decoration: none; | |
color: #05C; | |
} | |
#coderbits ol, ul { | |
list-style: none; | |
} | |
div#coderbits-summary { | |
padding: 4px 12px 2px 12px; | |
} | |
div#coderbits-avatar { | |
float: left; | |
} | |
#coderbits-avatar .avatar { | |
border: 1px solid #ddd; | |
padding: 1px; | |
width: 24px; | |
} | |
div#coderbits-overview { | |
margin-left: 36px; | |
} | |
#coderbits-overview h1 a { | |
font-size: 13px; | |
text-decoration: none; | |
} | |
#coderbits-overview p { | |
color: #666; | |
font: italic normal 10px arial, sans-serif; | |
} | |
div#coderbits-skills { | |
border-top: 1px solid #eee; | |
padding: 12px 12px 0 12px; | |
} | |
#coderbits-skills h2 { | |
font-size: 11px; | |
} | |
#coderbits-skills p { | |
font-size: 10px; | |
} | |
div#coderbits-stats { | |
padding: 12px 12px 0 12px; | |
} | |
#coderbits-stats p { | |
font-size: 10px; | |
} | |
#coderbits-stats-list li { | |
display: inline-block; | |
_display: inline; /* IE fix */ | |
margin-right: 5px; | |
} | |
#coderbits-stats-list li p { | |
line-height: 17px; | |
} | |
#coderbits-stats-list li strong { | |
font-size: 11px; | |
} | |
#coderbits-stats-list li span { | |
color: #999; | |
font-size: 11px; | |
-webkit-text-shadow: 1px 1px 0 #fff; | |
text-shadow: 1px 1px 0 #fff; | |
} | |
#coderbits-stats-list li.last { | |
padding-left: 10px; | |
border-right: 0; | |
margin-right: 0; | |
padding-right: 0; | |
} | |
div#coderbits-awards { | |
padding: 15px 0 10px 7px; | |
} | |
#coderbits-badges { | |
margin-left: 5px; | |
} | |
#coderbits-badges img { | |
width: 22px; | |
height: 22px; | |
margin: 0 3px 0 0; | |
} | |
#coderbits-badges a { | |
display: inline-block; | |
height: 20px; | |
vertical-align: middle; | |
margin-left: 7px; | |
} |
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
;(function(window, document, undefined) { | |
"use strict"; | |
var addCommas = function(nStr) { | |
nStr += ''; | |
var x = nStr.split('.'); | |
var x1 = x[0]; | |
var x2 = x.length > 1 ? '.' + x[1] : ''; | |
var rgx = /(\d+)(\d{3})/; | |
while (rgx.test(x1)) { | |
x1 = x1.replace(rgx, '$1' + ',' + '$2'); | |
} | |
return x1 + x2; | |
}; | |
var buildSummary = function(data) { | |
var content = ''; | |
content += '<div id="coderbits-summary">'; | |
content += '<div id="coderbits-avatar">'; | |
content += '<a href="' + data.link + '" target="_parent">'; | |
content += '<img alt="' + data.name + '" class="avatar" src="https://secure.gravatar.com/avatar/' + data.gravatar_hash + '?d=https%3A%2F%2Fcoderbits.com%2Fimages%2Fgravatar.png&r=PG&s=48">'; | |
content += '</a>'; | |
content += '</div>'; | |
content += '<div id="coderbits-overview">'; | |
content += '<h1>'; | |
content += '<a href="' + data.link + '" target="_parent" title="' + data.name + '">' + data.name + '</a>'; | |
content += '</h1>'; | |
content += '<p>'; | |
content += '<span>' + data.title + '</span>'; | |
content += '</p>'; | |
content += '</div>'; | |
content += '</div>'; | |
return content; | |
}; | |
var buildSkills = function(data) { | |
var content = '', items; | |
content += '<div id="coderbits-skills">'; | |
var area = ["Skills", "Interests", "Traits", "Areas"]; | |
(function() { | |
for(var i = 0; i < area.length; i++) { | |
var current = "top_" + area[i].toLowerCase(); | |
if(data[current].length > 0) { | |
content += "<h2>Top " + area[i] + "</h2>"; | |
items = data[current]; | |
return true; | |
} | |
} | |
})(); | |
content += '<p>'; | |
for(var i = 0; i < items.length; i++) { | |
content += items[i].name; | |
if(i < items.length - 1) { | |
content += ', '; | |
} | |
} | |
content += '</p>'; | |
content += '</div>'; | |
return content; | |
}; | |
var buildStats = function(data) { | |
var total = 0; | |
for(var i = 0; i < data.badges.length; i++) { | |
if(data.badges[i].earned) { | |
total++ | |
} | |
} | |
var content = ''; | |
content += '<div id="coderbits-stats">'; | |
content += '<ul id="coderbits-stats-list">'; | |
content += '<li>'; | |
content += '<p>'; | |
content += '<strong>' + addCommas(total) + '</strong>'; | |
content += '<span> badges</span>'; | |
content += '</p>'; | |
content += '<p>'; | |
content += '<strong>' + addCommas(data.follower_count) + '</strong>'; | |
content += '<span> followers</span>'; | |
content += '</p>'; | |
content += '</li>'; | |
content += '<li class="last">'; | |
content += '<p>'; | |
content += '<strong>' + addCommas(data.views) + '</strong>'; | |
content += '<span> views</span>'; | |
content += '</p>'; | |
content += '<p>'; | |
content += '<strong>' + addCommas(data.following_count) + '</strong>'; | |
content += '<span> friends</span>'; | |
content += '</p>'; | |
content += '</li>'; | |
content += '</ul>'; | |
content += '</div>'; | |
return content; | |
}; | |
var buildBadges = function(data) { | |
var content = '', count = 0, total = 0; | |
content += '<div id="coderbits-awards">'; | |
content += '<p id="coderbits-badges">' | |
for(var i = 0; i < data.badges.length; i++) { | |
var badge = data.badges[i]; | |
if(badge.earned) { | |
total++ | |
if(count < 11 && badge.level === 1) { | |
content += '<img src="' + badge.image_link + '" title="' + badge.name + ' - ' + badge.description + '" alt="' + badge.level + ' bit ' + badge.name + ' - ' + badge.description + '">'; | |
count++ | |
} | |
} | |
} | |
content += '<a href="' + data.link + '/badges">view all ' + total + '</a>'; | |
content += '</p>'; | |
content += '</div>'; | |
return content; | |
}; | |
var request = function(url) { | |
var script = document.getElementsByTagName("script")[0]; | |
var handler = document.createElement("script"); | |
handler.src = url; | |
script.parentNode.insertBefore(handler, script); | |
}; | |
var global = "coderbits", element = document.getElementById(global); | |
if(element) { | |
window[global] = function(data) { | |
var content = ''; | |
content += buildSummary(data); | |
content += buildSkills(data); | |
content += buildStats(data); | |
content += buildBadges(data); | |
document.getElementById(global).innerHTML = content; | |
delete window[global]; | |
}; | |
var username = element.getAttribute("data-coderbits-username"), | |
safeUsername = username.replace(/[('"){};!@#%&*]/gi, ''); | |
request("https://coderbits.com/" + safeUsername + ".json?callback=" + global); | |
} | |
})(window, document); |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>skopp - coderbits stats</title> | |
<link href="coderbits.css" media="all" rel="stylesheet" type="text/css"> | |
<script src="coderbits.js"></script> | |
</head> | |
<body> | |
<section id="coderbits" data-coderbits-username="skopp"></section> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
iframe = 200 x 242