Je suis débutant en javaScript , j'ai réalisé un diaporama qui fait défiler 200 photos
Sur mon PC hors connexion cela marche bien
Mais sur mon site , quand cela rame , il rate des photos
Voici la partie du code qui gére ces photos
dans le <head>
ima[0]="fo/DSC00086.jpg";
ima[1]="fo/DSC00087.jpg";
ima[2]="fo/DSC00088.jpg";
ima[3]="fo/DSC00089.jpg";
ima[4]="fo/DSC00090.jpg";
ima[5]="fo/DSC00091.jpg";
var nom ="CHATEAUX DU DESERT : ";
tt[-1]="Diaporamas de Alain" ;
tt[0]="Qasr al-Kharana" ;
tt[1]="Les châteaux du désert dans ..." ;
tt[2]="le Wadi Bottoum sont des petits ..." ;
var cpt =ima.length;
var ndiapo="1";
var nbdiapo=20;
var nbpage=1;
var npage=1;
var goton=1;var nl=1;var nplus=cpt-10; var lg=600; var af1=0;var duree;var num = 0;var next_location =0;var pics_loaded = 0;var onoff = 0;
var fullsized = 0;var direction = 1;var timeout_value; var images = new Array; var photo_urls = new Array;var full_photo_urls = new Array;
var tab_images = new Array;var transitionNames = new Array;var tra = new Array;var current_transition = 11;var loop = 0;
var browserCanBlend = (is_ie5_5up);
function gotonum() { // on a une forme pour aller à un N° de photo ,
goton= document.TopForm.gonum.options[document.TopForm.gonum.selectedIndex].value;
if(goton <9999) {
next_location=goton;
document.TopForm.gonum.value=9999;
reset_duree();
}
}
function stopOrStart() {
if (onoff) {
stop();
} else {
play();
}
}
function fullOrNormal() {
images = new Array;
pics_loaded=0;
if (fullsized) {
normal();
} else {
full();
}
next_location = num;
preload_photo(next_location);
go_to_next_photo();
}
function toggleLoop() {
if (loop) {
loop = 0;
} else {
loop = 1;
}
}
function changeElementText(id, newText) {
element = document.getElementById(id);
element.innerHTML = newText;
}
function stop() {
onoff = 0;
clearTimeout(duree);
if (cpt > num){
changeElementText("stopOrStartText", '<img src="diap/astop.jpg" width="42" height="20" alt="MARCHE">');
} else {
changeElementText("stopOrStartText", '<img src="diap/af1.jpg" width="42" height="20" alt="MARCHE">');
}
}
function play() {
changeElementText("stopOrStartText", '<img src="diap/aplay.jpg" height="20"alt="ARRET">');
onoff = 1;
go_to_next_photo();
}
function changeDirection() {
if (direction == 1) {
direction = -1;
changeElementText("changeDirText",'<img src="diap/arriere.jpg" height="20" width="42" alt="Avant">');
} else {
direction = 1;
changeElementText("changeDirText", '<img src="diap/avant.jpg" height="20" width="42" alt="Arrière">');
}
preload_next_photo();
}
function change_transition() {
current_transition = document.TopForm.transitionType.selectedIndex;
}
function preload_complete() {
}
function reset_duree() {
clearTimeout(duree);
if (onoff) {
timeout_value = document.TopForm.time.options[document.TopForm.time.selectedIndex].value * 100;
duree = setTimeout('go_to_next_photo()', timeout_value);
}
}
function wait_for_current_photo() {
if (!show_current_photo()) {
clearTimeout(duree)
duree = setTimeout('wait_for_current_photo()', 50);
preload_next_photo();
reset_duree();
return 0;
} else {
preload_next_photo();
reset_duree();
}
}
function go_to_next_photo() {
num = next_location ;
if (!show_current_photo()) {
wait_for_current_photo();
return 0;
}
preload_next_photo();
reset_duree();
}
function preload_next_photo() {
next_location = (parseInt(num) + parseInt(direction));
if (next_location > cpt) {
next_location = 1;
if (!loop) {
stop();
}
}
if (next_location == 0) {
next_location = cpt;
if (!loop) {
stop();
}
}
preload_photo(next_location);
}
function show_current_photo() {
if (!images[num] || !images[num].complete) {
preload_photo(num);
return 0;
}
if (browserCanBlend){
var do_transition;
if (current_transition == (transition_count)) {
do_transition = Math.floor(Math.random() * transition_count);
} else {
do_transition = current_transition;
}
document.images.slide.style.filter=tra[do_transition];
document.images.slide.filters[0].Apply();
}
document.slide.src = images[num].src;
setCaption(tab_images[num]);
setCapt(tab_tt[num]);
if (browserCanBlend) {
document.images.slide.filters[0].Play();
}
return 1;
}
function preload_photo(index) {
if (pics_loaded < cpt) {
if (!images[index]) {
images[index] = new Image;
images[index].onLoad = preload_complete();
images[index].src = ima[num];
pics_loaded++;
}
}
}