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('<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 ?> <?php endif ?>
</ul> </ul>
<div class="card-footer bg-transparent"> <div class="card-footer bg-transparent">
评价:<?= ClickZans::getBlock('P', $problem['id'], $problem['zan']) ?> 评价:<?= UOJProblem::cur()->getZanBlock() ?>
</div> </div>
</div> </div>

View File

@ -59,7 +59,7 @@ if ($_POST['problem_data_file_submit'] == 'submit') {
if ($zip->open($up_filename) === TRUE) { if ($zip->open($up_filename) === TRUE) {
$zip->extractTo("/var/uoj_data/upload/{$problem['id']}"); $zip->extractTo("/var/uoj_data/upload/{$problem['id']}");
$zip->close(); $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>"; echo "<script>alert('上传成功!')</script>";
} else { } else {
$errmsg = "解压失败!"; $errmsg = "解压失败!";
@ -749,7 +749,7 @@ $info_form->runAtServer();
</li> </li>
</ul> </ul>
<div class="card-footer bg-transparent"> <div class="card-footer bg-transparent">
评价:<?= ClickZans::getBlock('P', $problem['id'], $problem['zan']) ?> 评价:<?= UOJProblem::cur()->getZanBlock() ?>
</div> </div>
</div> </div>

View File

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

View File

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

View File

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

View File

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

View File

@ -64,7 +64,7 @@ $all_tags = DB::selectAll([
<tr> <tr>
<th>标题</th> <th>标题</th>
<th style="width: 20%">发表时间</th> <th style="width: 20%">发表时间</th>
<th class="text-center" style="width: 100px">评价</th> <th class="text-center" style="width: 50px">评价</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -85,7 +85,7 @@ $all_tags = DB::selectAll([
<?php endforeach ?> <?php endforeach ?>
</td> </td>
<td><?= $blog->info['post_time'] ?></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> </tr>
<?php endforeach ?> <?php endforeach ?>
</tbody> </tbody>

View File

@ -42,7 +42,7 @@ class ClickZans {
return $row['val']; 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) { if (!DB::$in_transaction) {
return DB::transaction(fn() => ClickZans::click($id, $type, $user, $delta)); return DB::transaction(fn() => ClickZans::click($id, $type, $user, $delta));
} }
@ -97,14 +97,14 @@ class ClickZans {
$cnt = $row['zan']; $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) { if ($val === null) {
$val = ClickZans::query($id, $type, Auth::user()); $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) { public static function getCntBlock($cnt) {

View File

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

View File

@ -113,11 +113,6 @@ h6,
font-size: 0.9em; 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-up,
.uoj-click-zan-down, .uoj-click-zan-down,
.uoj-click-zan-cnt { .uoj-click-zan-cnt {

View File

@ -347,11 +347,6 @@ pre {
font-size: 0.9em; 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 { .uoj-click-zan-up, .uoj-click-zan-down, .uoj-click-zan-cnt {
margin-left: 5px; margin-left: 5px;
margin-right: 5px; margin-right: 5px;

View File

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