You are on page 1of 3

Executed program of additem……next last

------------------------------------------------------------

var currentIndex=0;

var icecream ="http://www.akerufeed.com/wp-content/uploads/2016/07/allice.jpg";

var food1 = "http://www.circulaire-en-ligne.ca/wp-content/uploads/recette-pad-thai-facile-


300x200.jpg";

var animals = "https://upload.wikimedia.org/wikipedia/commons/6/62/Panda_(PSF).png";

var myFavoriteThings = [icecream,animals,food1];

updateScreen();

onEvent("nextButton", "click", function( ) {

nextImage();

updateScreen();

});

onEvent("lastButton", "click", function( ) {

previousImage();

updateScreen();

});

onEvent("addButton", "click", function( ) {

appendItem(myFavoriteThings,getText("addButton"));

updateScreen();

});

function nextImage() {

currentIndex++;

if (currentIndex>myFavoriteThings.length-1) {

currentIndex=currentIndex-1;

}
}

function previousImage() {

currentIndex--;

if (currentIndex<0) {

currentIndex=currentIndex+1;

function updateScreen() {

setImageURL("myImage",myFavoriteThings[currentIndex]);

if (currentIndex>=myFavoriteThings.length-1) {

currentIndex=0;

setImageURL("myImage","http://greatwallpapers.online/halloween-iphone-wallpaper-
pinterest/wallpaper-tumblr-halloween-iphone-wallpaper-pinterest-wallpaper-tumblr-7.jpeg");

onEvent("removeButton", "click", function( ) {

removeItem(myFavoriteThings,currentIndex);

if (currentIndex==myFavoriteThings.length) {

currentIndex=0;

setImageURL("myImage","http://greatwallpapers.online/halloween-iphone-wallpaper-
pinterest/wallpaper-tumblr-halloween-iphone-wallpaper-pinterest-wallpaper-tumblr-7.jpeg");
} else {

updateScreen();

});

You might also like