-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
88 lines (71 loc) · 2.5 KB
/
Copy pathmain.js
File metadata and controls
88 lines (71 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
window.addEventListener("load", () => {
const images = document.querySelectorAll("#background img");
let currentIndex = 0;
// Function to switch images
function switchImage() {
// Remove 'active' class from the current image
images[currentIndex].classList.remove("active");
// Calculate the next index
currentIndex = (currentIndex + 1) % images.length;
// Add 'active' class to the new image
images[currentIndex].classList.add("active");
}
// Set an interval to change the background every 10 seconds
setInterval(switchImage, 10000);
// Announcements cycling functionality
const announcements = [
"This is one out of 4 example announements!",
"We hope you enjoy this project",
"Announement 3",
"Announcement 4",
];
let currentAnnouncementIndex = 0;
const announcementText = document.getElementById("announcement-text");
// Function to update announcements
function updateAnnouncement() {
announcementText.textContent = announcements[currentAnnouncementIndex];
currentAnnouncementIndex = (currentAnnouncementIndex + 1) % announcements.length;
}
// Start cycling announcements
updateAnnouncement(); // Set the initial announcement
setInterval(updateAnnouncement, 30000); // Update every 30 seconds
// Clock function
clock();
function clock() {
const today = new Date();
let hours = today.getHours();
const minutes = today.getMinutes();
const seconds = today.getSeconds();
const hourTime = hours > 12 ? hours - 12 : hours === 0 ? 12 : hours;
const ampm = hours < 12 ? "AM" : "PM";
const minute = minutes < 10 ? "0" + minutes : minutes;
const second = seconds < 10 ? "0" + seconds : seconds;
const month = today.getMonth();
const year = today.getFullYear();
const day = today.getDate();
const monthList = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
];
const date = `${monthList[month]} ${day}, ${year}`;
const time = `${hourTime}:${minute}:${second} ${ampm}`;
const dateTime = `${date} - ${time}`;
const clockElement = document.getElementById("date-time");
if (clockElement) {
clockElement.innerHTML = dateTime;
} else {
console.error("Clock element with ID 'date-time' not found.");
}
setTimeout(clock, 1000);
}
});