-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
277 lines (182 loc) · 5.45 KB
/
main.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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
let datas=JSON.parse(localStorage.getItem("userData"))
console.log(datas)
document.getElementById("baljor").innerHTML=datas.name
let workout = [
{image:"https://www.gymwolf.com/images/category_chest.jpg",body_name:"Chest"},
{image:"https://www.gymwolf.com/images/category_biceps.jpg",body_name:"Biceps"},
{image:"https://www.gymwolf.com/images/category_triceps.jpg",body_name:"Triceps"},
{image:"https://www.gymwolf.com/images/category_back.jpg",body_name:"Back"},
{image:"https://www.gymwolf.com/images/category_shoulder.jpg",body_name:"Shoulder"},
{image:"https://www.gymwolf.com/images/category_legs.jpg",body_name:"Leg"},
{image:"https://www.gymwolf.com/images/category_abdominal.jpg",body_name:"Abdominal"},
{image:"https://www.gymwolf.com/images/category_combined.jpg",body_name:"Combined"},
{image:"https://www.gymwolf.com/images/category_cardio.jpg",body_name:"Cardio"},
]
let picture = (workout) => {
workout.forEach((el) => {
let {image,body_name}=el;
let div=document.createElement("div");
div.addEventListener("click",() =>{
localStorage.setItem("body_name",JSON.stringify(el));
window.location.href = "chest.html";
})
let image1= document.createElement("img");
image1.src=image;
let smallDiv=document.createElement("div");
smallDiv.setAttribute("class","smallDiv");
let h1 = document.createElement("h2");
h1.innerText=body_name;
smallDiv.append(h1);
div.append(image1,smallDiv);
document.querySelector("#picture").append(div)
})
}
picture(workout);
let abdominal = document.querySelector("#abdominal");
let append = () => {
let url = "http://localhost:3000/Abdominal"
fetch(url)
.then((res)=>{
return res.json()
})
.then((res)=> {
console.log(res);
displayTable(res,abdominal);
})
}
append();
let displayTable = (data,abdominal) => {
data.forEach((el) => {
let {smallImg,title,Sort}=el;
let div = document.createElement("div");
div.setAttribute("class","mainDiv")
let div1 = document.createElement("div");
div1.setAttribute("class","div1")
let div2 = document.createElement("div");
div2.setAttribute("class","div2")
if(smallImg!==""){
let img= document.createElement("img");
img.src = smallImg;
img.setAttribute("class","img")
div1.append(img);
}
let h3 = document.createElement("h3");
h3.addEventListener("click",()=>{
myFunction(el);
})
h3.innerText = title;
h3.setAttribute("class","h3")
let h31 = document.createElement("h31");
h31.innerText = Sort;
h31.setAttribute("class","h31")
div2.append(h3,h31)
div.append(div1,div2);
abdominal.append(div);
})
}
let back = document.querySelector("#back");
let append1 = () => {
let url = "http://localhost:3000/Back"
fetch(url)
.then((res)=>{
return res.json()
})
.then((res)=> {
displayTable(res,back);
})
}
append1();
let biceps = document.querySelector("#biceps");
let append2 = () => {
let url = "http://localhost:3000/Biceps"
fetch(url)
.then((res)=>{
return res.json()
})
.then((res)=> {
displayTable(res,biceps);
})
}
append2();
let chest = document.querySelector("#chest");
let append3 = () => {
let url = "http://localhost:3000/Chest"
fetch(url)
.then((res)=>{
return res.json()
})
.then((res)=> {
displayTable(res,chest);
})
}
append3();
let combined = document.querySelector("#combined");
let append4 = () => {
let url = "http://localhost:3000/Combined"
fetch(url)
.then((res)=>{
return res.json()
})
.then((res)=> {
displayTable(res,combined);
})
}
append4();
let legs = document.querySelector("#legs");
let append5 = () => {
let url = "http://localhost:3000/Legs"
fetch(url)
.then((res)=>{
return res.json()
})
.then((res)=> {
displayTable(res,legs);
})
}
append5();
let shoulder = document.querySelector("#shoulder");
let append7 = () => {
let url = "http://localhost:3000/Shoulder"
fetch(url)
.then((res)=>{
return res.json()
})
.then((res)=> {
displayTable(res,shoulder);
})
}
append7();
let triceps = document.querySelector("#triceps");
let append8 = () => {
let url = "http://localhost:3000/Triceps"
fetch(url)
.then((res)=>{
return res.json()
})
.then((res)=> {
displayTable(res,triceps);
})
}
append8();
let myFunction = (el) => {
if(el.video==""){
localStorage.setItem("data",JSON.stringify(el));
window.location.href = "chestobj.html"
}
else{
localStorage.setItem("data",JSON.stringify(el))
window.location.href = "video.html"
}
}
let one = () => {
window.location.href = "main.html"
}
let two = () => {
window.location.href = "myexercise.html"
}
let three = () => {
window.location.href = "workout.html"
}
document.querySelector("#one").addEventListener("click",one);
document.querySelector("#two").addEventListener("click",two);
document.querySelector("#three").addEventListener("click",three);