-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
90 lines (54 loc) · 2.36 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
80
81
82
83
84
85
86
87
88
89
90
import data from './data.json' assert {type:'json'};
let nameActivities = document.querySelectorAll(".actualInfo_span");
let actualInfo_h2 = document.querySelectorAll(".actualInfo_h2");
let lastInfo_label = document.querySelectorAll(".content_label");
let timeOptions = document.querySelectorAll(".divTime_spanTime");
showNormalData();
timeOptions[0].addEventListener("click", () => dataSelection("daily"));
timeOptions[1].addEventListener("click", () => dataSelection("weekly"));
timeOptions[2].addEventListener("click", () => dataSelection("monthly"));
function dataSelection(typeData){
switch(typeData){
case "weekly":
showWeeklyData();
console.log("weekly");
break;
case "daily" :
showDailyData();
console.log("daily");
break;
case "monthly":
showMonthlyData();
console.log("monthly");
break;
default: console.log("default");
}
}
function showNormalData(){
for(let i = 0 ; i < nameActivities.length;i++){
nameActivities[i].textContent=data[i].title;
actualInfo_h2[i].textContent = "-- hrs";
lastInfo_label[i].textContent = `Last week : -- hrs`;
}
}
function showWeeklyData(){
for(let i = 0 ; i < nameActivities.length;i++){
nameActivities[i].textContent=data[i].title;
actualInfo_h2[i].textContent = data[i].timeframes.weekly.current + "hrs";
lastInfo_label[i].textContent = `Last week - ${data[i].timeframes.weekly.previous} hrs`;
}
}
function showDailyData(){
for(let i = 0 ; i < nameActivities.length;i++){
nameActivities[i].textContent=data[i].title;
actualInfo_h2[i].textContent = data[i].timeframes.daily.current + "hrs";
lastInfo_label[i].textContent = `Last day - ${data[i].timeframes.daily.previous} hrs`;
}
}
function showMonthlyData(){
for(let i = 0 ; i < nameActivities.length;i++){
nameActivities[i].textContent=data[i].title;
actualInfo_h2[i].textContent = data[i].timeframes.monthly.current + "hrs";
lastInfo_label[i].textContent = `Last month - ${data[i].timeframes.monthly.previous} hrs`;
}
}