Thanks to @qz-cqy!
This commit is contained in:
billchenchina 2021-04-25 21:58:47 +08:00
parent 507844cc61
commit 78846bc1b8
No known key found for this signature in database
GPG Key ID: 98220BE9242CCE41
2 changed files with 6 additions and 5 deletions

View File

@ -62,13 +62,14 @@ EOD;
); );
if ($rest_second <= 86400) { if ($rest_second <= 86400) {
$notification = json_encode($upcoming_contest_name . "已经开始了。是否要跳转到比赛页面?");
echo <<<EOD echo <<<EOD
<div class="text-center bot-buffer-lg"> <div class="text-center bot-buffer-lg">
<div class="text-warning">$upcoming_contest_name 倒计时</div> <div class="text-warning">$upcoming_contest_name 倒计时</div>
<div id="contest-countdown"></div> <div id="contest-countdown"></div>
<script type="text/javascript"> <script type="text/javascript">
$('#contest-countdown').countdown($rest_second, function() { $('#contest-countdown').countdown($rest_second, function() {
if (confirm('$upcoming_contest_name 已经开始了。是否要跳转到比赛页面?')) { if (confirm($notification)) {
window.location.href = "$upcoming_contest_href"; window.location.href = "$upcoming_contest_href";
} }
}); });

View File

@ -104,20 +104,20 @@
var rating_data = [[ var rating_data = [[
<?php <?php
$user_rating_min = $user_rating_max = 1500; $user_rating_min = $user_rating_max = 1500;
$result = DB::query("select contest_id, rank, user_rating from contests_registrants where username = '{$user['username']}' and has_participated = 1 order by contest_id"); $result = DB::query("select contest_id, `rank`, user_rating from contests_registrants where username = '{$user['username']}' and has_participated = 1 order by contest_id");
$is_first_row = true; $is_first_row = true;
$last_rating = 1500; $last_rating = 1500;
while ($row = DB::fetch($result)) { while ($row = DB::fetch($result)) {
$contest = queryContest($row['contest_id']); $contest = queryContest($row['contest_id']);
$rating_delta = $row['user_rating'] - $last_rating; $rating_delta = $row['user_rating'] - $last_rating;
if (!$is_first_row) { if (!$is_first_row) {
echo "[$last_contest_time, {$row['user_rating']}, $last_contest_id, '$last_contest_name', $last_rank, $rating_delta],"; echo "[$last_contest_time, {$row['user_rating']}, $last_contest_id, $last_contest_name, $last_rank, $rating_delta],";
} else { } else {
$is_first_row = false; $is_first_row = false;
} }
$contest_start_time = new DateTime($contest['start_time']); $contest_start_time = new DateTime($contest['start_time']);
$last_contest_time = ($contest_start_time->getTimestamp() + $contest_start_time->getOffset()) * 1000; $last_contest_time = ($contest_start_time->getTimestamp() + $contest_start_time->getOffset()) * 1000;
$last_contest_name = $contest['name']; $last_contest_name = json_encode($contest['name']);
$last_contest_id = $contest['id']; $last_contest_id = $contest['id'];
$last_rank = $row['rank']; $last_rank = $row['rank'];
$last_rating = $row['user_rating']; $last_rating = $row['user_rating'];
@ -134,7 +134,7 @@ var rating_data = [[
echo "[{$time_now_stamp}, {$user['rating']}, 0]"; echo "[{$time_now_stamp}, {$user['rating']}, 0]";
} else { } else {
$rating_delta = $user['rating'] - $last_rating; $rating_delta = $user['rating'] - $last_rating;
echo "[$last_contest_time, {$user['rating']}, $last_contest_id, '$last_contest_name', $last_rank, $rating_delta]"; echo "[$last_contest_time, {$user['rating']}, $last_contest_id, $last_contest_name, $last_rank, $rating_delta]";
} }
if ($user['rating'] < $user_rating_min) { if ($user['rating'] < $user_rating_min) {
$user_rating_min = $user['rating']; $user_rating_min = $user['rating'];