const dayInMonth = moment().format("D");
const currentMonth = moment().format("M");
var i = 1;
while (currentMonth > i) {
var entries = entriesSum(i);
var max = daysInMonth(i);
var perc = entries + "/" + max;
dv.span(
`### ${monthName(i)} <sup>[[${monthNote(i)}|${perc}]]</sup><br>${progressBar(entries, max)}`
);
// Current month
i++;
entries = entriesSum(i);
max = dayInMonth;
perc = entries + "/" + max;
if (currentMonth == i) {
dv.span(
`### 🟢 ${monthName(i)} <sup>[[${monthNote(i)}|${perc}]]</sup><br>${progressBar(entries, max)}`
);
}
}
function monthName(month) {
return moment(`2022-${month}`).format("MMMM");
}
function entriesSum(month) {
var month = month.toString().padStart(2, '0');
const re = new RegExp(`2022-${month}-\\d{2}`);
return dv.pages('"10 Journals/2022.11 Dailies"').where(p => re.test(p.file.name)).array().length;
}
function daysInMonth(month) {
var month = month--;
return moment([2022, month]).daysInMonth();
}
function progressBar(entries, max) {
return `<progress value="${entries}" max="${max}">${entries}</progress>`;
}
function monthNote(month) {
return moment(`2022-${month}`).format("YYYY-MM-MMMM");
}
Forked from selfire1/Obsidian Journal Progress Tracker.md
Created
December 5, 2022 20:46
-
-
Save serpro69/b9e3dfcf82f110e3b851536cd15e6c36 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment