From 08d00aabd6247d828a36f7a738892c2c511db164 Mon Sep 17 00:00:00 2001 From: Kira Edges Date: Fri, 16 May 2025 11:10:33 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B3=D0=B8=D1=82=D0=B8=D0=B3=D0=BD=D0=BE?= =?UTF-8?q?=D1=80=20=D0=BF=D0=BE=D0=B4=D1=81=D1=82=D0=B0=D0=B2=D0=B8=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 - static/index.js | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 static/index.js diff --git a/.gitignore b/.gitignore index 2a3c60e..8553ec1 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,3 @@ bin/ # vweb and database *.db -*.js diff --git a/static/index.js b/static/index.js new file mode 100644 index 0000000..73c9d57 --- /dev/null +++ b/static/index.js @@ -0,0 +1,23 @@ + const startDate = new Date('2019-06-20T00:00:00Z'); /* будем считать, что именно в это время был первый релиз */ + + function updateYearsPassed() { + const now = Date.now(); + const millisecondsPerYear = 1000 * 60 * 60 * 24 * 365.2425; /* учёт високосных лет */ + const yearsPassed = (now - startDate) / millisecondsPerYear; + + document.getElementById('counter').textContent = + `${yearsPassed}`; + } + + function updateYear() { + const now = new Date().getFullYear(); + years = document.getElementsByClassName("year") + for (year in years) { + year.textContent = ` ${now} `} +} + + updateYearsPassed(); /* сразу при загрузке */ + updateYear(); + setInterval(updateYearsPassed, 10); + setInterval(updateYear, 10000); + /* код написал чат гопоты, мне осталось лишь подправить. Каюсь, гречневая */