-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhome.js
128 lines (110 loc) · 3.32 KB
/
home.js
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
const tileContainer = document.getElementById("tileContainer");
const homeBtn = document.getElementById("homebtn");
const panel3 = document.getElementById("panel3"),
panel4 = document.getElementById("panel4");
setUserLoggedInStatus(false);
const colorSchemeOcean = [
"#00BFFF",
"#1E90FF",
"#87CEEB",
"#20B2AA",
"#48D1CC",
"#00CED1",
"#5F9EA0",
"#4682B4",
"#B0E0E6",
];
const colorSchemeNightSky = [
"#1C1C56",
"#2E2E99",
"#4B0082",
"#6A0888",
"#8A084B",
"#A901DB",
"#D0A9F5",
"#F5A9E1",
"#FAFAD2",
];
// Determine tile size and number
const tilesAcrossWidth = 20;
const tileSize = window.innerWidth / tilesAcrossWidth;
const numRows = Math.ceil(window.innerHeight / tileSize);
const numCols = tilesAcrossWidth;
// Array to hold the previous color for each tile to ensure no two tiles touch with the same color.
let previousColors = Array(numRows)
.fill()
.map(() => Array(numCols).fill(""));
for (let i = 0; i < numRows; i++) {
for (let j = 0; j < numCols; j++) {
const tile = document.createElement("div");
tile.classList.add("tile");
tile.style.width = `${tileSize}px`;
tile.style.height = `${tileSize}px`;
let color;
do {
color =
colorSchemeOcean[Math.floor(Math.random() * colorSchemeOcean.length)];
} while (
(i > 0 && previousColors[i - 1][j] === color) ||
(j > 0 && previousColors[i][j - 1] === color)
);
previousColors[i][j] = color;
tile.style.background = color;
tileContainer.appendChild(tile);
}
}
function transitionColors(currentScheme, nextScheme) {
let newColors = Array(numRows)
.fill()
.map(() => Array(numCols).fill(""));
for (let i = 0; i < numRows; i++) {
for (let j = 0; j < numCols; j++) {
const tile = tileContainer.children[i * numCols + j];
let newColor;
do {
newColor = nextScheme[Math.floor(Math.random() * nextScheme.length)];
} while (
(i > 0 &&
(tileContainer.children[(i - 1) * numCols + j].style.background ===
newColor ||
newColors[i - 1][j] === newColor)) ||
(j > 0 &&
(tileContainer.children[i * numCols + j - 1].style.background ===
newColor ||
newColors[i][j - 1] === newColor))
);
newColors[i][j] = newColor;
tile.style.background = newColor;
}
}
}
function openLoginWindow() {
loginTransition();
var userLoginUrl = 'login.html'
window.location.href = userLoginUrl;
}
function guestLogin() {
loginTransition();
var guestLoginUrl = '/Graph/index.html'
window.location.href = guestLoginUrl;
}
function loginTransition() {
const loginButton = document.getElementById("loginButton");
const guestButton = document.getElementById("guestButton");
// Fade out the login button
loginButton.style.opacity = "0";
loginButton.style.transition = "opacity 3s, transform 1s";
loginButton.style.transform = "scale(0.2)";
guestButton.style.opacity = "0";
guestButton.style.transition = "opacity 3s, transform 1s";
guestButton.style.transform = "scale(0.2)";
}
let currentScheme = colorSchemeOcean;
let nextScheme = colorSchemeNightSky;
window.addEventListener("load", () => {
setInterval(() => {
transitionColors(currentScheme, nextScheme);
// Swap schemes for the next transition
[currentScheme, nextScheme] = [nextScheme, currentScheme];
}, 4000); // every 4 seconds
});