-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
77 lines (65 loc) · 2.08 KB
/
index.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
const Languages = {
English: "en",
Spanish: "es",
};
function checkLanguage() {
const mainURL = "deathbymisstep.com/";
const currURL = location.href.slice(location.href.indexOf("/") + 2);
if (currURL != mainURL) {
localStorage.currLanguage = getLanguageURL(currURL);
} else {
const languageSet = localStorage.currLanguage ? true : false;
if (!languageSet) {
const browserLanguage = navigator.language.substring(0, 2);
localStorage.currLanguage = browserLanguage;
}
if (localStorage.currLanguage != Languages.English) {
if (!isLanguageAvailable(localStorage.currLanguage)) return;
location.replace(
location.protocol + "//" + mainURL + localStorage.currLanguage
);
}
}
}
function getLanguageURL(url) {
return url.slice(url.indexOf("/") + 1, url.lastIndexOf("/"));
}
function isLanguageAvailable(currLanguage) {
for (let language in Languages) {
if (Languages[language] === currLanguage) return true;
}
return false;
}
checkLanguage();
document.addEventListener("DOMContentLoaded", () => {
AddEventListenersInTeam();
document
.querySelector(".languageButton")
.addEventListener("click", function () {
ChangeLanguage();
});
});
function AddEventListenersInTeam() {
const teamMemberImgs = document.querySelectorAll(".team-member-img");
const teamCardLinks = document.querySelectorAll(".team-card-link");
const teamSize = teamMemberImgs.length;
for (let i = 0; i < teamSize; i++) {
teamMemberImgs[i].addEventListener("mouseover", function () {
teamCardLinks[i].classList.toggle("team-card-link-hover");
});
teamMemberImgs[i].addEventListener("mouseout", function () {
teamCardLinks[i].classList.toggle("team-card-link-hover");
});
}
}
function ChangeLanguage() {
let newLanguage = this.innerHTML;
switch (newLanguage) {
case "Español":
newLanguage = Languages.Spanish;
break;
default:
newLanguage = Languages.English;
}
localStorage.currLanguage = newLanguage;
}