-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
145 lines (126 loc) · 3.9 KB
/
script.js
File metadata and controls
145 lines (126 loc) · 3.9 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
let count = 0;
let incrementInterval;
let fifaCount = 0;
fetch('https://script.google.com/macros/s/AKfycbwtS-dKkGeR6ihR1Ct_00LyC8WpKQXj84TsDtzWLtY8zqo6q0T7av-qqG0dpbQuQXUI6Q/exec')
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
if (!data || !Array.isArray(data)) {
throw new Error('Data is not in the expected format');
}
const events = data;
for (let i = 0; i < events.length; i++) {
if (events[i].eventName === "Fifa") {
fifaCount = events[i].count;
break;
}
}
console.log("Count for Fifa:", fifaCount);
// Once you have the count, you can start incrementing
startIncrementing(fifaCount);
})
.catch(error => console.error('Error fetching or processing data:', error));
function increment() {
count++;
document.getElementById("counter").innerText = count;
}
function decrement() {
if (count > 0) {
count--;
document.getElementById("counter").innerText = count;
}
}
function startIncrementing() {
incrementInterval = setInterval(() => {
if (count < fifaCount) {
increment();
} else {
clearInterval(incrementInterval);
}
}, 10); // Adjust the interval for faster or slower incrementation
}
// When the div is in view, start incrementing
const counterContainer = document.getElementById("counterContainer");
let observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
startIncrementing();
}
});
});
observer.observe(counterContainer);
var num1 = 0;
var num2 = 0;
var num3 = 0;
var angle = 0;
function check() {
num1 += 1;
if (num1 == 101) {
num1 = 0;
}
num2 += 1;
if (num2 == 101) {
num2 = 0;
}
num3 += 1;
if (num3 == 101) {
num3 = 0;
}
angle += 1;
if (angle == 361) {
angle = 0;
}
}
function generateRandomGradient() {
check();
const gradientAngle = angle;
const percentage1 = num1;
const percentage2 = num2;
const percentage3 = num3;
return `linear-gradient(${gradientAngle}deg, #00c0ff ${percentage1}%, #ffffff ${
percentage1 + percentage2
}%, #ffcf00 ${percentage1 + percentage2 + percentage3}%)`;
}
// Function to update background gradient every second
function updateBackground() {
const gradient = generateRandomGradient();
document.querySelector(".counter-container").style.background = gradient;
setTimeout(updateBackground, 10);
}
// Call updateBackground initially
updateBackground();
// Set the event date (YYYY-MM-DD)
const eventDate = new Date("2024-04-01").getTime();
// Update the countdown every second
const timer = setInterval(function () {
// Get the current date and time
const now = new Date().getTime();
// Find the remaining time between now and the event date
const timeRemaining = eventDate - now;
// Calculate days, hours, minutes, and seconds
const days = Math.floor(timeRemaining / (1000 * 60 * 60 * 24));
const hours = Math.floor(
(timeRemaining % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)
);
const minutes = Math.floor((timeRemaining % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((timeRemaining % (1000 * 60)) / 1000);
// Display the countdown
document.getElementById("countert").innerHTML = `
<h1>Countdown to the Event:</h1>
<p>${days}d ${hours}h ${minutes}m ${seconds}s</p>
`;
// If the event date is passed, clear the interval and remove the overlay
if (timeRemaining < 0) {
clearInterval(timer);
document.getElementById("overlayt").style.display = "none";
}
}, 10);
// Close button functionality
document.getElementById("closeBtnt").addEventListener("click", function () {
clearInterval(timer);
document.getElementById("overlayt").style.display = "none";
});