Mercurial > libervia-web
diff libervia/web/pages/calendar/_browser/__init__.py @ 1518:eb00d593801d
refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 02 Jun 2023 16:49:28 +0200 |
parents | libervia/pages/calendar/_browser/__init__.py@ec3ad9abf9f9 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libervia/web/pages/calendar/_browser/__init__.py Fri Jun 02 16:49:28 2023 +0200 @@ -0,0 +1,25 @@ +from browser import document, window +from browser.timer import set_interval + +calendar_start = window.calendar_start + + +def update_current_time_line(): + now = window.Date.new() + + # Calculate the position of the current-time-line + now_ts = now.getTime() / 1000 + minutes_passed = (now_ts - calendar_start) / 60 + + new_top = minutes_passed + 15 + + # Update the current-time-line position and make it visible + current_time_line = document["current-time-line"] + current_time_line.style.top = f"{new_top}px" + current_time_line.hidden = False + +# Initial update +update_current_time_line() + +# Update the current-time-line every minute +set_interval(update_current_time_line, 60 * 1000)