-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKratosPageJs.js
130 lines (103 loc) · 3.95 KB
/
KratosPageJs.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
let storyBtn = document.getElementById("storyBtn");
let powersBtn = document.getElementById("powersBtn");
let weaknessBtn = document.getElementById("weaknessBtn");
let infoName = document.getElementById("infoName");
let kratosIMG = document.getElementById("KratosIMG");
let homeLink = document.getElementById("Home");
let characterLink = document.getElementById("Characters");
let contactUsLink = document.getElementById("ContactUs");
let lastRandomNum = 12;
homeLink.addEventListener('mouseover',function(){
linkStyleHover("Home");
});
homeLink.addEventListener('mouseout',function(){
linkStyleInitial("Home");
});
characterLink.addEventListener('mouseover',function(){
linkStyleHover("Characters");
});
characterLink.addEventListener('mouseout',function(){
linkStyleInitial("Characters");
});
contactUsLink.addEventListener('mouseover',function(){
linkStyleHover("ContactUs");
});
contactUsLink.addEventListener('mouseout',function(){
linkStyleInitial("ContactUs");
});
storyBtn.addEventListener('click', function(){
changeInfoName("Kratos");
changeInfoText("infoText");
activelink("storyBtn","powersBtn","weaknessBtn");
document.getElementById("readMoreBtn").href = "https://en.wikipedia.org/wiki/Kratos_(God_of_War)";
})
powersBtn.addEventListener('click',function(){
changeInfoName("Powers");
changeInfoText("infoText2");
activelink("powersBtn","storyBtn","weaknessBtn");
document.getElementById("readMoreBtn").href = "https://www.thegamer.com/kratos-powers-abilities-weakness/";
})
weaknessBtn.addEventListener('click',function(){
changeInfoName("Weakness");
changeInfoText("infoText3");
activelink("weaknessBtn","storyBtn","powersBtn");
document.getElementById("readMoreBtn").href = "https://www.thegamer.com/kratos-powers-abilities-weakness/";
})
kratosIMG.addEventListener('mouseover',function(){
imgStyle("KratosIMG","scale(1.05)");
})
kratosIMG.addEventListener('mouseout',function(){
imgStyle("KratosIMG","scale(1.0)");
})
//-----------------------Functions-----------------------------//
function changeInfoName(title){
infoName.textContent = title;
}
function changeInfoText(id){
document.getElementById("infoText").style.display="none";
document.getElementById("infoText2").style.display="none";
document.getElementById("infoText3").style.display="none";
document.getElementById(id).style.display="block";
}
function imgStyle(imgId,scale){
document.getElementById(imgId).style.transform = scale;
document.getElementById(imgId).style.transition = "900ms";
}
function activelink(activeId,noactive1,noactive2){
document.getElementById(activeId).style.borderColor = "red";
document.getElementById(activeId).style.boxShadow = "0px 0px 10px red";
document.getElementById(noactive1).setAttribute('style',"");
document.getElementById(noactive2).setAttribute('style',"");
}
function linkStyleHover (id) {
let link = document.getElementById(id);
link.style.textDecoration = "2px underline";
link.style.textUnderlineOffset = "10px";
link.style.transition = "350ms";
link.style.transform = "translateY(-5px)";
link.style.opacity = "100%";
}
function linkStyleInitial(id) {
let link = document.getElementById(id);
link.style.textDecoration = "none";
link.style.transition = "350ms";
link.style.transform = "translateY(0px)";
link.style.opacity = "60%";
}
characterLink.addEventListener('click',function(){
// random number between 1 and 3
let randomNum = Math.floor(Math.random() * 3) + 1;
let aLink = document.getElementById("charactersLink");
if(lastRandomNum != randomNum){
if(randomNum == 1){
aLink.setAttribute('href',"KratosPage.html");
}
else if(randomNum == 2){
aLink.setAttribute('href',"KirbyPage.html");
}
else if(randomNum == 3){
aLink.setAttribute('href',"Dante.html");
}
}
lastRandomNum = randomNum;
});