Skip to content

Instantly share code, notes, and snippets.

@camwest
Created March 15, 2009 22:35
Show Gist options
  • Save camwest/79565 to your computer and use it in GitHub Desktop.
Save camwest/79565 to your computer and use it in GitHub Desktop.
var Tweet = Class.create({
initialize: function(data) {
this.date = data.created_at;
this.fromUser = data.from_user;
this.text = data.text;
this.imageSource = data.profile_image_url;
this.id = data.id;
},
toElement: function() {
return new Element("div", { className: "tweet" }).insert(
new Element("img", { src: this.imageSource })
).insert(
new Element("p").insert(
new Element("a", { href: "http://twitter.com/" + this.fromUser }).update(this.fromUser)
).insert(" " + this.text + ", ").insert(
new Element("a", { href: "http://twitter.com/" + this.fromUser + "/statuses/" + this.id }).update("#")
)
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment