Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
sahajoydeep authored May 10, 2024
1 parent f0610e0 commit 44854be
Showing 1 changed file with 35 additions and 33 deletions.
68 changes: 35 additions & 33 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
function randomImage() {
const options = ["images/2084220.jpg", "images/image1.jpg","images/image2.jpg","images/image3.jpg","images/image4.jpg","images/image5.jpg", "images/image6.jpg", "images/image7.jpg", "images/image8.jpg", "images/image9.jpg", "images/image10.jpg", "images/image11.jpg", "images/image12.jpg"];
const img = document.querySelector("#desktop");
setInterval(function() {
const randomIMG = options[Math.floor(Math.random() * options.length)];
img.src = randomIMG;
img.alt = "";
}, 2500);
document.addEventListener('DOMContentLoaded, function()'){
function randomImage() {
const options = ["images/2084220.jpg", "images/image1.jpg", "images/image2.jpg", "images/image3.jpg", "images/image4.jpg", "images/image5.jpg", "images/image6.jpg", "images/image7.jpg", "images/image8.jpg", "images/image9.jpg", "images/image10.jpg", "images/image11.jpg", "images/image12.jpg"];
const img = document.querySelector("#desktop");
setInterval(function () {
const randomIMG = options[Math.floor(Math.random() * options.length)];
img.src = randomIMG;
img.alt = "";
}, 2500);

const colors = [
"rgb(255, 218, 185)", // Peach
"rgb(173, 216, 230)", // Light Blue
"rgb(144, 238, 144)", // Light Green
"rgb(255, 192, 203)", // Pink
"rgb(221, 160, 221)", // Lavender
"rgb(255, 250, 205)", // Lemon Chiffon
"rgb(176, 224, 230)", // Powder Blue
"rgb(255, 228, 196)", // Bisque
"rgb(240, 255, 240)", // Honeydew
"rgb(245, 245, 220)", // Beige
"rgb(240, 248, 255)", // Alice Blue
"rgb(255, 222, 173)", // Navajo White
"rgb(230, 230, 250)", // Lavender Blue
"rgb(240, 255, 240)", // Honeydew
"rgb(255, 240, 245)" // Lavender Blush
];

let currentIndex = 0;
const colors = [
"rgb(255, 218, 185)", // Peach
"rgb(173, 216, 230)", // Light Blue
"rgb(144, 238, 144)", // Light Green
"rgb(255, 192, 203)", // Pink
"rgb(221, 160, 221)", // Lavender
"rgb(255, 250, 205)", // Lemon Chiffon
"rgb(176, 224, 230)", // Powder Blue
"rgb(255, 228, 196)", // Bisque
"rgb(240, 255, 240)", // Honeydew
"rgb(245, 245, 220)", // Beige
"rgb(240, 248, 255)", // Alice Blue
"rgb(255, 222, 173)", // Navajo White
"rgb(230, 230, 250)", // Lavender Blue
"rgb(240, 255, 240)", // Honeydew
"rgb(255, 240, 245)" // Lavender Blush
];

function changeBackgroundColor() {
document.body.style.backgroundColor = colors[currentIndex];
currentIndex = (currentIndex + 1) % colors.length;
}

setInterval(changeBackgroundColor, 2500);
let currentIndex = 0;

function changeBackgroundColor() {
document.body.style.backgroundColor = colors[currentIndex];
currentIndex = (currentIndex + 1) % colors.length;
}

setInterval(changeBackgroundColor, 2000);
}
}

0 comments on commit 44854be

Please sign in to comment.