-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
79 lines (62 loc) · 2.54 KB
/
script.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
/* --------------- Theme control --------------- */
const themeSelector = () => {
const selectTheme = document.getElementById("selectTheme");
const themeProvider = document.getElementById("themeProvider");
themeProvider.setAttribute("href", `./themes/${selectTheme.value}.css`);
selectTheme.addEventListener("change", () => {
themeProvider.setAttribute("href", `./themes/${selectTheme.value}.css`);
});
};
themeSelector();
/* --------------- Dropdown button --------------- */
const dropDown = document.getElementById("dropdown");
const rightNav = document.getElementById("right-nav");
const handleDropDown = () => {
if (rightNav.style.display === "block") {
rightNav.style.display = "none";
} else {
rightNav.style.display = "block";
}
};
dropDown.addEventListener("click", handleDropDown);
/* --------------- Read more and less button --------------- */
const readMoreBtn = document.getElementsByClassName("read-more-button");
const readLessBtn = document.getElementsByClassName("read-less-button");
for (i = 0; i < readMoreBtn.length; i++) {
let select = i;
readMoreBtn[i].addEventListener("click", () => {
const moreDetail = document.getElementsByClassName("more-detail");
moreDetail[select].style.display = "inline";
readMoreBtn[select].style.display = "none";
readLessBtn[select].style.display = "block";
});
readLessBtn[i].addEventListener("click", () => {
const moreDetail = document.getElementsByClassName("more-detail");
moreDetail[select].style.display = "none";
readLessBtn[select].style.display = "none";
readMoreBtn[select].style.display = "block";
});
}
/* --------------- Submit and less button --------------- */
const submitBtn = document.getElementById("submit");
const name = document.getElementById("name");
const subject = document.getElementById("subject");
const email = document.getElementById("email");
const message = document.getElementById("message");
const consent = document.getElementById("consent")
submitBtn.addEventListener("click", () => {
if (name.value && subject.value && email.value && message.value && consent.checked === true) {
alert(
"Subject \t" +
subject.value +
"\n\nDear " +
name.value +
"," +
"\n\nFirst of all, we would like to express our thanks for your interest in our Agency." +
"\n\nRegarding your inquiry, we are considering your request and get back to you as soon as possible" +
"\n\nYours sincerely," +
"\n\nLisa H" +
"\n\nSales Department | L&K Agency."
);
}
});