Skip to content

Instantly share code, notes, and snippets.

@leopic
Created January 10, 2013 05:35
Show Gist options
  • Save leopic/4499706 to your computer and use it in GitHub Desktop.
Save leopic/4499706 to your computer and use it in GitHub Desktop.
$.getJSON('https://api.github.com/users/leopic/events', function(data) {
for (var i = 0; i < data.length; i++) {
eventType = data[i].type;
switch (eventType) {
case 'WatchEvent':
currentClass = 'watch';
nuevoDom += '<li class=' + currentClass + '>' + eventType + ' ' + data[i].created_at + '</li>';
break;
case 'PushEvent':
currentClass = 'push';
nuevoDom += '<li class=' + currentClass + '>' + eventType + ' ' + data[i].created_at + '</li>';
break;
case 'GistEvent':
currentClass = 'gist';
nuevoDom += '<li class=' + currentClass + '>' + eventType + ' ' + data[i].payload.gist.forks_url + '</li>';
break;
default:
currentClass = 'other';
nuevoDom += '<li class=' + currentClass + '>' + eventType + ' ' + data[i].created_at + '</li>';
break;
}
}
}).complete(function() {
$('#json').html(nuevoDom);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment