From 0dab3112b231fb50afcd1ec6ab8ded02d8b51d0e Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Fri, 2 Jun 2023 20:35:56 +0200 Subject: [PATCH] almost fixed the slideshow freezing --- res/index/script.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/res/index/script.js b/res/index/script.js index 41f96ad..d1e6190 100644 --- a/res/index/script.js +++ b/res/index/script.js @@ -4,13 +4,13 @@ let last_index = -1; function change_slideshow_img() { - let buffer = (imgs_index === undefined || imgs_index.length == 0) ? imgs_index_2 : imgs_index; + let buffer = (imgs_index === undefined || imgs_index.length === 0) ? imgs_index_2 : imgs_index; let random_index; do { random_index = Math.floor(Math.random() * buffer.length); - } while (random_index == last_index); + } while (buffer[random_index] == last_index); document.getElementById("slideshow").src = "http://207.180.212.190/fht/fabrika_imgs/downscaled/" + buffer[random_index] + ".jpg"; @@ -24,7 +24,9 @@ function change_slideshow_img() imgs_index_2.splice(random_index, 1); } - last_index = random_index; + console.log(buffer[random_index] + "\n" + last_index + "\n\n"); - setTimeout(function() {change_slideshow_img()}, 3000); + last_index = buffer[random_index]; + + setTimeout(change_slideshow_img, 3000); } \ No newline at end of file