-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdailyMood.js
37 lines (35 loc) · 1.35 KB
/
dailyMood.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
/*!
* Trilium-DailyMood v1.0
* https://github.com/dvai/Trilium-DailyMood
*
* Licensed Apache-2.0 © 东东
*/
function addTodayMood() {
setTimeout(async () => {
const emojis = ["😡", "👽", "😞", "😕", "😐", "🙂", "😊", "😄", "😆", "🥰", "🤩"];
var calendar = $(document).find('.calendar-body');
var dates = calendar.find('.calendar-date');
await dates.each(async function () {
var targetDate = $(this);
var dayNoteDate = targetDate.attr("data-calendar-date");
if (!targetDate.attr("href")) {
return;
};
const dayNote = await api.getDayNote(dayNoteDate);
var todayMood = dayNote.getLabelValue("todayMood");
if (todayMood === null || todayMood === "") {
return;
}
todayMood = parseInt(todayMood)
var childElement = targetDate.find('span');
targetDate.html(
`<div style="position: relative;width:100%"><div style="text-align:center">${childElement.html()}</div >
<div style="font-size:12px;position: absolute; top: 0; right: 0;">${emojis[todayMood]}</div>
</div > `);
});
}, 90)
}
$(document).ready(function () {
$('.bx-calendar').on('click', addTodayMood);
$('.calendar-btn').on('click', addTodayMood);
})