Commit a6e502fd authored by frank-xjh's avatar frank-xjh
Browse files

fix page-time when there is no word

parent c4cb0180
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -53,5 +53,6 @@ if (cur) {
  if (pos < 0) textLength = (document.getElementsByClassName('md-content__inner')[0].textContent.slice(0, pos).replace(/\s/g, '').length - document.getElementsByTagName('h1')[0].textContent.replace(/\s/g, '').length - document.getElementsByClassName('page-copyright')[0].textContent.replace(/\s/g, '').length - 4);
  else textLength = (document.getElementsByClassName('md-content__inner')[0].textContent.replace(/\s/g, '').length - document.getElementsByTagName('h1')[0].textContent.replace(/\s/g, '').length - document.getElementsByClassName('page-copyright')[0].textContent.replace(/\s/g, '').length - 4);
  var ti = Math.ceil(textLength / 400);
  cur.innerHTML = `<p>本页面共 ${textLength} 字,预计阅读需要 ${ti} 分钟</p>`;
  if (textLength > 0) cur.innerHTML = `<p>本页面共 ${textLength} 字,预计阅读需要 ${ti} 分钟</p>`;
  else cur.innerHTML = `<p>本页面还在建设中,欢迎参与完善!</p>`;
}