var primeMetaData = {
"7": {
img: "http://upload.wikimedia.org/wikipedia/en/thumb/4/4c/Les_Demoiselles_d%27Avignon.jpg/350px-Les_Demoiselles_d%27Avignon.jpg",
text: "1907: Picasso paints Les Demoiselles Avignon"
},
"11": {
img: "http://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Aan_de_Zuidpool_-_p1913-160.jpg/220px-Aan_de_Zuidpool_-_p1913-160.jpg",
text: "1911: Amundsen reaches South Pole"
},
"23": {
img: "",
text: "1923: French troops occupy the Ruhr in an attempt to force Germany to pay reparations"
},
"29": {
img: "http://upload.wikimedia.org/wikipedia/commons/c/cc/American_union_bank.gif",
text: "1929: The year of the Wall St. Crash"
},
"37": {
img: "",
text: "1937: Spanish Civil War, bombing of Guernica"
},
"67": {
img: "",
text: "1967: Celtic win the European Cup"
}
}
function getFactors(subject) {
var factors = [];
for (var i = 1; i <= subject; i++) {
if (subject % i == 0) {
factors.push(i);
}
}
return factors;
}
var primeTemplate = _.template(document.querySelector('#prime-template').innerHTML);
var nonPrimeTemplate = _.template(document.querySelector('#non-prime-template').innerHTML);
var list = document.querySelector("#number-container");
for (var i = 1; i < 50; i++) {
var result = getFactors(i);
if(result.length==2) {
// prime
var metaData = primeMetaData[i.toString()];
var temp = primeTemplate(_.extend({
number : i,
text : "prime",
img : ""
}, metaData));
var li = document.createElement('li');
li.innerHTML = temp;
list.appendChild(li);
} else {
var temp = nonPrimeTemplate({
number : i
});
var li = document.createElement('li');
...
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.