I want to display several pictures for a specific amount of time. When the time runs out go to the next picture, and this cycle loops until there are no more pictures.
I've tried for and while loop's but they don't work with my implementation.
Here is what I have:
JavaScript
/*
* Set's a timer for the image that's going to be displayed
*
* @param plan contains the array with the objects that contain the picture path and time
* @param index index of array
* @version 1.0
*/
function display(plan, index){
var exercises = plan.getExercises(); // array
// 60*1000 -> 1 minute
//Displays the image for a 'exercises[index].getDuration() * 1000' period of time
image(exercises[index].getURL());
setTimeout(function() {
//Removes the image when time is up
var el = document.getElementById("myDiv");
el.parentNode.removeChild(el);
gif_acabou = true;
}, exercises[index].getDuration() * 1000);
}
/*
* Creates an element and adds it to the HTML <div>
*
* @param img_URL - image path
* @version 1.0
*/
function image(img_URL) {
var img = document.createElement("IMG");
img.src = img_URL;
document.getElementById('myDiv').appendChild(img);
}