I'm very new to web development, so this may seem trivial to you:
I'm building a wall that displays a mosaic of 100 miniatures of landscape pictures. I get the URLs of these pictures from a remote JSON which only contains the 100 latest uploaded pictures, starting from the most recent. That JSON is constantly updated.
JSON structure :
[
{
"name": "Blue Mountains",
"url": "http://foo.com/url-to-picture", // <- Most recent
"location": "Canada"
},
{
"name": "Yellow Lake",
"url": "http://foo.com/url-to-picture", // <- Second most recent
"location": "Greece"
}, ...
]
I'd like to check the JSON every 10 seconds and detect if new pictures have been uploaded and, if so, I'd like to know how many and then replace the oldest pictures from the wall by the new ones.
All I could really come up with is this:
function getNewPictures() {
$.getJSON("http://bar.com/url-to-json", function(result) {
latest100 = result;
checkIfNewPictures(); // I don't know how to do this
old100 = latest100;
});
}
setInterval(getNewPictures, 10000);
As you can see, I have no clue as to how I could compare old100 and latest100. I also suppose it'd be easier for me if I could store the X new pictures into another array so that the process of updating the wall would be easier.
What would be the most practical way to achieve this?
Thanks!