Mercurial > libervia-web
comparison libervia/pages/calendar/_browser/__init__.py @ 1508:ec3ad9abf9f9
pages (calendar): calendar page, first draft
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 07 Apr 2023 15:20:40 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1507:ae5158f3c420 | 1508:ec3ad9abf9f9 |
---|---|
1 from browser import document, window | |
2 from browser.timer import set_interval | |
3 | |
4 calendar_start = window.calendar_start | |
5 | |
6 | |
7 def update_current_time_line(): | |
8 now = window.Date.new() | |
9 | |
10 # Calculate the position of the current-time-line | |
11 now_ts = now.getTime() / 1000 | |
12 minutes_passed = (now_ts - calendar_start) / 60 | |
13 | |
14 new_top = minutes_passed + 15 | |
15 | |
16 # Update the current-time-line position and make it visible | |
17 current_time_line = document["current-time-line"] | |
18 current_time_line.style.top = f"{new_top}px" | |
19 current_time_line.hidden = False | |
20 | |
21 # Initial update | |
22 update_current_time_line() | |
23 | |
24 # Update the current-time-line every minute | |
25 set_interval(update_current_time_line, 60 * 1000) |