My Badges

Update, I've made a better stab at this.

. . .

this widget from badgewidgethack does not seem to get all the badges from Open Badge Backpack

The script I got from badgewidgethack seems to limit the to 3 as far as I can see.

So I edited a couple of lines:

 while (i < data.badges.length ) {

and

 if (i === data.badges.length  ) {

Which seems to have done the trick?


	<script type="text/javascript">

	var url = "http://beta.openbadges.org/displayer/8358/group/5612.json";
	    $.getJSON(url,
	        function(data) {
	            var i=0;
	            var widgetcode = "<table>";
	            while (i < data.badges.length < 4) {
	                widgetcode = widgetcode + "<tr><td align='center'>";
	                badgeName = data.badges[i].assertion.badge.name;
	                imgUrl = data.badges[i].assertion.badge.image;
	                critUrl = data.badges[i].assertion.badge.criteria;
	                assertUrl = data.badges[i].hostedUrl;
	                widgetcode = widgetcode + "<a href='" + assertUrl + "'><img src='"+imgUrl+"' width='50' height='50' border='0'/></a><br /><a href='" + critUrl + "'>" + badgeName + "</a>";                
	                widgetcode = widgetcode + "</td></tr>";
	                i = i+1;
	                    if (i === data.badges.length || i === 3) {
	                    widgetcode = widgetcode + "</table>";
	                    document.getElementById("bhwidget").innerHTML=widgetcode;
	                    return;
	                    }
	            }
	        }
	    );
	</script>