1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| <?php
$random = '?'.rand();
?>
<script LANGUAGE="JavaScript">
// Variable qui stocke le nombre d'image de l'utilisateur
varX="<?php echo $_SESSION['x'];?>";
// Variable qui sert à ne pas conserver les mêmes images dû aux cookies.
varRandom="<?php echo $random;?>";
// Variable qui sert à savoir à quel image on en est
varT=1;
function getCookie(sName) {
var cookContent = document.cookie, cookEnd, i, j;
var sName = sName + "=";
for(var i=0,c=cookContent.length;i<c;i++) {
j = i + sName.length;
if(cookContent.substring(i, j) == sName) {
cookEnd = cookContent.indexOf(";", j);
if(cookEnd == -1) {
cookEnd = cookContent.length;
}
return decodeURIComponent(cookContent.substring(j, cookEnd));
}
}
return null;
}
function changer_image(signe)
{
comp=getCookie("num_img");
if (signe=='moins')
{
varT--;
// Condition qui cache la prévisualisation précédente si on est à la photo 1.
if (parseInt(comp-1)>1)
document.getElementById('tgau').innerHTML='<input type="image" src="images/boutons/Bouton-precedent2.png" name="prec" onclick="changer_image(\'moins\')" />';
else
document.getElementById('tgau').innerHTML='';
// Variable pour remédier aux apostrophes.
varP="<?php echo $_SESSION['pseudo'];?>";
document.getElementById('image').innerHTML="<img src='images/"+varP+"/Image "+(parseInt(comp)-1)+".jpg"+varRandom+"' alt='' height=470 />";
document.getElementById('gau').innerHTML="<img src='images/"+varP+"/Image "+(parseInt(comp)-2)+".jpg"+varRandom+"' alt='' height=120 />";
document.getElementById('midd').innerHTML="<img src='images/"+varP+"/Image "+(parseInt(comp)-1)+".jpg"+varRandom+"' alt='' height=100 />";
document.getElementById('dro').innerHTML="<img src='images/"+varP+"/Image "+(parseInt(comp))+".jpg"+varRandom+"' alt='' height=120 />";
if (parseInt(comp-1)<varX)
document.getElementById('tdro').innerHTML='<input type="image" src="images/boutons/Bouton-suivant2.png" name="next" onclick="changer_image(\'plus\')" />';
else
document.getElementById('tdro').innerHTML='';
document.cookie = 'num_img' +"=" + (parseInt(comp)-1)+ ";" ;
}
else
{
varT++;
if (parseInt(comp+1)>1)
document.getElementById('tgau').innerHTML='<input type="image" src="images/boutons/Bouton-precedent2.png" name="prec" onclick="changer_image(\'moins\')" />';
else
document.getElementById('tgau').innerHTML='';
varP="<?php echo $_SESSION['pseudo'];?>";
document.getElementById('image').innerHTML="<img src='images/"+varP+"/Image "+(parseInt(comp)+1)+".jpg"+varRandom+"' alt='' height=470 />";
document.getElementById('gau').innerHTML="<img src='images/"+varP+"/Image "+(parseInt(comp))+".jpg"+varRandom+"' alt='' height=120 />";
document.getElementById('midd').innerHTML="<img src='images/"+varP+"/Image "+(parseInt(comp)+1)+".jpg"+varRandom+"' alt='' height=100 />";
document.getElementById('dro').innerHTML="<img src='images/"+varP+"/Image "+(parseInt(comp)+2)+".jpg"+varRandom+"' alt='' height=120 />";
if ((parseInt(comp)+1)<varX)
document.getElementById('tdro').innerHTML='<input type="image" src="images/boutons/Bouton-suivant2.png" name="next" onclick="changer_image(\'plus\')" />';
else
document.getElementById('tdro').innerHTML='';
document.cookie = 'num_img' +"=" + (parseInt(comp)+1)+ ";" ;
}
return varT;
}
function init()
{
document.cookie = 'num_img' +"=1;" ;
}
</script> |
Partager