body { padding: 10px; font-family: "Arial", sans-serif; }
h1 { font-size: 2em; font-weight: bold; margin-bottom: 20px; }
li { display: block; overflow: auto; padding: 10px; }
li:hover { cursor: pointer; background: #eee; }
li img { width: 50px; float: left; margin-right: 10px; }
li p { margin-bottom: 5px; }
li a { color: #378FCF; }
li span {font-weight: bold; font-size: 1.1em; }
li em { color: #666; }
JavaScript
YUI().use('node-event-delegate', function(Y) {
// Register a helper, to get the URL to a Tuenti profile!
Handlebars.registerHelper('tuentiLink', function(uid) {
return "http://www.tuenti.com/#m=Profile&func=index&user_id=" + uid;
});
/**
* This function turns an object with a "people" array and renders it using handlebars templates
* @param context {Object} {people:[ {name, age, city, uid, avatar}] }
* @return {String} rendered HTML code
*/
var renderPeople = function(context) {
// Compile the template (we do this step on the build, and prepare a YUI module full of compiled templates)
// A compiledTemplate is just a function that receives data (context) and outputs a (html) string
var compiledTemplate = Handlebars.compile(Y.one("#people-template").getHTML());
return compiledTemplate(context);
};
/**
* Shuffles an array in place
* @param o {Array} Input array
* @return {Array} Shuffled array
* @see http://stackoverflow.com/a/6274381/1738205
*/
var shuffleArray = function(o) {
for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
};
// The data that we're going to render
var peopleData = {
people: [
{
name: "Alberto Gragera",
age: 29,
city: "Montijo",
uid: "60138125",
avatar: "http://ak1.img.tuenti.net/MdlfPQOVoo0crJxuAwDAAMAAJQAy"
},
{
name: "David Iglesias",
age: 29,
city: "Langreo",
uid: "62135604",
avatar: "http://tsimg.tuenti.net/MeK-KAO0HTRmbXogAwDAAMAAMgAm"
},
{
name: "Michal Rudnicki",
age: 33,
city: "Częstochowa",
uid: "72012863",
avatar:...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.