diff options
| author | Ngô Ngọc Đức Huy <huyngo@disroot.org> | 2025-12-07 23:36:29 +0700 |
|---|---|---|
| committer | Ngô Ngọc Đức Huy <huyngo@disroot.org> | 2025-12-07 23:36:29 +0700 |
| commit | 011ba89beb683320afb0d70429a135577581f412e15fa7877f08a66eb3ee08ac (patch) | |
| tree | 316f97b1061744ae57dc5066105881de70284ba43b18e5d2fbd9209fdc2d322a /static/cal/lunar.js | |
| parent | 7e16e67efaa63873ca1c4f130a48798ece3130c071555880eb01fee9fc3f441e (diff) | |
| download | new-blog-011ba89beb683320afb0d70429a135577581f412e15fa7877f08a66eb3ee08ac.tar.gz | |
Implement permanent link for calendar
Diffstat (limited to 'static/cal/lunar.js')
| -rw-r--r-- | static/cal/lunar.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/static/cal/lunar.js b/static/cal/lunar.js index 763f7cc..a4aeb33 100644 --- a/static/cal/lunar.js +++ b/static/cal/lunar.js @@ -294,6 +294,8 @@ const weekdayFormatEN = new Intl.DateTimeFormat("en-US", {weekday: "long"}) const weekdayFormatVI = new Intl.DateTimeFormat("vi-VN", {weekday: "long"}) const weekdayFormatZH = new Intl.DateTimeFormat("zh-CN", {weekday: "long"}) +const datePermalinkA = document.querySelector('#date-permalink') + const SOLAR_MONTH_VI = ["Một", "Hai", "Ba", "Tư", "Năm", "Sáu", "Bảy", "Tám", "Chín", "Mười", "Mười Một", "Mười Hai"] const LUNAR_MONTH_VI = ["Giêng", "Hai", "Ba", "Tư", "Năm", "Sáu", "Bảy", "Tám", "Chín", "Mười", "Mười Một", "Chạp"] const LUNAR_MONTH_ZH = ["元", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "臘", ] @@ -479,9 +481,18 @@ function getSpecialDays(date, lunarDate) { } function updateOutputs() { + const url = new URL(document.location) if (dateInput.valueAsDate === null) { - dateInput.valueAsDate = new Date() + const dateStr = url.searchParams.get('date') + if (dateStr) { + dateInput.valueAsDate = new Date(dateStr) + } else { + dateInput.valueAsDate = new Date() + } } + url.searchParams.set('date', dateInput.value) + datePermalinkA.innerText = url + datePermalinkA.href = url const date = dateInput.valueAsDate solarYearOutput.innerText = date.getFullYear() solarMonthOutputEN.innerText = monthFormatEN.format(date) |
