Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

Commit

Permalink
UI | 添加友情链接随机排序开关
Browse files Browse the repository at this point in the history
Signed-off-by: paizi <[email protected]>
  • Loading branch information
paizi committed Oct 25, 2019
1 parent a1b8c17 commit 23dd20e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,19 @@ classes: {
);
$form->addInput($mdrPray);


$RandomLinks = new Typecho_Widget_Helper_Form_Element_Radio(
'RandomLinks',
array(
true => _t(''),
false => _t('')
),
ture,
_t('友情链接随机排序'),
_t('开启后友情链接将按照随机顺序排列')
);
$form->addInput($RandomLinks);

$mdrHitokoto = new Typecho_Widget_Helper_Form_Element_Radio(
'mdrHitokoto',
array(
Expand Down
4 changes: 3 additions & 1 deletion page-links.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
<?php $this->need('comments.php'); ?>
</div>
<?php $this->need('footer.php'); ?>
<?php if ($this->options->RandomLinks): ?>
<script>
var cards = $(".mdui-col");
for (var i = 0; i < cards.length; i++) {
var target1 = Math.floor(Math.random() * cards.length - 1) + 1;
var target2 = Math.floor(Math.random() * cards.length - 1) + 1;
cards.eq(target1).before(cards.eq(target2));
}
</script>
</script>
<?php endif; ?>

0 comments on commit 23dd20e

Please sign in to comment.