remade slideshow logic

This commit is contained in:
Václav Šmejkal 2024-05-08 10:13:50 +02:00
parent 2a531107e4
commit fe5d2c7391
Signed by: ENGO150
GPG Key ID: 4A57E86482968843

View File

@ -1,37 +1,25 @@
//let imgs_index = [ 59, 58, 56, 55, 54, 67, 66, 64, 61, 60 ]; //let imgs_index = [ 59, 58, 56, 55, 54, 67, 66, 64, 61, 60 ];
let imgs_index = [ 54, 55, 56, 57, 58, 59, 60, 61, 62, 63 ]; let imgs_index = [ 54, 55, 56, 57, 58, 59, 60, 61, 62, 63 ];
let imgs_index_2 = []; let last_index = imgs_index.length - 1;
let last_index = -1;
let login_clicked = false; let login_clicked = false;
let register_clicked = false; let register_clicked = false;
function change_slideshow_img() function change_slideshow_img()
{ {
let buffer = (imgs_index == undefined || imgs_index.length == 0) ? imgs_index_2 : imgs_index; if (last_index == imgs_index.length - 1)
let random_index = 5;
do
{ {
random_index = Math.floor(Math.random() * buffer.length); let first_index = imgs_index[0];
//console.log("A");
} while (buffer[random_index] == last_index);
document.getElementById("slideshow").src = "http://109.123.243.163/fht/fabrika_imgs/downscaled/" + buffer[random_index] + ".jpg"; do
{
imgs_index.sort(() => Math.random() - 0.5);
} while (first_index == imgs_index[0]);
if (imgs_index.includes(buffer[random_index])) last_index = 0;
{
imgs_index_2.push(buffer[random_index]);
imgs_index.splice(random_index, 1);
} else
{
imgs_index.push(buffer[random_index]);
imgs_index_2.splice(random_index, 1);
} }
//console.log(buffer[random_index] + "\n" + last_index + "\n\n"); document.getElementById("slideshow").src = "http://109.123.243.163/fht/fabrika_imgs/downscaled/" + imgs_index[last_index++] + ".jpg";
last_index = buffer[random_index];
} }
function repeat_panorama() function repeat_panorama()