-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
231 lines (180 loc) · 6.98 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
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
function toggleMenu() {
const navButtons = document.querySelectorAll(".btn-nav");
const navMenu = document.querySelector("nav ul");
navButtons.forEach((element) => {
element.addEventListener("click", function () {
navMenu.classList.toggle("active");
});
});
}
toggleMenu();
async function getServices() {
const response = await fetch("http://localhost:3000/services");
const services = await response.json();
services.forEach(function (service) {
createServiceItem(
service.image,
service.title,
service.description,
"Learn More",
service.link
);
});
}
async function getTestimonials() {
const response = await fetch("http://localhost:3000/testimonials");
const testimonials = await response.json();
testimonials.forEach(function (testimonial) {
createTestimonialItem(
testimonial.author,
testimonial.image,
testimonial.area,
testimonial.testimonial
);
});
}
async function getFAQs() {
const response = await fetch("http://localhost:3000/faqs");
const faqs = await response.json();
faqs.forEach(function (item) {
createFAQItem(item.question, item.answer);
});
}
async function getProjects() {
const response = await fetch("http://localhost:3000/projects");
const projects = await response.json();
projects.forEach(function (item) {
createProjectItem(item.image, item.title, item.category);
});
}
async function getTeam() {
const response = await fetch("http://localhost:3000/team");
const team = await response.json();
team.forEach(function (item) {
createTeamItem(item.image, item.name, item.area, item.slogan);
});
}
async function getStrategyCards() {
const response = await fetch("http://localhost:3000/strategyCards");
const strategyCards = await response.json();
strategyCards.forEach(function (item) {
createStrategyCardItem(item.id, item.title, item.description);
});
}
getServices();
getTestimonials();
getFAQs();
getProjects();
getTeam();
getStrategyCards();
function createStrategyCardItem(id, title, description) {
const strategyCardsList = document.querySelector(".strategy-cards-container");
const strategyCardItem = document.createElement("div");
strategyCardItem.classList.add("strategy-card");
const orderItem = document.createElement("div");
orderItem.classList.add("order");
orderItem.textContent = `0${id}`;
strategyCardItem.append(orderItem);
const infoItem = document.createElement("div");
infoItem.classList.add("info");
const infoTitle = document.createElement("h3");
infoTitle.textContent = title;
const infoDescription = document.createElement("p");
infoDescription.textContent = description;
infoItem.append(infoTitle, infoDescription);
strategyCardItem.append(infoItem);
strategyCardsList.append(strategyCardItem);
}
function createTeamItem(image, name, area, slogan) {
const teamList = document.querySelector(".team-list");
const teamItemContainer = document.createElement("div");
teamItemContainer.classList.add("team-item");
const imageElement = document.createElement("img");
imageElement.setAttribute("src", image);
teamItemContainer.append(imageElement);
const titleElement = document.createElement("h3");
titleElement.textContent = name;
teamItemContainer.append(titleElement);
const paragraph = document.createElement("p");
paragraph.textContent = area;
teamItemContainer.append(paragraph);
const paragraph2 = document.createElement("p");
paragraph2.textContent = slogan;
teamItemContainer.append(paragraph2);
teamList.append(teamItemContainer);
}
function createProjectItem(image, title, category) {
const projectsList = document.querySelector(".projects-container");
const projectItemContainer = document.createElement("div");
projectItemContainer.classList.add("project");
const imageElement = document.createElement("img");
imageElement.setAttribute("src", image);
projectItemContainer.append(imageElement);
const titleElement = document.createElement("h3");
titleElement.textContent = title;
projectItemContainer.append(titleElement);
const paragraph = document.createElement("p");
paragraph.textContent = category;
projectItemContainer.append(paragraph);
projectsList.append(projectItemContainer);
}
function createFAQItem(question, answer) {
const faqsList = document.querySelector(".faqs-list");
const faqItemContainer = document.createElement("div");
faqItemContainer.classList.add("faqs-item");
const faqContainer = document.createElement("details");
const faqQuestion = document.createElement("summary");
faqQuestion.textContent = question;
const faqAnswer = document.createElement("p");
faqAnswer.textContent = answer;
faqContainer.append(faqQuestion, faqAnswer);
faqItemContainer.append(faqContainer);
faqsList.append(faqItemContainer);
}
function createServiceItem(imageURL, title, description, linkText, linkHref) {
const servicesList = document.querySelector(".services-list");
const serviceItemContainer = document.createElement("div");
serviceItemContainer.classList.add("service-item");
const imageElement = document.createElement("img");
imageElement.setAttribute("src", imageURL);
serviceItemContainer.append(imageElement);
const titleElement = document.createElement("h3");
titleElement.textContent = title;
serviceItemContainer.append(titleElement);
const paragraph = document.createElement("p");
paragraph.textContent = description;
serviceItemContainer.append(paragraph);
const link = document.createElement("a");
link.textContent = linkText;
link.setAttribute("href", linkHref);
serviceItemContainer.append(link);
servicesList.append(serviceItemContainer);
}
function createTestimonialItem(author, image, area, testimonial) {
const testimonialsList = document.querySelector(".testimonials-list");
const testimonialsItemContainer = document.createElement("div");
testimonialsItemContainer.classList.add("testimonials-item");
const paragraph = document.createElement("p");
paragraph.textContent = testimonial;
const testimonialAuthorContainer = document.createElement("div");
testimonialAuthorContainer.classList.add("testimonials-author");
const testimonialImageContainer = document.createElement("div");
testimonialImageContainer.classList.add("image");
const imageElement = document.createElement("img");
imageElement.setAttribute("src", image);
testimonialImageContainer.append(imageElement);
const testimonialBioContainer = document.createElement("div");
testimonialBioContainer.classList.add("bio");
const authorElement = document.createElement("h3");
authorElement.textContent = author;
testimonialBioContainer.append(authorElement);
const areaElement = document.createElement("p");
areaElement.textContent = area;
testimonialBioContainer.append(areaElement);
testimonialAuthorContainer.append(
testimonialImageContainer,
testimonialBioContainer
);
testimonialsItemContainer.append(paragraph, testimonialAuthorContainer);
testimonialsList.append(testimonialsItemContainer);
}