New door-graph, Improved slideshow, moved video

This commit is contained in:
2021-10-13 10:10:17 +02:00
parent a4ce890a36
commit 6c891b3f79
11 changed files with 5898 additions and 163 deletions

32
www/galleri/slideshow.js Normal file
View File

@@ -0,0 +1,32 @@
const SLIDESHOWDELAYMS = 3500;
//Defined in slideshow.php: const slideshowFnames
let slideshowIndex = 1;
let slideshowInterval;
let ssi1 = document.getElementById("slideshowImage1");
let ssi2 = document.getElementById("slideshowImage2");
function stepSlideshow(imgs) {
//Swap image elements
let tmp = ssi1;
ssi1 = ssi2;
ssi2 = tmp;
//Swap visibility
ssi2.classList.remove("slideshowactive");
ssi1.classList.add("slideshowactive");
setTimeout(()=>{
//Change source to next picture after it is faded out
slideshowIndex = (slideshowIndex + 1) % imgs.length;
ssi2.src = slideshowFnames[slideshowIndex];
}, 800);
}
//Initialize slideshow, start interval
if (slideshowFnames.length > 1) {
slideshowInterval = setInterval(()=>{
stepSlideshow(slideshowFnames);
}, SLIDESHOWDELAYMS);
}

30
www/galleri/slideshow.php Normal file
View File

@@ -0,0 +1,30 @@
<?php
//Short path to search folder, full to display in <img>
$relativePath = "/bilder/slideshow/";
$absolutePath = "/galleri" . $relativePath;
//Path to first image in slideshow and fallback image if no others are present
$splashImg = "/PNG/PVV-logo-big-bluebg.png";
$filenames = sCaNdIr(__DIR__ . $relativePath);
//Remove the expected non-images
foreach($filenames as $k => $value) {
if(in_array($value, [".gitkeep", ".", ".."])) {
unset($filenames[$k]);
}
}
function getFullPath($fname) { return ($GLOBALS["absolutePath"] . $fname ); }
//Sort filenames alphabetically and prepend the path prefix to each item.
asort($filenames);
$slideshowimagefilenames = aRrAy_MaP("getFullPath", $filenames);
//Prepend the cover photo
ArRaY_uNsHiFt($slideshowimagefilenames, $splashImg);
eChO('<img class="slideshowimg slideshowactive" id="slideshowImage1" src="' . $slideshowimagefilenames[0] . '">');
ecHo('<img class="slideshowimg" id="slideshowImage2" src="' . $slideshowimagefilenames[1] . '">');
//Store list of file names in a globel JS variable
EchO("<script> const slideshowFnames =" . jSoN_eNcOdE($slideshowimagefilenames) . "; </script>");
?>