refactor(web/hack): drop bootstrap4

This commit is contained in:
Baoshuo Ren 2022-10-21 06:58:32 +08:00
parent 6277a0c8c3
commit a06707335f
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
2 changed files with 23 additions and 77 deletions

View File

@ -1,5 +1,7 @@
<?php <?php
requirePHPLib('form'); requirePHPLib('form');
requireLib('bootstrap5');
requireLib('hljs');
if (!Auth::check() && UOJConfig::$data['switch']['force-login']) { if (!Auth::check() && UOJConfig::$data['switch']['force-login']) {
redirectToLogin(); redirectToLogin();
@ -13,10 +15,6 @@
become404Page(); become404Page();
} }
if (!isset($_COOKIE['bootstrap4'])) {
$REQUIRE_LIB['bootstrap5'] = '';
}
$submission = querySubmission($hack['submission_id']); $submission = querySubmission($hack['submission_id']);
$problem = queryProblemBrief($submission['problem_id']); $problem = queryProblemBrief($submission['problem_id']);
$problem_extra_config = getProblemExtraConfig($problem); $problem_extra_config = getProblemExtraConfig($problem);
@ -66,13 +64,6 @@
} }
} }
?> ?>
<?php
if (isset($REQUIRE_LIB['bootstrap5'])) {
$REQUIRE_LIB['hljs'] = '';
} else {
$REQUIRE_LIB['shjs'] = '';
}
?>
<?php echoUOJPageHeader(UOJLocale::get('problems::hack').' #'.$hack['id']) ?> <?php echoUOJPageHeader(UOJLocale::get('problems::hack').' #'.$hack['id']) ?>
<h1 class="h3"> <h1 class="h3">
@ -85,18 +76,12 @@
<div class="card-header bg-info"> <div class="card-header bg-info">
<h4 class="card-title"><?= UOJLocale::get('details') ?></h4> <h4 class="card-title"><?= UOJLocale::get('details') ?></h4>
</div> </div>
<?php if (!isset($REQUIRE_LIB['bootstrap5'])): ?> <?php echoJudgementDetails($hack['details'], $styler, 'details') ?>
<div class="card-body"> <?php if ($should_show_details_to_me): ?>
<?php endif ?> <?php if ($styler->fade_all_details): ?>
<?php echoJudgementDetails($hack['details'], $styler, 'details') ?> <hr />
<?php if ($should_show_details_to_me): ?> <?php echoHackDetails($hack['details'], 'final_details') ?>
<?php if ($styler->fade_all_details): ?>
<hr />
<?php echoHackDetails($hack['details'], 'final_details') ?>
<?php endif ?>
<?php endif ?> <?php endif ?>
<?php if (!isset($REQUIRE_LIB['bootstrap5'])): ?>
</div>
<?php endif ?> <?php endif ?>
</div> </div>
<?php endif ?> <?php endif ?>

View File

@ -1,4 +1,6 @@
<?php <?php
requireLib('bootstrap5');
if (!Auth::check() && UOJConfig::$data['switch']['force-login']) { if (!Auth::check() && UOJConfig::$data['switch']['force-login']) {
redirectToLogin(); redirectToLogin();
} }
@ -7,10 +9,6 @@
become403Page(); become403Page();
} }
if (!isset($_COOKIE['bootstrap4'])) {
$REQUIRE_LIB['bootstrap5'] = '';
}
$conds = array(); $conds = array();
$q_problem_id = isset($_GET['problem_id']) && validateUInt($_GET['problem_id']) ? $_GET['problem_id'] : null; $q_problem_id = isset($_GET['problem_id']) && validateUInt($_GET['problem_id']) ? $_GET['problem_id'] : null;
@ -61,60 +59,31 @@
<div class="d-none d-sm-block"> <div class="d-none d-sm-block">
<?php if (Auth::check()): ?> <?php if (Auth::check()): ?>
<div class="float-right <div class="float-right btn-group">
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
btn-group
<?php endif ?>">
<a href="/hacks?hacker=<?= Auth::id() ?>" class="btn btn-success btn-sm"><?= UOJLocale::get('problems::hacks by me') ?></a> <a href="/hacks?hacker=<?= Auth::id() ?>" class="btn btn-success btn-sm"><?= UOJLocale::get('problems::hacks by me') ?></a>
<a href="/hacks?owner=<?= Auth::id() ?>" class="btn btn-danger btn-sm"><?= UOJLocale::get('problems::hacks to me') ?></a> <a href="/hacks?owner=<?= Auth::id() ?>" class="btn btn-danger btn-sm"><?= UOJLocale::get('problems::hacks to me') ?></a>
</div> </div>
<?php endif ?> <?php endif ?>
<form id="form-search" class="form-inline" role="form"> <form id="form-search" class="form-inline" role="form">
<div id="form-group-submission_id" class="form-group <div id="form-group-submission_id" class="form-group d-inline-block">
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
d-inline-block
<?php endif ?>
">
<label for="input-submission_id" class="control-label"><?= UOJLocale::get('problems::submission id') ?>:</label> <label for="input-submission_id" class="control-label"><?= UOJLocale::get('problems::submission id') ?>:</label>
<input type="text" class="form-control input-sm" name="submission_id" id="input-submission_id" value="<?= $q_submission_id ?>" maxlength="6" style="width:5em" /> <input type="text" class="form-control input-sm" name="submission_id" id="input-submission_id" value="<?= $q_submission_id ?>" maxlength="6" style="width:5em" />
</div> </div>
<div id="form-group-problem_id" class="form-group <div id="form-group-problem_id" class="form-group d-inline-block">
<?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> <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" /> <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>
<div id="form-group-hacker" class="form-group <div id="form-group-hacker" class="form-group d-inline-block">
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
d-inline-block
<?php endif ?>
">
<label for="input-hacker" class="control-label"><?= UOJLocale::get('problems::hacker') ?>:</label> <label for="input-hacker" class="control-label"><?= UOJLocale::get('problems::hacker') ?>:</label>
<input type="text" class="form-control input-sm" name="hacker" id="input-hacker" value="<?= $q_hacker ?>" maxlength="100" style="width:10em" /> <input type="text" class="form-control input-sm" name="hacker" id="input-hacker" value="<?= $q_hacker ?>" maxlength="100" style="width:10em" />
</div> </div>
<div id="form-group-owner" class="form-group <div id="form-group-owner" class="form-group d-inline-block">
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
d-inline-block
<?php endif ?>
">
<label for="input-owner" class="control-label"><?= UOJLocale::get('problems::owner') ?>:</label> <label for="input-owner" class="control-label"><?= UOJLocale::get('problems::owner') ?>:</label>
<input type="text" class="form-control input-sm" name="owner" id="input-owner" value="<?= $q_owner ?>" maxlength="100" style="width:10em" /> <input type="text" class="form-control input-sm" name="owner" id="input-owner" value="<?= $q_owner ?>" maxlength="100" style="width:10em" />
</div> </div>
<div id="form-group-status" class="form-group <div id="form-group-status" class="form-group d-inline-block">
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
d-inline-block
<?php endif ?>
">
<label for="input-status" class="control-label"><?= UOJLocale::get('problems::result') ?>:</label> <label for="input-status" class="control-label"><?= UOJLocale::get('problems::result') ?>:</label>
<select class="input-sm <select class="input-sm form-select" id="input-status" name="status">
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
form-select
<?php else: ?>
form-control
<?php endif ?>
" id="input-status" name="status">
<option value=""<?= $selected_all?>>All</option> <option value=""<?= $selected_all?>>All</option>
<option value="1"<?= $selected_succ ?>>Success!</option> <option value="1"<?= $selected_succ ?>>Success!</option>
<option value="2"<?= $selected_fail ?>>Failed.</option> <option value="2"<?= $selected_fail ?>>Failed.</option>
@ -140,26 +109,18 @@ d-inline-block
}); });
</script> </script>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<div class="mt-3"></div> <div class="mt-3"></div>
<?php else: ?>
<div class="top-buffer-sm"></div>
<?php endif ?>
</div> </div>
<?php echoHacksList($cond, <?php echoHacksList($cond,
'order by id desc', 'order by id desc',
array( [
'judge_time_hidden' => '', 'judge_time_hidden' => '',
'table_config' => (isset($REQUIRE_LIB['bootstrap5']) 'table_config' => [
? array( 'div_classes' => ['card', 'mb-3', 'table-responsive'],
'div_classes' => array('card', 'mb-3', 'table-responsive'), 'table_classes' => ['table', 'mb-0', 'uoj-table', 'text-center'],
'table_classes' => array('table', 'mb-0', 'uoj-table', 'text-center') ],
) ],
: array()
),
),
$myUser); $myUser);
?> ?>