Compare commits

...

9 Commits

Author SHA1 Message Date
bff23cfdfd
fix: index page bs4
All checks were successful
continuous-integration/drone/push Build is passing
2022-09-24 08:33:36 +08:00
2367452bcd
feat: frontend version switch 2022-09-24 08:26:39 +08:00
bd79eebb44
refactor: submissions_list with bs5 2022-09-24 08:13:39 +08:00
02f181cc5b
fix: navbar search form 2022-09-24 07:01:13 +08:00
b50b3ee67c
refactor: backgrounds 2022-09-24 06:58:20 +08:00
6caffead0e
fix: body overflow-y 2022-09-24 06:28:50 +08:00
3f6582b478
fix: bs5 navbar divider color 2022-09-24 06:28:02 +08:00
a8233f1cb6
refactor: msg page with bs5 2022-09-24 06:25:27 +08:00
c967357e01
fix: footer margin-top 2022-09-24 06:19:26 +08:00
8 changed files with 275 additions and 41 deletions

View File

@ -3,7 +3,9 @@
$countdowns = DB::selectAll("select * from countdowns order by endtime asc");
$friend_links = DB::selectAll("select * from friend_links order by level desc, id asc");
$REQUIRE_LIB['bootstrap5'] = '';
if (!isset($_COOKIE['bootstrap4'])){
$REQUIRE_LIB['bootstrap5'] = '';
}
?>
<?php echoUOJPageHeader(UOJConfig::$data['profile']['oj-name-short']) ?>
<div class="row">
@ -65,18 +67,41 @@
<?php endif ?>
</div>
</div>
<?php if (Auth::check() && isNormalUser($myUser)): ?>
<div class="mt-4">
<h4><?= UOJLocale::get('top solver') ?></h4>
<?php echoRanklist(array('echo_full' => true, 'top10' => true, 'by_accepted' => true)) ?>
<div class="text-center">
<a href="/solverlist"
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
class="text-decoration-none"
<?php endif ?>
><?= UOJLocale::get('view all') ?></a>
<?php if (Auth::check()): ?>
<?php if (isNormalUser($myUser)): ?>
<div class="mt-4
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
card
<?php endif ?>
">
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<div class="card-body">
<h4 class="card-title"><?= UOJLocale::get('top solver') ?></h4>
<?php else: ?>
<h3><?= UOJLocale::get('top solver') ?></h3>
<?php endif ?>
<?php echoRanklist(array(
'echo_full' => true,
'top10' => true,
'by_accepted' => true,
'table_classes' => isset($REQUIRE_LIB['bootstrap5'])
? array('table', 'text-center')
: array('table', 'table-bordered', 'table-hover', 'table-striped', 'table-text-center'),
)) ?>
<div class="text-center">
<a href="/solverlist"
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
class="text-decoration-none"
<?php endif ?>
><?= UOJLocale::get('view all') ?></a>
</div>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
</div>
<?php endif ?>
</div>
<?php endif ?>
<?php else: ?>
<div class="mt-4 card card-default">
<div class="card-body text-center">
@ -91,7 +116,7 @@
</div>
<div class="card card-default mt-4">
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<div class="card-header">
<div class="card-header bg-white">
<b>倒计时</b>
</div>
<?php endif ?>
@ -127,7 +152,7 @@
</div>
<div class="card card-default mt-4">
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<div class="card-header">
<div class="card-header bg-white">
<b>友情链接</b>
</div>
<?php endif ?>

View File

@ -37,6 +37,11 @@
} else {
$cond = '1';
}
if (!isset($_COOKIE['bootstrap4'])){
$REQUIRE_LIB['bootstrap5'] = '';
}
?>
<?php echoUOJPageHeader(UOJLocale::get('submissions')) ?>
<div class="d-none d-sm-block">
@ -46,21 +51,37 @@
</div>
<?php endif ?>
<form id="form-search" class="form-inline" method="get">
<div id="form-group-problem_id" class="form-group">
<div id="form-group-problem_id" class="form-group
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
d-inline-block
<?php endif ?>
">
<label for="input-problem_id" class="control-label"><?= UOJLocale::get('problems::problem id')?>:</label>
<input type="text" class="form-control input-sm" name="problem_id" id="input-problem_id" value="<?= $q_problem_id ?>" maxlength="4" style="width:4em" />
</div>
<div id="form-group-submitter" class="form-group">
<div id="form-group-submitter" class="form-group
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
d-inline-block
<?php endif ?>
">
<label for="input-submitter" class="control-label"><?= UOJLocale::get('username')?>:</label>
<input type="text" class="form-control input-sm" name="submitter" id="input-submitter" value="<?= $q_submitter ?>" maxlength="20" style="width:10em" />
</div>
<div id="form-group-score" class="form-group">
<div id="form-group-score" class="form-group
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
d-inline-block
<?php endif ?>
">
<label for="input-min_score" class="control-label"><?= UOJLocale::get('score range')?>:</label>
<input type="text" class="form-control input-sm" name="min_score" id="input-min_score" value="<?= $q_min_score ?>" maxlength="3" style="width:4em" placeholder="0" />
<label for="input-max_score" class="control-label">~</label>
<input type="text" class="form-control input-sm" name="max_score" id="input-max_score" value="<?= $q_max_score ?>" maxlength="3" style="width:4em" placeholder="100" />
</div>
<div id="form-group-language" class="form-group">
<div id="form-group-language" class="form-group
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
d-inline-block
<?php endif ?>
">
<label for="input-language" class="control-label"><?= UOJLocale::get('problems::language')?>:</label>
<input type="text" class="form-control input-sm" name="language" id="input-language" value="<?= $html_esc_q_language ?>" maxlength="10" style="width:8em" />
</div>
@ -85,7 +106,21 @@
</script>
<div class="top-buffer-sm"></div>
</div>
<?php
echoSubmissionsList($cond, 'order by id desc', array('judge_time_hidden' => ''), $myUser);
echoSubmissionsList($cond,
'order by id desc',
array(
'judge_time_hidden' => '',
'table_config' => (isset($REQUIRE_LIB['bootstrap5'])
? array(
'div_classes' => array('card', 'mb-3'),
'table_classes' => array('table', 'mb-0', 'uoj-submissions-table', 'text-center')
)
: array()
),
),
$myUser);
?>
<?php echoUOJPageFooter() ?>

View File

@ -58,9 +58,15 @@ function redirectToLogin() {
}
}
function becomeMsgPage($msg, $title = '消息') {
global $REQUIRE_LIB;
if (UOJContext::isAjax()) {
die($msg);
} else {
if (!isset($_COOKIE['bootstrap4'])){
$REQUIRE_LIB['bootstrap5'] = '';
}
echoUOJPageHeader($title);
echo $msg;
echoUOJPageFooter();
@ -107,20 +113,36 @@ function getUserName($username, $realname = null) {
function getProblemLink($problem, $problem_title = '!title_only') {
global $REQUIRE_LIB;
if ($problem_title == '!title_only') {
$problem_title = $problem['title'];
} elseif ($problem_title == '!id_and_title') {
$problem_title = "#${problem['id']}. ${problem['title']}";
}
return '<a href="/problem/'.$problem['id'].'">'.$problem_title.'</a>';
$result = '<a ';
if (isset($REQUIRE_LIB['bootstrap5'])) {
$result .= ' class="text-decoration-none" ';
}
$result .= ' href="/problem/'.$problem['id'].'">'.$problem_title.'</a>';
return $result;
}
function getContestProblemLink($problem, $contest_id, $problem_title = '!title_only') {
global $REQUIRE_LIB;
if ($problem_title == '!title_only') {
$problem_title = $problem['title'];
} elseif ($problem_title == '!id_and_title') {
$problem_title = "#{$problem['id']}. {$problem['title']}";
}
return '<a href="/contest/'.$contest_id.'/problem/'.$problem['id'].'">'.$problem_title.'</a>';
$result = '<a ';
if (isset($REQUIRE_LIB['bootstrap5'])) {
$result .= ' class="text-decoration-none" ';
}
$result .= ' href="/contest/'.$contest_id.'/problem/'.$problem['id'].'">'.$problem_title.'</a>';
return $result;
}
function getBlogLink($id) {
if (validateUInt($id) && $blog = queryBlog($id)) {
@ -234,6 +256,8 @@ function getSubmissionStatusDetails($submission) {
}
function echoSubmission($submission, $config, $user) {
global $REQUIRE_LIB;
$problem = queryProblemBrief($submission['problem_id']);
$submitterLink = getUserLink($submission['submitter']);
@ -255,7 +279,11 @@ function echoSubmission($submission, $config, $user) {
echo '<tr class="warning">';
}
if (!isset($config['id_hidden'])) {
echo '<td><a href="/submission/', $submission['id'], '">#', $submission['id'], '</a></td>';
echo '<td><a ';
if (isset($REQUIRE_LIB['bootstrap5'])) {
echo ' class="text-decoration-none" ';
}
echo ' href="/submission/', $submission['id'], '">#', $submission['id'], '</a></td>';
}
if (!isset($config['problem_hidden'])) {
if ($submission['contest_id']) {
@ -287,7 +315,11 @@ function echoSubmission($submission, $config, $user) {
echo '<td>', $used_memory_str, '</td>';
}
echo '<td>', '<a href="/submission/', $submission['id'], '">', $submission['language'], '</a>', '</td>';
echo '<td>', '<a ';
if (isset($REQUIRE_LIB['bootstrap5'])) {
echo ' class="text-decoration-none" ';
}
echo ' href="/submission/', $submission['id'], '">', $submission['language'], '</a>', '</td>';
if ($submission['tot_size'] < 1024) {
$size_str = $submission['tot_size'] . 'b';
@ -354,6 +386,8 @@ function echoSubmissionsListOnlyOne($submission, $config, $user) {
function echoSubmissionsList($cond, $tail, $config, $user) {
global $REQUIRE_LIB;
$header_row = '<tr>';
$col_names = array();
$col_names[] = 'submissions.status_details';

View File

@ -76,16 +76,44 @@ class Paginator {
}
public function pagination() {
global $REQUIRE_LIB;
if ($this->n_pages == 1) {
return '';
}
$html = '<ul class="pagination top-buffer-no bot-buffer-sm justify-content-center">';
if ($this->cur_page > 1) {
$html .= '<li class="page-item"><a class="page-link" href="'.$this->getPageUri(1).'"><span class="glyphicon glyphicon glyphicon-fast-backward"></span></a></li>';
$html .= '<li class="page-item"><a class="page-link" href="'.$this->getPageUri($this->cur_page - 1).'"><span class="glyphicon glyphicon glyphicon-backward"></span></a></li>';
$html .= '<li class="page-item">'
. '<a class="page-link" href="'.$this->getPageUri(1).'">';
if (isset($REQUIRE_LIB['bootstrap5'])) {
$html .= '<i class="bi bi-chevron-double-left"></i>';
} else {
$html .= '<span class="glyphicon glyphicon glyphicon-fast-backward"></span>';
}
$html .= '</a></li>';
$html .= '<li class="page-item">'
. '<a class="page-link" href="'.$this->getPageUri($this->cur_page - 1).'">';
if (isset($REQUIRE_LIB['bootstrap5'])) {
$html .= '<i class="bi bi-chevron-left"></i>';
} else {
$html .= '<span class="glyphicon glyphicon glyphicon-backward"></span>';
}
$html .= '</a></li>';
} else {
$html .= '<li class="page-item disabled"><a class="page-link"><span class="glyphicon glyphicon glyphicon-fast-backward"></span></a></li>';
$html .= '<li class="page-item disabled"><a class="page-link"><span class="glyphicon glyphicon glyphicon-backward"></span></a></li>';
$html .= '<li class="page-item disabled"><a class="page-link">';
if (isset($REQUIRE_LIB['bootstrap5'])) {
$html .= '<i class="bi bi-chevron-double-left"></i>';
} else {
$html .= '<span class="glyphicon glyphicon glyphicon-fast-backward"></span>';
}
$html .= '</a></li>';
$html .= '<li class="page-item disabled"><a class="page-link">';
if (isset($REQUIRE_LIB['bootstrap5'])) {
$html .= '<i class="bi bi-chevron-left"></i>';
} else {
$html .= '<span class="glyphicon glyphicon glyphicon-backward"></span>';
}
$html .= '</a></li>';
}
for ($i = max($this->cur_page - $this->max_extend, 1); $i <= min($this->cur_page + $this->max_extend, $this->n_pages); $i++) {
@ -96,11 +124,38 @@ class Paginator {
}
}
if ($this->cur_page < $this->n_pages) {
$html .= '<li class="page-item"><a class="page-link" href="'.$this->getPageUri($this->cur_page + 1).'"><span class="glyphicon glyphicon glyphicon-forward"></span></a></li>';
$html .= '<li class="page-item"><a class="page-link" href="'.$this->getPageUri($this->n_pages).'"><span class="glyphicon glyphicon glyphicon-fast-forward"></span></a></li>';
$html .= '<li class="page-item">'
. '<a class="page-link" href="'.$this->getPageUri($this->cur_page + 1).'">';
if (isset($REQUIRE_LIB['bootstrap5'])) {
$html .= '<i class="bi bi-chevron-right"></i>';
} else {
$html .= '<span class="glyphicon glyphicon glyphicon-forward"></span>';
}
$html .= '</a></li>';
$html .= '<li class="page-item">'
. '<a class="page-link" href="'.$this->getPageUri($this->n_pages).'">';
if (isset($REQUIRE_LIB['bootstrap5'])) {
$html .= '<i class="bi bi-chevron-double-right"></i>';
} else {
$html .= '<span class="glyphicon glyphicon glyphicon-fast-forward"></span>';
}
$html .= '</a></li>';
} else {
$html .= '<li class="page-item disabled"><a class="page-link"><span class="glyphicon glyphicon glyphicon-forward"></span></a></li>';
$html .= '<li class="page-item disabled"><a class="page-link"><span class="glyphicon glyphicon glyphicon-fast-forward"></span></a></li>';
$html .= '<li class="page-item disabled"><a class="page-link">';
if (isset($REQUIRE_LIB['bootstrap5'])) {
$html .= '<i class="bi bi-chevron-right"></i>';
} else {
$html .= '<span class="glyphicon glyphicon glyphicon-forward"></span>';
}
$html .= '</a></li>';
$html .= '<li class="page-item disabled"><a class="page-link">';
if (isset($REQUIRE_LIB['bootstrap5'])) {
$html .= '<i class="bi bi-chevron-double-right"></i>';
} else {
$html .= '<span class="glyphicon glyphicon glyphicon-fast-forward"></span>';
}
$html .= '</a></li>';
}
$html .= '</ul>';
return $html;

View File

@ -6,7 +6,13 @@
}
?>
<div class="navbar navbar-light navbar-expand-md bg-light mb-4" role="navigation">
<div class="navbar navbar-light navbar-expand-md
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
bg-white shadow-sm
<?php else: ?>
bg-light
<?php endif ?>
mb-4" role="navigation">
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<div class="container">
<?php endif ?>
@ -30,7 +36,7 @@
<li class="nav-item">
<a class="nav-link" href="<?= HTML::url('/contests') ?>">
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<i class="bi bi-bar-chart-line-fill"></i>
<i class="bi bi-bar-chart-line"></i>
<?php else: ?>
<span class="glyphicon glyphicon-stats"></span>
<?php endif ?>
@ -50,7 +56,7 @@
<li class="nav-item">
<a class="nav-link" href="<?= HTML::url('/groups') ?>">
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<i class="bi bi-people-fill"></i>
<i class="bi bi-people"></i>
<?php else: ?>
<span class="glyphicon glyphicon-education"></span>
<?php endif ?>
@ -70,7 +76,7 @@
<li class="nav-item">
<a class="nav-link" href="<?= HTML::url('/submissions') ?>">
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<i class="bi bi-pie-chart-fill"></i>
<i class="bi bi-pie-chart"></i>
<?php else: ?>
<span class="glyphicon glyphicon-tasks"></span>
<?php endif ?>
@ -80,7 +86,7 @@
<li class="nav-item">
<a class="nav-link" href="<?= HTML::url('/hacks') ?>">
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<i class="bi bi-flag-fill"></i>
<i class="bi bi-flag"></i>
<?php else: ?>
<span class="glyphicon glyphicon-flag"></span>
<?php endif ?>
@ -100,17 +106,43 @@
<li class="nav-item">
<a class="nav-link" href="<?= HTML::url('/faq') ?>">
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<i class="bi bi-question-circle-fill"></i>
<i class="bi bi-question-circle"></i>
<?php else: ?>
<span class="glyphicon glyphicon-info-sign"></span>
<?php endif ?>
<?= UOJLocale::get('help') ?>
</a>
</li>
<?php if (!isset($REQUIRE_LIB['bootstrap5'])): ?>
<li class="nav-item">
<a class="nav-link" href="#" id="try-bs5">
<span class="glyphicon glyphicon-share"></span>
体验新版
</a>
<script>
$('#try-bs5').click(function() {
$.removeCookie('bootstrap4', { path: '/' });
location.reload();
});
</script>
</li>
<?php endif ?>
</ul>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<hr class="d-lg-none text-white-50">
<hr class="d-lg-none text-muted">
<ul class="nav navbar-nav ms-md-auto">
<li class="nav-item">
<a class="nav-link" href="#" id="back-to-bs4">
<i class="bi bi-sign-turn-left"></i>
返回旧版
</a>
<script>
$('#back-to-bs4').click(function() {
$.cookie('bootstrap4', '1', { expires: 7, path: '/' });
location.reload();
});
</script>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<i class="bi bi-translate"></i>
@ -202,6 +234,15 @@
<?php endif ?>
<?php endif ?>
</ul>
<?php else: ?>
<form id="form-search-problem" class="form-inline my-2 my-lg-0" method="get">
<div class="input-group">
<input type="text" class="form-control" name="search" id="input-search" placeholder="<?= UOJLocale::get('search')?>" />
<div class="input-group-append">
<button type="submit" class="btn btn-search btn-outline-primary" id="submit-search"><span class="glyphicon glyphicon-search"></span></button>
</div>
</div>
</form>
<?php endif ?>
</div>
@ -210,9 +251,12 @@
<?php endif ?>
</div>
<script>
var zan_link = '';
</script>
<?php if (!isset($REQUIRE_LIB['bootstrap5'])): ?>
<script type="text/javascript">
var zan_link = '';
$('#form-search-problem').submit(function(e) {
e.preventDefault();

View File

@ -6,7 +6,7 @@
</div>
<?php if ($ShowPageFooter): ?>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<footer class="bg-light text-muted pt-3 pb-4" style="font-size: 0.9em">
<footer class="bg-white text-muted pt-3 pb-4 mt-4" style="font-size: 0.9em">
<div class="container d-lg-flex justify-content-lg-between">
<p>
&copy; <?= date('Y') ?>

View File

@ -237,7 +237,7 @@
</script>
</head>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<body class="d-flex flex-column min-vh-100">
<body class="d-flex flex-column min-vh-100 bg-light">
<?php else: ?>
<body>
<?php endif ?>

View File

@ -1,7 +1,48 @@
.uoj-username {
/* S2OJ Bootstrap 5 Theme */
body {
overflow-y: scroll;
}
.uoj-username,
.uoj-score {
font-weight: 800;
text-decoration: none;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji',
'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
}
.form-group {
margin-bottom: 1rem;
}
.form-inline .form-control {
display: inline-block;
width: auto;
vertical-align: middle;
}
.form-row {
display: flex;
flex-wrap: wrap;
margin-right: -5px;
margin-left: -5px;
}
.form-row > .col {
padding-left: 5px;
padding-right: 5px;
}
label {
margin-bottom: 0.5rem;
}
.float-right {
float: right;
}
.uoj-submissions-table > tbody > tr:last-child {
border-bottom-color: transparent;
}