From d34aaec76eb0cedbd5ac444c845835ce61b56c27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DNyymix=E2=80=9D?= Date: Mon, 25 Apr 2022 10:56:58 +0300 Subject: [PATCH] Add js code --- main.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/main.js b/main.js index e69de29..bc3acb3 100644 --- a/main.js +++ b/main.js @@ -0,0 +1,13 @@ +setInterval(setClock, 1000); + +function setClock() { + const currentDate = new Date(); + + const secRatio = currentDate.getSeconds() / 60; + const minRatio = (secRatio + currentDate.getMinutes()) / 60; + const horRatio = (minRatio + currentDate.getHours()) / 12; + + document.getElementById('sek').style.setProperty('--rotation', secRatio * 360); + document.getElementById('min').style.setProperty('--rotation', minRatio * 360); + document.getElementById('hrs').style.setProperty('--rotation', horRatio * 360); +} \ No newline at end of file