From c2f92a5b363a6b5892c273a0e3602b796b1d509b Mon Sep 17 00:00:00 2001 From: Venkatsai Bellala <42386481+vskbellala@users.noreply.github.com> Date: Fri, 10 Mar 2023 17:44:34 -0500 Subject: [PATCH] library updates, redo photo slideshow --- docs/index.html | 17 +++++++++-------- docs/scripts.js | 36 ++++++++++++++++++++++++++---------- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/docs/index.html b/docs/index.html index edfed6f..a2aee9b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -8,8 +8,8 @@ Brown Solar Charger - - + + @@ -51,10 +51,10 @@

The Solar Charger

@@ -85,13 +85,14 @@

The Solar Charger

setTimeout(loadJSON, 10, 'data/monthData', call_plots_month, { 'up': upTime * 1000, 'down': downTime * 1000 }); //Carousel stuff const img = document.getElementById('stn'); - const rightBtn = document.getElementById('right-btn'); - const leftBtn = document.getElementById('left-btn');// Images are from unsplash + // const rightBtn = document.getElementById('right-btn'); + // const leftBtn = document.getElementById('left-btn');// Images are from unsplash // img.src = pictures[0]; img.style.backgroundImage = 'url('+pictures[0]+')'; let position = 0; - rightBtn.addEventListener("click", moveRight); - leftBtn.addEventListener("click", moveLeft); + // rightBtn.addEventListener("click", moveRight); + // leftBtn.addEventListener("click", moveLeft); + advanceP(); diff --git a/docs/scripts.js b/docs/scripts.js index 89cd9b4..59c32e9 100644 --- a/docs/scripts.js +++ b/docs/scripts.js @@ -232,12 +232,28 @@ const moveRight = () => { position++; } +const advanceP = () => { + if (position >= pictures.length - 1) { + position = 0; + img.style.backgroundImage = 'url(' + pictures[position] + ')'; + // img.style.animation = "sweep-right .5s ease-in-out"; + // setTimeout(setIdle, 500); + // img.src = pictures[position]; + } else { + img.style.backgroundImage = 'url(' + pictures[position + 1] + ')'; + // img.style.animation = "sweep-right .5s ease-in-out"; + // setTimeout(setIdle, 500); + // img.src = pictures[position + 1]; + position++; + } + setTimeout(advanceP,2000); +} + const moveLeft = () => { if (position < 1) { position = pictures.length - 1; img.style.backgroundImage = 'url(' + pictures[position] + ')'; - img.style.animation = "sweep .5s ease-in-out"; - setTimeout(setIdle, 500); + img.style.animation = "sweep .5s ease-in-out"; setTimeout(setIdle, 500); // img.src = pictures[position]; return; } @@ -295,7 +311,7 @@ function fill_stat(id, stat) { function call_stats(d) { liveUp(d); // increments carousel on each stats update (~30 seconds), still can manual control between update - moveRight(); // comment out to disable "slideshow" + // moveRight(); // comment out to disable "slideshow" if (d.Available) { availUp(); } else { @@ -536,13 +552,13 @@ function tdiff(a, b) { } str += ", "; } - if (seconds > 0) { - str += seconds + " second"; - if (seconds > 1) { - str += "s"; - } - str += ", "; - } + // if (seconds > 0) { + // str += seconds + " second"; + // if (seconds > 1) { + // str += "s"; + // } + // str += ", "; + // } str = str.substring(0, str.length - 2); return str + " ago"; } \ No newline at end of file