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)
+ }
+ });