Skip to content

Instantly share code, notes, and snippets.

@AlexRex
Created April 19, 2015 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexRex/1d09060a8a1486a881e9 to your computer and use it in GitHub Desktop.
Save AlexRex/1d09060a8a1486a881e9 to your computer and use it in GitHub Desktop.
Slideshow PH2
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