-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContactUsJs.js
159 lines (122 loc) · 4.48 KB
/
ContactUsJs.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
let lastRandomNum = 12;
//---------- link hover style --------------------
let homeLink = document.getElementById("Home");
homeLink.addEventListener('mouseover',function(){
linkStyleHover("Home");
});
homeLink.addEventListener('mouseout',function(){
linkStyleInitial("Home");
});
let characterLink = document.getElementById("Characters");
characterLink.addEventListener('mouseover',function(){
linkStyleHover("Characters");
});
characterLink.addEventListener('mouseout',function(){
linkStyleInitial("Characters");
});
let contactUsLink = document.getElementById("ContactUs");
contactUsLink.addEventListener('mouseover',function(){
linkStyleHover("ContactUs");
});
contactUsLink.addEventListener('mouseout',function(){
linkStyleInitial("ContactUs");
});
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%";
}
//------ Random page when characters link is clicked ------
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");
}
}
lastRandomNum = randomNum;
});
//------ get rid of blue borders which browser adds when onfocus--------
let inputBox = document.getElementsByTagName("input");
let textareaBox = document.getElementById("message");
for(let i = 0; i < inputBox.length; i++){
inputBox[i].addEventListener('focus',function(){
inputBoxfocus(inputBox[i]);
})
}
textareaBox.addEventListener('focus',function(){
inputBoxfocus(textareaBox);
})
function inputBoxfocus(tag){
tag.style.outline = "none";
}
//--------------------- submit btn-----------------------------
let submitBtn = document.getElementById("SubmitBtn");
//--------------------- submit hover style-----------------------------
submitBtn.onmouseover = function(){
submitBtn.style.transform = "scale(1.02)";
submitBtn.style.transition = "200ms";
submitBtn.style.backgroundColor = "rgb(80, 80, 80)";
submitBtn.style.color = "white";
}
submitBtn.onmouseout = function(){
submitBtn.setAttribute('style',"");
}
//--------------------- submit Message-----------------------------
submitBtn.onclick = function (){
document.getElementById("formTag").style.display = "none";
let inputBoxes = document.getElementsByClassName("input");
for(let i = 0; i< inputBoxes.length; i++){
inputBoxes[i].value="";
}
textareaBox.value="";
let newDiv = document.createElement("div");
newDiv.style.padding = "227.7px 25%";
newDiv.style.justifyContent = "center";
let newH1 = document.createElement("h1");
newH1.style.color = "white";
newH1.style.textAlign = "center";
newH1.textContent = "Thank You !";
let newP = document.createElement("p");
newP.style.color = "white";
newP.style.textAlign = "center";
let newTextNode1 = document.createTextNode("Thank you for contacting us. We will respond to you ");
let newTextNode2 = document.createTextNode("through email within seven days, so please");
let newTextNode3 = document.createTextNode(" keep an eye on your mailbox.");
let br1 = document.createElement("br");
let br2 = document.createElement("br");
newP.appendChild(newTextNode1);
newP.appendChild(br1);
newP.appendChild(newTextNode2);
newP.appendChild(br2);
newP.appendChild(newTextNode3);
let parenDiv = document.getElementById("parentDiv");
newDiv.appendChild(newH1);
newDiv.appendChild(newP);
parenDiv.appendChild(newDiv);
setTimeout(function(){
newDiv.removeChild(newH1);
newDiv.removeChild(newP);
parenDiv.removeChild(newDiv);
let form = document.getElementById("formTag");
form.style.display="block";
},10000);
}