chore(web): remove show-text option of click-zan block

This commit is contained in:
Baoshuo Ren 2022-11-09 21:37:37 +08:00
parent 5ce6490efb
commit 3c4cc702c3
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
13 changed files with 18 additions and 31 deletions

View File

@ -21,4 +21,4 @@ if (!ClickZans::canClickZan($_POST['id'], $_POST['type'], Auth::user())) {
die('<div class="text-danger">no permission</div>');
}
die(ClickZans::click($_POST['id'], $_POST['type'], Auth::user(), $_POST['delta'], $_POST['show-text'] !== 'false'));
die(ClickZans::click($_POST['id'], $_POST['type'], Auth::user(), $_POST['delta']));

View File

@ -379,7 +379,7 @@ if (UOJContest::cur()) {
<?php endif ?>
</ul>
<div class="card-footer bg-transparent">
评价:<?= ClickZans::getBlock('P', $problem['id'], $problem['zan']) ?>
评价:<?= UOJProblem::cur()->getZanBlock() ?>
</div>
</div>

View File

@ -59,7 +59,7 @@ if ($_POST['problem_data_file_submit'] == 'submit') {
if ($zip->open($up_filename) === TRUE) {
$zip->extractTo("/var/uoj_data/upload/{$problem['id']}");
$zip->close();
exec("cd /var/uoj_data/upload/{$problem['id']}; if [ -z "`find . -maxdepth 1 -type f`" ]; then for sub_dir in `find -maxdepth 1 -type d ! -name .`; do mv -f \$sub_dir/* . && rm -rf \$sub_dir; done; fi");
exec("cd /var/uoj_data/upload/{$problem['id']}; if [ -z \"`find . -maxdepth 1 -type f`\" ]; then for sub_dir in `find -maxdepth 1 -type d ! -name .`; do mv -f \$sub_dir/* . && rm -rf \$sub_dir; done; fi");
echo "<script>alert('上传成功!')</script>";
} else {
$errmsg = "解压失败!";
@ -749,7 +749,7 @@ $info_form->runAtServer();
</li>
</ul>
<div class="card-footer bg-transparent">
评价:<?= ClickZans::getBlock('P', $problem['id'], $problem['zan']) ?>
评价:<?= UOJProblem::cur()->getZanBlock() ?>
</div>
</div>

View File

@ -159,7 +159,7 @@ if (isSuperUser($myUser)) {
</li>
</ul>
<div class="card-footer bg-transparent">
评价:<?= ClickZans::getBlock('P', UOJProblem::info('id'), UOJProblem::info('zan')) ?>
评价:<?= UOJProblem::cur()->getZanBlock() ?>
</div>
</div>

View File

@ -239,7 +239,7 @@ $pag = new Paginator($pag_config);
<?php endif ?>
</ul>
<div class="card-footer bg-transparent">
评价:<?= ClickZans::getBlock('P', UOJProblem::info('id'), UOJProblem::info('zan')) ?>
评价:<?= UOJProblem::cur()->getZanBlock() ?>
</div>
</div>

View File

@ -143,7 +143,7 @@ $problem_editor->runAtServer();
</li>
</ul>
<div class="card-footer bg-transparent">
评价:<?= ClickZans::getBlock('P', UOJProblem::info('id'), UOJProblem::info('zan')) ?>
评价:<?= UOJProblem::cur()->getZanBlock() ?>
</div>
</div>

View File

@ -315,7 +315,7 @@ $submissions_sort_by_choice = !isset($_COOKIE['submissions-sort-by-code-length']
<?php endif ?>
</ul>
<div class="card-footer bg-transparent">
评价:<?= ClickZans::getBlock('P', $problem['id'], $problem['zan']) ?>
评价:<?= UOJProblem::cur()->getZanBlock() ?>
</div>
</div>

View File

@ -64,7 +64,7 @@ $all_tags = DB::selectAll([
<tr>
<th>标题</th>
<th style="width: 20%">发表时间</th>
<th class="text-center" style="width: 100px">评价</th>
<th class="text-center" style="width: 50px">评价</th>
</tr>
</thead>
<tbody>
@ -85,7 +85,7 @@ $all_tags = DB::selectAll([
<?php endforeach ?>
</td>
<td><?= $blog->info['post_time'] ?></td>
<td><?= ClickZans::getBlock('B', $blog->info['id'], $blog->info['zan'], null, false) ?></td>
<td><?= ClickZans::getCntBlock($blog->info['zan']) ?></td>
</tr>
<?php endforeach ?>
</tbody>

View File

@ -42,7 +42,7 @@ class ClickZans {
return $row['val'];
}
public static function click($id, $type, $user, $delta, $show_text = true) {
public static function click($id, $type, $user, $delta) {
if (!DB::$in_transaction) {
return DB::transaction(fn() => ClickZans::click($id, $type, $user, $delta));
}
@ -97,14 +97,14 @@ class ClickZans {
$cnt = $row['zan'];
}
return ClickZans::getBlock($type, $id, $cnt, $cur, $show_text);
return ClickZans::getBlock($type, $id, $cnt, $cur);
}
public static function getBlock($type, $id, $cnt, $val = null, $show_text = true) {
public static function getBlock($type, $id, $cnt, $val = null) {
if ($val === null) {
$val = ClickZans::query($id, $type, Auth::user());
}
return '<div class="uoj-click-zan-block" data-id="'.$id.'" data-type="'.$type.'" data-val="'.$val.'" data-cnt="'.$cnt.'" data-show-text="'.$show_text.'"></div>';
return '<div class="uoj-click-zan-block" data-id="'.$id.'" data-type="'.$type.'" data-val="'.$val.'" data-cnt="'.$cnt.'"></div>';
}
public static function getCntBlock($cnt) {

View File

@ -107,8 +107,8 @@ class UOJProblem {
return false;
}
public function getZanBlock($show_text = true) {
return ClickZans::getBlock('P', $this->info['id'], $this->info['zan'], null, $show_text);
public function getZanBlock() {
return ClickZans::getBlock('P', $this->info['id'], $this->info['zan']);
}
public function getSubmissionRequirement() {

View File

@ -113,11 +113,6 @@ h6,
font-size: 0.9em;
}
.uoj-click-zan-block[data-show-text="1"] {
min-width: 140px;
text-align: left;
}
.uoj-click-zan-up,
.uoj-click-zan-down,
.uoj-click-zan-cnt {

View File

@ -347,11 +347,6 @@ pre {
font-size: 0.9em;
}
.uoj-click-zan-block[data-show-text] {
min-width: 140px;
text-align: left;
}
.uoj-click-zan-up, .uoj-click-zan-down, .uoj-click-zan-cnt {
margin-left: 5px;
margin-right: 5px;

View File

@ -263,13 +263,11 @@ $.fn.uoj_blog_tag = function() {
// click zan
function click_zan(zan_id, zan_type, zan_delta, node) {
var loading_node = $('<div class="uoj-click-zan-block text-muted">loading...</div>');
var show_text = Boolean($(node).data('show-text'));
$(node).replaceWith(loading_node);
$.post(zan_link + '/click-zan', {
id : zan_id,
delta : zan_delta,
type : zan_type,
'show-text': show_text,
}, function(ret) {
$(loading_node).replaceWith($(ret).click_zan_block());
}).fail(function() {
@ -283,7 +281,6 @@ $.fn.click_zan_block = function() {
var type = $(this).data('type');
var val = parseInt($(this).data('val'));
var cnt = parseInt($(this).data('cnt'));
var show_text = Boolean($(this).data('show-text'));
if (isNaN(cnt)) {
return;
}
@ -315,11 +312,11 @@ $.fn.click_zan_block = function() {
}
var node = this;
var up_node = $('<a href="#" class="uoj-click-zan-up">'+up_icon_html+(show_text ? uojLocale('click-zan::good') : '')+'</a>').click(function(e) {
var up_node = $('<a href="#" class="uoj-click-zan-up">'+up_icon_html+uojLocale('click-zan::good')+'</a>').click(function(e) {
e.preventDefault();
click_zan(id, type, 1, node);
}).addClass(isBootstrap5Page ? 'text-decoration-none' : '');
var down_node = $('<a href="#" class="uoj-click-zan-down">'+down_icon_html+(show_text ? uojLocale('click-zan::bad') : '')+'</a>').click(function(e) {
var down_node = $('<a href="#" class="uoj-click-zan-down">'+down_icon_html+uojLocale('click-zan::bad')+'</a>').click(function(e) {
e.preventDefault();
click_zan(id, type, -1, node);
}).addClass(isBootstrap5Page ? 'text-decoration-none' : '');