summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-08-29 15:05:50 +0800
committerEltrac <hi@guhub.cn>2025-08-29 15:05:50 +0800
commit282d57b388cb5bdd67ba34bb1789fa0629d69b78 (patch)
tree31667c22411f4527ac4b5272c3c24ce427eb0eaf
parent96153c88d957102234c0ef4ad794dbe62d7ca4ef (diff)
style: clear comment on action menu scripts
-rw-r--r--layouts/_partials/scripts/action-menu-js.html42
1 files changed, 33 insertions, 9 deletions
diff --git a/layouts/_partials/scripts/action-menu-js.html b/layouts/_partials/scripts/action-menu-js.html
index 309043c8..e2db17e7 100644
--- a/layouts/_partials/scripts/action-menu-js.html
+++ b/layouts/_partials/scripts/action-menu-js.html
@@ -1,20 +1,29 @@
{{ $pageId := . }}
<script defer>
-// 初始化所有功能
+/**
+ * =================
+ * Initialize all Action Menu features
+ * - comment toggle
+ * - comment count
+ * - like
+ * =================
+ */
+
function initializeFeatures() {
const pageId = "{{ $pageId }}";
- console.log(pageId)
if (!pageId) return;
- // 评论展开/收起功能
initializeComments();
- // 点赞功能
initializeLikes(pageId);
- // 评论数量获取
initializeCommentCount();
}
-// 评论展开/收起功能初始化
+/**
+ * =================
+ * Toggle Comment Section
+ * =================
+ */
+
function initializeComments() {
const commentsToggle = document.getElementById('comments-toggle');
const commentsSection = document.getElementById('comments-section');
@@ -28,7 +37,12 @@ function initializeComments() {
}
}
-// 评论数量功能初始化
+/**
+ * =================
+ * Fetch and set Comment Count
+ * =================
+ */
+
function initializeCommentCount() {
const commentCountEl = document.getElementById('comment-count');
if (!commentCountEl) return;
@@ -56,7 +70,12 @@ function initializeCommentCount() {
document.addEventListener('DOMContentLoaded', initializeCommentCount);
-// 点赞功能初始化
+/**
+ * =================
+ * Initialize like functionality
+ * =================
+ */
+
function initializeLikes(pageId) {
if (window.location.host !== 'www.geedea.pro') return;
@@ -129,7 +148,12 @@ function initializeLikes(pageId) {
observer.observe(document.getElementById("action-menu"));
}
-// 在 DOM 加载完成后初始化所有功能
+/**
+ * =================
+ * Load features after DOMContentLoaded
+ * =================
+ */
+
document.addEventListener('DOMContentLoaded', () => {
if ('requestIdleCallback' in window) {
requestIdleCallback(initializeFeatures);