Skip to content

Commit

Permalink
add weekly total
Browse files Browse the repository at this point in the history
  • Loading branch information
r-carroll committed Jul 28, 2024
1 parent f62b363 commit c4d0846
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion content/reading-tracker.html
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@

<div>
<h3><span class="tally-display-hours"></span> hours and <span class="tally-display-minutes"></span> minutes total</h3>
<h3><span class="tally-display-week-hours"></span> hours and <span class="tally-display-week-minutes"></span> minutes this week</h3>

<div id="prayer-section">
<form action="javascript:void(0);">
Expand Down Expand Up @@ -348,7 +349,7 @@ <h2>Hours of the day</h2>
<h2>Days of the week</h2>
<canvas id="daysChart"></canvas>

<h2>Book</h2>
<h2>Minutes spent in each book</h2>
<canvas id="bookChart"></canvas>
</div>

Expand All @@ -368,6 +369,18 @@ <h2>Book</h2>
const daysChart = document.getElementById('daysChart');
const weekChart = document.getElementById('weekChart');
const bookChart = document.getElementById('bookChart');
const weeklyHoursTally = document.getElementById('tally-display-week-hours');
const weeklyMinutesTally = document.getElementById('tally-display-week-minutes');

const weeklyTotal = [...weeklyMap.values()].reduce((prev, current) => prev + current, 0);

for(element in weeklyHoursTally) {
element.innerText = weeklyTotal / 60;
}

for(element in weeklyMinutesTally) {
element.innerText = weeklyTotal % 60;
}

new Chart(weekChart, {
type: 'line',
Expand Down

0 comments on commit c4d0846

Please sign in to comment.