Skip to content

Instantly share code, notes, and snippets.

@mockee
Created November 2, 2012 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mockee/4002901 to your computer and use it in GitHub Desktop.
Save mockee/4002901 to your computer and use it in GitHub Desktop.
Showing avatars in random positions.
;(function() {
var doc = document
, frag = doc.createDocumentFragment()
, ids = [
{ id: 'tifafa', name: 'tifa' }
, { id: 'godlikejay', name: 'Jay' }
, { id: 'mockee', name: 'mockee' }
].sort(function() {
return Math.random() > 0.5
})
function attr(attrs) {
for (var name in attrs) {
this.setAttribute(name, attrs[name])
}
return this
}
for (var i in ids) {
var id = ids[i].id
, name = ids[i].name
, lnk = doc.createElement('a')
, avatar = '<img src="/img/member/'
+ id + '.png" alt=' + name + '>'
attr.call(lnk, {
title: name
, href: 'https://twitter.com/' + id
, target: '_blank'
}).innerHTML = avatar
frag.appendChild(lnk)
}
doc.getElementById('team')
.appendChild(frag)
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment