Unverified Commit 9ebdabae authored by ir1d's avatar ir1d Committed by GitHub
Browse files

Merge pull request #257 from frank-xjh/master

Fix page-time
parents ae5fa60a b6a04097
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -50,8 +50,9 @@ if (cur) {
    pos -= comments.textContent.length;
  }
  var textLength = 0;
  if (pos < 0) textLength = (document.getElementsByClassName('md-content__inner')[0].textContent.slice(0, pos).replace(/\s/g, '').length);
  else textLength = (document.getElementsByClassName('md-content__inner')[0].textContent.replace(/\s/g, '').length);
  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>`;
}