Gnandal Elisée• 170
@Gnandal
Posted
Your data didn't update automaticaly when I swich the filter
1
Thanks for the replay @Gnandal Elisee It was working perfectly when I was working on vscode live server. but after I uploaded it to GitHub pages I stopped working. can you help me solve this problem?
0
Gnandal Elisée• 170
@Gnandal
Posted
@Mohammed-Nedjima The problem is in your updateData function, replace it by this :
const updateData = (data) => {
//Initialize your variables before
let currWork = document.getElementById("curr-work");
let prevWork = document.getElementById("prev-work");
let currPlay = document.getElementById("curr-play");
let prevPlay = document.getElementById("prev-play");
let currStudy = document.getElementById("curr-study");
let prevStudy = document.getElementById("prev-study");
let currExercise = document.getElementById("curr-exercise");
let prevExercise = document.getElementById("prev-exercise");
let currSocial = document.getElementById("curr-social");
let prevSocial = document.getElementById("prev-social");
let currSelfCare = document.getElementById("curr-selfcare");
let prevSelfCare = document.getElementById("prev-selfcare");
//End initialization
// categories.forEach((item) => {
// if (item === "SelfCare") {
// item = "Self Care";
// } else {
// item = item.toLowerCase();
// }
// const itemData = data.find((e) => e.title === item);
// console.log(itemData);
// });
currWork.textContent = data[0].timeframes[timeframe].current + "hrs";
prevWork.textContent = data[0].timeframes[timeframe].previous + "hrs";
currPlay.textContent = data[1].timeframes[timeframe].current + "hrs";
prevPlay.textContent = data[1].timeframes[timeframe].previous + "hrs";
currStudy.textContent = data[2].timeframes[timeframe].current + "hrs";
prevStudy.textContent = data[2].timeframes[timeframe].previous + "hrs";
currExercise.textContent =
data[3].timeframes[timeframe].current + "hrs";
prevExercise.textContent =
data[3].timeframes[timeframe].previous + "hrs";
currSocial.textContent = data[4].timeframes[timeframe].current + "hrs";
prevSocial.textContent =
data[4].timeframes[timeframe].previous + "hrs";
currSelfCare.textContent =
data[5].timeframes[timeframe].current + "hrs";
prevSelfCare.textContent =
data[5].timeframes[timeframe].previous + "hrs";
};
1