chore(web/problem_set): drop bootstrap4

This commit is contained in:
Baoshuo Ren 2022-10-10 08:18:55 +08:00
parent 63bce3f253
commit 7e8db47f93
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

View File

@ -11,9 +11,7 @@
become403Page(); become403Page();
} }
if (!isset($_COOKIE['bootstrap4'])) { $REQUIRE_LIB['bootstrap5'] = '';
$REQUIRE_LIB['bootstrap5'] = '';
}
if (isSuperUser($myUser) || isProblemManager($myUser) || isProblemUploader($myUser)) { if (isSuperUser($myUser) || isProblemManager($myUser) || isProblemUploader($myUser)) {
$new_problem_form = new UOJForm('new_problem'); $new_problem_form = new UOJForm('new_problem');
@ -44,16 +42,9 @@
echo '<td>'; echo '<td>';
} }
echo '#', $problem['id'], '</td>'; echo '#', $problem['id'], '</td>';
if (isset($REQUIRE_LIB['bootstrap5'])) {
echo '<td class="text-start">'; echo '<td class="text-start">';
} else { echo '<a class="text-decoration-none" href="/problem/', $problem['id'], '">', $problem['title'], '</a>';
echo '<td class="text-left">';
}
echo '<a ';
if (isset($REQUIRE_LIB['bootstrap5'])) {
echo ' class="text-decoration-none" ';
}
echo ' href="/problem/', $problem['id'], '">', $problem['title'], '</a>';
if ($problem['uploader'] == $myUser['username']) { if ($problem['uploader'] == $myUser['username']) {
echo ' <span class="badge text-white bg-info">', UOJLocale::get('problems::my problem') ,'</span> '; echo ' <span class="badge text-white bg-info">', UOJLocale::get('problems::my problem') ,'</span> ';
@ -65,27 +56,18 @@
if (isset($_COOKIE['show_tags_mode'])) { if (isset($_COOKIE['show_tags_mode'])) {
foreach (queryProblemTags($problem['id']) as $tag) { foreach (queryProblemTags($problem['id']) as $tag) {
if (isset($REQUIRE_LIB['bootstrap5'])) { echo ' <a class="uoj-problem-tag my-1">';
echo ' <a class="uoj-problem-tag my-1">'; echo '<span class="badge bg-secondary">';
echo '<span class="badge bg-secondary">';
} else {
echo ' <a class="uoj-problem-tag">';
echo '<span class="badge badge-pill badge-secondary">';
}
echo HTML::escape($tag), '</span>'; echo HTML::escape($tag), '</span>';
echo '</a> '; echo '</a> ';
} }
} }
echo '</td>'; echo '</td>';
if (isset($_COOKIE['show_submit_mode'])) { if (isset($_COOKIE['show_submit_mode'])) {
$a_class = '';
if (isset($REQUIRE_LIB['bootstrap5'])) {
$a_class .= ' text-decoration-none ';
}
$perc = $problem['submit_num'] > 0 ? round(100 * $problem['ac_num'] / $problem['submit_num']) : 0; $perc = $problem['submit_num'] > 0 ? round(100 * $problem['ac_num'] / $problem['submit_num']) : 0;
echo <<<EOD echo <<<EOD
<td><a class="{$a_class}" href="/submissions?problem_id={$problem['id']}&min_score=100&max_score=100">&times;{$problem['ac_num']}</a></td> <td><a class="text-decoration-none" href="/submissions?problem_id={$problem['id']}&min_score=100&max_score=100">&times;{$problem['ac_num']}</a></td>
<td><a class="{$a_class}" href="/submissions?problem_id={$problem['id']}">&times;{$problem['submit_num']}</a></td> <td><a class="text-decoration-none" href="/submissions?problem_id={$problem['id']}">&times;{$problem['submit_num']}</a></td>
<td> <td>
<div class="progress bot-buffer-no"> <div class="progress bot-buffer-no">
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="$perc" aria-valuemin="0" aria-valuemax="100" style="width: $perc%; min-width: 20px;">{$perc}%</div> <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="$perc" aria-valuemin="0" aria-valuemax="100" style="width: $perc%; min-width: 20px;">{$perc}%</div>
@ -134,9 +116,9 @@ EOD;
$header .= '<th class="text-center" style="width:5em;">ID</th>'; $header .= '<th class="text-center" style="width:5em;">ID</th>';
$header .= '<th>'.UOJLocale::get('problems::problem').'</th>'; $header .= '<th>'.UOJLocale::get('problems::problem').'</th>';
if (isset($_COOKIE['show_submit_mode'])) { if (isset($_COOKIE['show_submit_mode'])) {
$header .= '<th class="text-center" style="width:' . (isset($REQUIRE_LIB['bootstrap5']) ? '4' : '5') . 'em;">'.UOJLocale::get('problems::ac').'</th>'; $header .= '<th class="text-center" style="width:4em;">'.UOJLocale::get('problems::ac').'</th>';
$header .= '<th class="text-center" style="width:' . (isset($REQUIRE_LIB['bootstrap5']) ? '4' : '5') . 'em;">'.UOJLocale::get('problems::submit').'</th>'; $header .= '<th class="text-center" style="width:4em;">'.UOJLocale::get('problems::submit').'</th>';
$header .= '<th class="text-center" style="width:' . (isset($REQUIRE_LIB['bootstrap5']) ? '125' : '150') . 'px;">'.UOJLocale::get('problems::ac ratio').'</th>'; $header .= '<th class="text-center" style="width:125px;">'.UOJLocale::get('problems::ac ratio').'</th>';
} }
if (isset($_COOKIE['show_difficulty'])) { if (isset($_COOKIE['show_difficulty'])) {
$header .= '<th class="text-center" style="width:3em;">'.UOJLocale::get('problems::difficulty').'</th>'; $header .= '<th class="text-center" style="width:3em;">'.UOJLocale::get('problems::difficulty').'</th>';
@ -162,130 +144,75 @@ EOD;
$pag_config['tail'] = "order by id asc"; $pag_config['tail'] = "order by id asc";
$pag = new Paginator($pag_config); $pag = new Paginator($pag_config);
$div_classes = isset($REQUIRE_LIB['bootstrap5']) $div_classes = ['card', 'my-3', 'table-responsive'];
? array('card', 'my-3', 'table-responsive') $table_classes = ['table', 'uoj-table', 'mb-0'];
: array('table-responsive');
$table_classes = isset($REQUIRE_LIB['bootstrap5'])
? array('table', 'uoj-table', 'mb-0')
: array('table', 'table-bordered', 'table-hover', 'table-striped');
?> ?>
<?php echoUOJPageHeader(UOJLocale::get('problems')) ?> <?php echoUOJPageHeader(UOJLocale::get('problems')) ?>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<div class="row"> <div class="row">
<!-- left col -->
<div class="col-lg-9"> <div class="col-lg-9">
<!-- title -->
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<?php endif ?>
<h1 class="h2"> <h1 class="h2">
<?= UOJLocale::get('problems') ?> <?= UOJLocale::get('problems') ?>
</h1> </h1>
<?php if (isSuperUser($myUser) || isProblemManager($myUser) || isProblemUploader($myUser)): ?> <?php if (isSuperUser($myUser) || isProblemManager($myUser) || isProblemUploader($myUser)): ?>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<div class="text-end"> <div class="text-end">
<?php endif ?>
<?php $new_problem_form->printHTML(); ?> <?php $new_problem_form->printHTML(); ?>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
</div> </div>
<?php endif ?>
<?php endif ?> <?php endif ?>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
</div> </div>
<?php endif ?> <!-- end title -->
<?php if (!isset($REQUIRE_LIB['bootstrap5'])): ?>
<div class="top-buffer-sm"></div>
<?php endif ?>
<div class="row"> <div class="row">
<div class="col-sm-4 <div class="col-sm-4 col-12">
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
col-12
<?php endif ?>
">
<?= HTML::tablist($tabs_info, $cur_tab, 'nav-pills') ?> <?= HTML::tablist($tabs_info, $cur_tab, 'nav-pills') ?>
</div> </div>
<div class=" <div class="text-end p-2 col-12 col-sm-8">
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
text-end p-2 col-12 col-sm-8
<?php else: ?>
text-right checkbox order-sm-5 col-sm-4
<?php endif ?>
">
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<div class="form-check d-inline-block me-2"> <div class="form-check d-inline-block me-2">
<?php else: ?> <input
<label class="checkbox-inline" for="input-show_tags_mode"> type="checkbox" id="input-show_tags_mode"
<?php endif ?> class="form-check-input"
<input type="checkbox" id="input-show_tags_mode" <?= isset($_COOKIE['show_tags_mode']) ? 'checked="checked" ': ''?>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?> />
class="form-check-input" <label class="form-check-label" for="input-show_tags_mode">
<?php endif ?> <?= UOJLocale::get('problems::show tags') ?>
<?= isset($_COOKIE['show_tags_mode']) ? 'checked="checked" ': ''?> </label>
/> </div>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?> <div class="form-check d-inline-block">
<label class="form-check-label" for="input-show_tags_mode"> <input
<?php endif ?> type="checkbox" id="input-show_submit_mode"
<?= UOJLocale::get('problems::show tags') ?>
</label>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
</div>
<?php endif ?>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<div class="form-check d-inline-block">
<?php else: ?>
<label class="checkbox-inline" for="input-show_submit_mode">
<?php endif ?>
<input type="checkbox" id="input-show_submit_mode"
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
class="form-check-input" class="form-check-input"
<?php endif ?>
<?= isset($_COOKIE['show_submit_mode']) ? 'checked="checked" ': ''?> <?= isset($_COOKIE['show_submit_mode']) ? 'checked="checked" ': ''?>
/> />
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<label class="form-check-label" for="input-show_submit_mode"> <label class="form-check-label" for="input-show_submit_mode">
<?php endif ?> <?= UOJLocale::get('problems::show statistics') ?>
<?= UOJLocale::get('problems::show statistics') ?> </label>
</label>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
</div> </div>
<?php endif ?>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<div class="form-check d-inline-block"> <div class="form-check d-inline-block">
<?php else: ?> <input
<label class="checkbox-inline" for="input-show_difficulty"> type="checkbox" id="input-show_difficulty"
<?php endif ?>
<input type="checkbox" id="input-show_difficulty"
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
class="form-check-input" class="form-check-input"
<?php endif ?> <?= isset($_COOKIE['show_difficulty']) ? 'checked="checked" ': ''?>
<?= isset($_COOKIE['show_difficulty']) ? 'checked="checked" ': ''?> /> />
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<label class="form-check-label" for="input-show_difficulty"> <label class="form-check-label" for="input-show_difficulty">
<?php endif ?> <?= UOJLocale::get('problems::show difficulty') ?>
<?= UOJLocale::get('problems::show difficulty') ?> </label>
</label>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
</div> </div>
<?php endif ?>
</div> </div>
<?php if (!isset($REQUIRE_LIB['bootstrap5'])): ?>
<div class="col-sm-4 order-sm-3">
<?= $pag->pagination(); ?>
</div>
<?php endif ?>
</div> </div>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<div class="text-center"> <div class="text-center">
<?= $pag->pagination(); ?> <?= $pag->pagination() ?>
</div> </div>
<?php endif ?>
<script type="text/javascript"> <script type="text/javascript">
$('#input-show_tags_mode').click(function() { $('#input-show_tags_mode').click(function() {
@ -318,7 +245,6 @@ $('#input-show_difficulty').click(function() {
<thead><?= $header ?></thead> <thead><?= $header ?></thead>
<tbody> <tbody>
<?php <?php
foreach ($pag->get() as $idx => $row) { foreach ($pag->get() as $idx => $row) {
echoProblem($row); echoProblem($row);
echo "\n"; echo "\n";
@ -330,13 +256,18 @@ $('#input-show_difficulty').click(function() {
</tbody> </tbody>
</table> </table>
</div> </div>
<?= $pag->pagination() ?>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?> <div class="text-center">
<?= $pag->pagination() ?>
</div> </div>
</div>
<!-- end left col -->
<!-- right col -->
<aside class="col mt-3 mt-lg-0"> <aside class="col mt-3 mt-lg-0">
<!-- search bar -->
<form method="get"> <form method="get">
<div class="input-group mb-3"> <div class="input-group mb-3">
<input id="search-input" name="search" type="text" class="form-control" placeholder="搜索"> <input id="search-input" name="search" type="text" class="form-control" placeholder="搜索">
@ -347,12 +278,10 @@ $('#input-show_difficulty').click(function() {
</form> </form>
<script>$('#search-input').val(new URLSearchParams(location.search).get('search'));</script> <script>$('#search-input').val(new URLSearchParams(location.search).get('search'));</script>
<?php <!-- sidebar -->
uojIncludeView('sidebar', array()); <?php uojIncludeView('sidebar', []) ?>
?>
</aside> </aside>
</div> </div>
<?php endif ?>
<?php echoUOJPageFooter() ?> <?php echoUOJPageFooter() ?>