2024-09-10 10:55:19 +08:00
|
|
|
|
<html lang="zh">
|
|
|
|
|
<head>
|
|
|
|
|
<title>晚餐吃什么鸭</title>
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
2024-09-10 15:39:26 +08:00
|
|
|
|
<link rel="stylesheet" href="/static/bootstrap.min.css">
|
2024-09-10 10:55:19 +08:00
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<div class="container text-center" style="padding-top: 120px">
|
|
|
|
|
<p>每天8:00-17:30间开放匿名投票更新,17:30以后允许发起抽签,抽签结果确定后不可更改</p>
|
|
|
|
|
<p>随机抽签,按得票数决定中签概率</p>
|
|
|
|
|
{% if last_result %}
|
2024-09-10 11:31:03 +08:00
|
|
|
|
<p>今日{{ last_result }}最终得票数降低30%</p>
|
2024-09-10 10:55:19 +08:00
|
|
|
|
{% endif %}
|
|
|
|
|
<form id="inputForm" class="form-inline">
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<div class="input-group">
|
|
|
|
|
<span class="input-group-addon">我选择</span>
|
|
|
|
|
</div>
|
|
|
|
|
{% for choice in all_choice %}
|
|
|
|
|
<div class="input-group">
|
|
|
|
|
<label for="range{{ loop.index }}" class="form-label">{{ choice['label'] }}
|
|
|
|
|
- {{ '{:.2f}'.format((menu.get(choice['name']) or 0) * 100) }}%</label>
|
|
|
|
|
<input type="range" class="form-range" id="range{{ loop.index }}" name="{{ choice['name'] }}"
|
|
|
|
|
min="0"
|
|
|
|
|
max="10" step="1" value="{{ (menu.get(choice['name']) or 0) * 10 }}">
|
|
|
|
|
</div>
|
|
|
|
|
{% endfor %}
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
<button type="button" class="btn btn-primary" onclick="update()">更新</button>
|
|
|
|
|
<button type="button" class="btn btn-secondary" onclick="clearValue()">不吃</button>
|
|
|
|
|
<button type="button" class="btn btn-secondary" {{ "" if can_roll == True else 'disabled="disabled"' | safe }}
|
|
|
|
|
onclick="roll()">开始抽签
|
|
|
|
|
</button>
|
|
|
|
|
<div style="padding-top: 40px">
|
2024-09-10 11:31:03 +08:00
|
|
|
|
<label>大家的选择 - 总票数:{{ '{:.2f}'.format(total_vote | round(2)) }}</label>
|
2024-09-10 10:55:19 +08:00
|
|
|
|
<ul style="padding-top: 20px; margin-bottom: 80px" class="list-group">
|
|
|
|
|
{% for key in summary %}
|
|
|
|
|
<li class="list-group-item {{ "active" if result == key else "" }}">
|
|
|
|
|
<div class="row justify-content-between">
|
2024-09-10 11:31:03 +08:00
|
|
|
|
<span class="col-5">{{ key }}</span>
|
2024-09-10 10:55:19 +08:00
|
|
|
|
<span class="col-3">{{ '{:.2f}'.format(summary[key] | round(2)) }}票</span>
|
2024-09-10 11:31:03 +08:00
|
|
|
|
<span class="col-3">{{ '{:.2f}'.format(summary[key] / total_vote * 100 | round(2)) }}%</span>
|
2024-09-10 10:55:19 +08:00
|
|
|
|
</div>
|
|
|
|
|
</li>
|
|
|
|
|
{% endfor %}
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
2024-09-11 07:44:31 +08:00
|
|
|
|
<div class="fixed-bottom" style="padding-bottom: 20px"><a class="link-secondary" style="text-decoration: none; font-size: 0.8rem"
|
2024-09-10 11:31:03 +08:00
|
|
|
|
href="https://git.zaneyork.cn:8443/ZaneYork/dinner_vote">本项目抽签完全公开透明,源码开放欢迎随时审查</a>
|
|
|
|
|
</div>
|
2024-09-10 10:55:19 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
2024-09-10 15:39:26 +08:00
|
|
|
|
<script src="/static/jquery-3.2.1.min.js"></script>
|
|
|
|
|
<script src="/static/jquery.serializejson.js"></script>
|
|
|
|
|
<script src="/static/bootstrap.bundle.min.js"></script>
|
2024-09-10 10:55:19 +08:00
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
function update() {
|
|
|
|
|
var data = $('#inputForm').serializeJSON();
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: 'dinner/update?value=' + JSON.stringify(data),
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
success: function (result) {
|
2024-09-10 15:39:26 +08:00
|
|
|
|
if (result.code === 0) {
|
2024-09-10 10:55:19 +08:00
|
|
|
|
window.location.reload();
|
|
|
|
|
} else {
|
|
|
|
|
alert('更新失败: ' + result.data)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function clearValue() {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: 'dinner/update?value=',
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
success: function (result) {
|
2024-09-10 15:39:26 +08:00
|
|
|
|
if (result.code === 0) {
|
2024-09-10 10:55:19 +08:00
|
|
|
|
window.location.reload();
|
|
|
|
|
} else {
|
|
|
|
|
alert('更新失败: ' + result.data)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function roll() {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: 'dinner/roll',
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
success: function (result) {
|
2024-09-10 15:39:26 +08:00
|
|
|
|
if (result.code === 0) {
|
2024-09-10 10:55:19 +08:00
|
|
|
|
window.location.reload();
|
|
|
|
|
} else {
|
|
|
|
|
alert('更新失败: ' + result.data)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|