Skip to content

Instantly share code, notes, and snippets.

@nikibrown
Created January 18, 2011 18:05
Show Gist options
  • Save nikibrown/784856 to your computer and use it in GitHub Desktop.
Save nikibrown/784856 to your computer and use it in GitHub Desktop.
function processEntries(data) {
// Loop for each entry
$.each(data.Entries, function(entriesIndex, entriesObject) {
var img, a, span; // declare the three variables you'll be using
if (entriesObject.Field3 != "") {
// Save the <img> to a variable after creating it
img = $("<img />", {
class: "avatar",
src: "http://www.gravatar.com/avatar/" + MD5(entriesObject.Field3) + "?d=http%3A%2F%2Fbostonwebsitemakeover.com%2Fassets%2Fimg%2Fdefault.png"
}); // Don't append yet
}
if (entriesObject.Field17 != "") {
a = $("<a />", {
href: "http://twitter.com/" + entriesObject.Field17,
html: "<p>@" + entriesObject.Field17 + "</p>"
});
}
if (entriesObject.Field1 != "") {
span = $("<span />", {
class: "name",
html: entriesObject.Field1 + " " + entriesObject.Field2 + "<br />" + '<a href="' + entriesObject.Field4 + '">' + entriesObject.Field4 + "</a>"
});
}
// Append to list here
$('<li class="entry">').append(img).append(span).append(a).appendTo('#people');
}); // end for each loop
}; // end process entries function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment