Created
April 19, 2015 16:20
-
-
Save AlexRex/1d09060a8a1486a881e9 to your computer and use it in GitHub Desktop.
Slideshow PH2
This file contains 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
function slideShow(origen, posOrigen){ | |
var idRuta = getRuta(); | |
var next = document.getElementById('next'); | |
var back = document.getElementById('back'); | |
var img = document.getElementById('slideShowImg'); | |
var caption = document.getElementById('slideShowCaption'); | |
var slideShowWrapper = document.getElementById('slideShowWrapper'); | |
var close = document.getElementById('closeSlideShow'); | |
var pos = posOrigen; | |
if(idRuta){ | |
slideShowWrapper.style.display = 'inherit'; | |
var http_request = getFotos(idRuta); | |
http_request.onreadystatechange = function(){ | |
if(http_request.readyState == 4){ | |
var fotos = JSON.parse(http_request.responseText); | |
img.src = 'img/'+fotos[pos].ARCHIVO; | |
caption.innerHTML = fotos[pos].DESCRIPCION; | |
img.onclick = function(){ | |
if(fotos.length == pos+1){ | |
pos = 0; | |
} | |
else | |
pos++; | |
img.src = 'img/'+fotos[pos].ARCHIVO; | |
caption.innerHTML = fotos[pos].DESCRIPCION; | |
}; | |
next.onclick = function(){ | |
if(fotos.length == pos+1){ | |
pos = 0; | |
} | |
else | |
pos++; | |
img.src = 'img/'+fotos[pos].ARCHIVO; | |
caption.innerHTML = fotos[pos].DESCRIPCION; | |
}; | |
back.onclick = function(){ | |
if(pos===0){ | |
pos = fotos.length-1; | |
} | |
else | |
pos--; | |
img.src = 'img/'+fotos[pos].ARCHIVO; | |
caption.innerHTML = fotos[pos].DESCRIPCION; | |
}; | |
close.onclick = function(){ | |
slideShowWrapper.style.display = 'none'; | |
}; | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment