Last active
August 29, 2015 14:26
-
-
Save benthebear/9d9cc78ce31e25650cd1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Draws a new card in the document <body>. | |
*/ | |
function renderPainting() { | |
var postings = [ | |
{ | |
pictureName: 'Starry Night', | |
artist: 'Vincent van Gogh', | |
year: 1889, | |
image: '1.jpg' | |
}, | |
{ | |
pictureName: 'Gas', | |
artist: 'Edward Hopper', | |
year: 1851, | |
image: '2.jpg' | |
}, | |
{ | |
pictureName: 'The Wounded Deer', | |
artist: 'Frida Kahlo', | |
year: 1947, | |
image: '3.jpg' | |
}, | |
{ | |
pictureName: 'A View of Exeter', | |
artist: 'JMW Turner', | |
year: 1827, | |
image: '4.jpg' | |
}, | |
]; | |
var rawTemplate = $("#render-newCard").html() | |
for (var i = 0; i < 4 ; i++) { | |
var currentObject = postings[i]; | |
var filledTemplate = Mustache.render(rawTemplate,currentObject); | |
$("#wunderbar").append (filledTemplate) | |
} | |
} | |
renderPainting() | |
function getRandom (gallery) | |
{ | |
var apiValues = gallery; | |
var rawTemplate = $("#render-newAPI").html(); | |
for (var i=0; i<4; i++) { | |
var completeTemplate = Mustache.render(rawTemplate, getRandomElement(apiValues)); | |
$("#randomness").append (completeTemplate); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment