From b703819b744524ef873a942137492f62d64d14fa Mon Sep 17 00:00:00 2001 From: ZaneYork Date: Wed, 11 Sep 2024 10:15:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=80=92=E8=AE=A1=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dinner.py | 1 + templates/dinner.html | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/dinner.py b/src/dinner.py index 0b5a53e..6f072e9 100644 --- a/src/dinner.py +++ b/src/dinner.py @@ -101,6 +101,7 @@ def dinner_update(): :return: 响应内容 """ user_agent_string = request.headers.get('User-Agent') + print(user_agent_string) if not is_mobile_request(user_agent_string): abort(403) if check_roll() != 0: diff --git a/templates/dinner.html b/templates/dinner.html index 4b3e450..840b216 100644 --- a/templates/dinner.html +++ b/templates/dinner.html @@ -29,7 +29,8 @@ -
@@ -46,8 +47,9 @@ {% endfor %}
-
本项目抽签完全公开透明,源码开放欢迎随时审查 +
@@ -98,6 +100,31 @@ } }) } + + $(function () { + const counterId = window.setInterval(counter, 1000); + + function counter() { + const now = new Date(); + const targetTime = new Date( + now.getFullYear(), now.getMonth(), now.getDate(), + 17, 30, 0, 0 + ); + const diff = targetTime - now; + btn = $("#btnRoll"); + if (diff <= 0) { + window.clearInterval(counterId); + btn.text('开始抽签'); + btn.attr('disabled', null) + return; + } + // Convert diff to hours, minutes, and seconds + const hours = Math.floor(diff / (1000 * 60 * 60)).toString().padStart(2, '0'); + const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60)).toString().padStart(2, '0'); + const seconds = Math.floor((diff % (1000 * 60)) / 1000).toString().padStart(2, '0'); + btn.text(hours + ':' + minutes + ':' + seconds) + } + }); \ No newline at end of file