-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotion.js
51 lines (35 loc) · 1.82 KB
/
notion.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
const progressBar = document.querySelector('.progress-bar');
const progressText = document.querySelector('.progress-text');
const smallBar = document.getElementById("smallBar");
const startDate = new Date('2024-09-21');
const endDate = new Date('2025-06-14');
const totalDuration = endDate.getTime() - startDate.getTime();
const today = new Date();
const elapsedTime = today.getTime() - startDate.getTime();
const progress = Math.min(elapsedTime / totalDuration, 1) * 100;
progressBar.style.width = `${progress}%`;
progressText.textContent = `${progress.toFixed(2)}%`;
const daysRemainingSpan = document.getElementById("days-remaining");
const monthsRemainingSpan = document.getElementById("months-remaining");
const yearsRemainingSpan = document.getElementById("years-remaining");
function updateCountdown() {
const today = new Date();
const diffInMs = endDate.getTime() - today.getTime();
const inDays = (diffInMs / (1000 * 60 * 60 * 24))
const years = Math.floor(inDays / 365);
const months = Math.floor((inDays % 365) / 30);
const days = Math.floor((inDays % 365) % 30 );
daysRemainingSpan.textContent = days;
monthsRemainingSpan.textContent = months;
yearsRemainingSpan.textContent = years;
}
updateCountdown();
setInterval(updateCountdown, 1000);
//------------------------------------------------------------------------------------------------------------ https://www.notion.so/Done-progress-ced96d9767d94d07a42599c5f6c72319?pvs=4
const { Client } = require('@notionhq/client');
const notion = new Client({ auth: "secret_loXza0WvvrPh8vgHlciXaydRbajsaf54JPqS8e75mTC" });
(async () => {
const pageId = "ced96d9767d94d07a42599c5f6c72319";
const response = await notion.pages.retrieve({ page_id: pageId });
smallBar.style.width = `${(Math.round(response.properties['Percentage done'].rollup.number *1000)/10)}%`;
})();