summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBigCoke233 <hi@guhub.cn>2020-04-01 09:51:27 +0800
committerBigCoke233 <hi@guhub.cn>2020-04-01 09:51:27 +0800
commit553f0c82753bcf548782b5b3a2656d8590faff78 (patch)
tree6bd7232f5e9b48c45fa9310c7eb3dc3b014ac01c
parent8c8810f08322c722ff4e319bfcabca93ef92cc86 (diff)
:tea: Perf: 优化文章字数统计的显示
-rw-r--r--assets/js/miracles.min.js2
-rw-r--r--post.php4
2 files changed, 5 insertions, 1 deletions
diff --git a/assets/js/miracles.min.js b/assets/js/miracles.min.js
index 0b45f62..ca56a58 100644
--- a/assets/js/miracles.min.js
+++ b/assets/js/miracles.min.js
@@ -385,6 +385,7 @@ eval(function(d,e,a,c,b,f){b=function(a){return(a<e?"":b(parseInt(a/e)))+(35<(a%
* getWordsNum
*/
function getWordsNum() {
+ if($("#readTip").length>0){
if ($("#post-content"))
str = $("#post-content").text();
else return false;
@@ -396,6 +397,7 @@ function getWordsNum() {
sLen = str.length;
time = Math.ceil(sLen / 450);
$("#readTip").html("本文约 " + sLen + "字 阅读大概需要 " + time + " 分钟");
+ }
}
/**
diff --git a/post.php b/post.php
index eab9e82..e9a2f21 100644
--- a/post.php
+++ b/post.php
@@ -13,13 +13,15 @@ $this->need('includes/header.php');
</div></div>
</div>
<?php endif; ?>
- <div class="tip blue" id="reading-time-alert"<?php if($this->options->ifShowRTA==0): ?> style="display:none!important"<?php endif;?>>
+ <?php if($this->options->ifShowRTA==0): ?>
+ <div class="tip blue" id="reading-time-alert">
<div class="container-fluid">
<div class="row">
<div class="col-1 tip-icon"><i class="iconfont icon-info"></i></div>
<div class="col-11 tip-content" id="readTip"></div>
</div></div>
</div>
+ <?php endif;?>
<?php $this->content(); ?>
</div>
<div class="post-qr" id="post-qr">