summaryrefslogtreecommitdiffstats
path: root/assets/js
diff options
context:
space:
mode:
authoramzrk22020-06-03 13:58:49 +0800
committeramzrk22020-06-03 13:58:49 +0800
commit3df71601ae866aff9c2ae060ed1ac7407807fcc4 (patch)
treead34004b865f43aecf43d111b5586f592a1e05ba /assets/js
parente6afd04368f56af57b77f71be4dda5a4d9279a64 (diff)
downloadhugo-theme-fuji-3df71601ae866aff9c2ae060ed1ac7407807fcc4.tar.gz
hugo-theme-fuji-3df71601ae866aff9c2ae060ed1ac7407807fcc4.tar.bz2
hugo-theme-fuji-3df71601ae866aff9c2ae060ed1ac7407807fcc4.zip
New comment area & opt out of font awesome
Diffstat (limited to 'assets/js')
-rw-r--r--assets/js/fuji.js46
1 files changed, 14 insertions, 32 deletions
diff --git a/assets/js/fuji.js b/assets/js/fuji.js
index eda8723..4fbd651 100644
--- a/assets/js/fuji.js
+++ b/assets/js/fuji.js
@@ -51,6 +51,9 @@ function updateUtterancesTheme(utterancesFrame) {
}
}
+// load comment
+document.querySelector('span.post-comment-notloaded').addEventListener('click', loadComment);
+
// remove empty ul in toc if article only have ## and ###
if (document.querySelectorAll('.sidebar-toc ul ul').length > 0) {
document.querySelectorAll('.sidebar-toc ul ul').forEach((value, key, parent) => {
@@ -75,31 +78,6 @@ if (getNowTheme() === 'dark') {
});
}
-// if in post page and using utterances
-// add utterances comment loading indicator
-if (document.querySelector('.post-loading')) {
- var commentStatus; // utterence status
- var commentLoadingTime = 0; // loading time passed
- var commentCheckInterval = self.setInterval(checkUtterances, 500);
-
- function checkUtterances() {
- if (document.querySelector('.post-comment .utterances')) {
- commentStatus = document.querySelector('.post-comment .utterances').getAttribute('style');
- }
- if (commentStatus) {
- clearInterval(commentCheckInterval);
- updateUtterancesTheme(document.querySelector('.post-comment iframe'));
- document.querySelector('.post-loading').setAttribute('style', 'display: none;');
- } else {
- if (++commentLoadingTime > 20) {
- clearInterval(commentCheckInterval);
- document.querySelector('.post-comment').setAttribute('style', 'display: none;');
- document.querySelector('.post-loading i').className = 'far fa-times-circle';
- }
- }
- }
-}
-
// theme switch button
document.querySelector('.btn .btn-toggle-mode').addEventListener('click', () => {
let nowTheme = getNowTheme();
@@ -126,12 +104,16 @@ document.querySelector('.btn .btn-toggle-mode').addEventListener('click', () =>
updateMeidumTheme(mediumInst);
// switch comment area theme
// only works after comment area are initialized
- if (document.querySelector('.post-loading') && commentStatus) {
- updateUtterancesTheme(document.querySelector('.post-comment iframe'));
- }
- if (document.querySelector('#disqus_thread') && typeof DISQUS !== 'undefined') {
- DISQUS.reset({
- reload: true,
- });
+ let commentArea = document.querySelector('.post-comment');
+ let commentStatus = document.querySelector('span.post-comment-notloaded').getAttribute('style');
+ if (commentStatus) {
+ if (commentArea.getAttribute('data-comment') === 'utterances') {
+ updateUtterancesTheme(document.querySelector('.post-comment iframe'));
+ }
+ if (commentArea.getAttribute('data-comment') === 'disqus') {
+ DISQUS.reset({
+ reload: true,
+ });
+ }
}
});