diff --git a/argontheme.js b/argontheme.js index 9dd4feb..b0794ba 100644 --- a/argontheme.js +++ b/argontheme.js @@ -409,7 +409,7 @@ $(document).on("blur" , "#navbar_search_input_container" , function(){ }); // 监听输入变化来切换has-text类 $(document).on("input" , "#navbar_search_input" , function(){ - var container = $("#navbar_search_input_container"); + let container = $("#navbar_search_input_container"); if ($(this).val().trim() !== "") { container.addClass("has-text"); } else { @@ -602,7 +602,7 @@ function waterflowInit() { let heights = [0, 0, 0]; function getMinHeightPosition(){ let res = 0, minn = 2147483647; - for (var i = 0; i < columns; i++) { + for (let i = 0; i < columns; i++) { if (heights[i] < minn) { minn = heights[i]; res = i; @@ -663,11 +663,11 @@ if (argonConfig.waterflow_columns !== "1") { /*移动端文章列表布局切换*/ !function(){ - var mobileLayout = argonConfig.article_list_layout_mobile || "1"; - var isMobile = window.innerWidth <= 900; + let mobileLayout = argonConfig.article_list_layout_mobile || "1"; + let isMobile = window.innerWidth <= 900; function applyMobileLayout() { - var nowMobile = window.innerWidth <= 900; + let nowMobile = window.innerWidth <= 900; if (nowMobile) { $("html").addClass("mobile-layout-" + mobileLayout); } else { @@ -728,10 +728,10 @@ if (argonConfig.waterflow_columns !== "1") { $("#fabtn_go_to_comment").addClass("fabtn-hidden"); } $goToComment.on("click" , function(){ - var commentsArea = $("#comments"); - var postCommentArea = $("#post_comment"); - var wasCollapsed = commentsArea.hasClass("comments-collapsed"); - var toggleBtn = $("#comments_toggle"); + let commentsArea = $("#comments"); + let postCommentArea = $("#post_comment"); + let wasCollapsed = commentsArea.hasClass("comments-collapsed"); + let toggleBtn = $("#comments_toggle"); if (wasCollapsed && toggleBtn.length > 0) { // 折叠状态:先滚动到评论切换按钮位置,再展开 @@ -1290,7 +1290,7 @@ if (argonConfig.waterflow_columns !== "1") { }); // 准备数据 - var ajaxData = { + let ajaxData = { action: "ajax_post_comment", comment: commentContent, author: commentName, @@ -2279,7 +2279,7 @@ if ($("html").hasClass("banner-as-cover")){ } /*Pjax*/ -var pjaxScrollTop = 0, pjaxLoading = false; +let pjaxScrollTop = 0, pjaxLoading = false; $.pjax.defaults.timeout = 10000; $.pjax.defaults.container = ['#primary', '#leftbar_part1_menu', '#leftbar_part2_inner', '.page-information-card-container', '#rightbar', '#wpadminbar']; $.pjax.defaults.fragment = ['#primary', '#leftbar_part1_menu', '#leftbar_part2_inner', '.page-information-card-container', '#rightbar', '#wpadminbar']; @@ -2448,7 +2448,7 @@ $(document).on("click" , "#blog_categories .tag" , function(){ initMobileCatalog(); // 如果有文章目录,默认展开 setTimeout(function() { - var catalogSection = $("#mobile_catalog_toggle").closest(".leftbar-mobile-collapse-section"); + let catalogSection = $("#mobile_catalog_toggle").closest(".leftbar-mobile-collapse-section"); console.log('[Mobile Sidebar] Catalog section found:', catalogSection.length); if (catalogSection.length > 0 && !catalogSection.hasClass("expanded")) { catalogSection.addClass("expanded"); @@ -2489,15 +2489,15 @@ $(document).on("click" , "#blog_categories .tag" , function(){ // ========== 移动端折叠面板交互 ========== $(document).on("click", ".leftbar-mobile-collapse-header", function(e) { - var section = $(this).closest(".leftbar-mobile-collapse-section"); - var header = $(this); - var isExpanded = section.hasClass("expanded"); + let section = $(this).closest(".leftbar-mobile-collapse-section"); + let header = $(this); + let isExpanded = section.hasClass("expanded"); // 添加点击波纹效果 - var ripple = $(''); - var rect = this.getBoundingClientRect(); - var x = e.clientX - rect.left; - var y = e.clientY - rect.top; + let ripple = $(''); + let rect = this.getBoundingClientRect(); + let x = e.clientX - rect.left; + let y = e.clientY - rect.top; ripple.css({ left: x + 'px', top: y + 'px' @@ -2523,14 +2523,14 @@ $(document).on("click" , "#blog_categories .tag" , function(){ function initMobileCatalog() { console.log('[Mobile Catalog] initMobileCatalog called, initialized:', window.mobileCatalogInitialized); if (window.mobileCatalogInitialized) return; - var $mobileContainer = $("#leftbar_mobile_catalog"); - var $postContent = $("#post_content"); + let $mobileContainer = $("#leftbar_mobile_catalog"); + let $postContent = $("#post_content"); console.log('[Mobile Catalog] Container found:', $mobileContainer.length, 'PostContent found:', $postContent.length); if ($mobileContainer.length === 0) return; if ($postContent.length === 0) return; // 直接生成目录,不依赖 headIndex 插件 - var $headers = $postContent.find('h1, h2, h3, h4, h5, h6'); + let $headers = $postContent.find('h1, h2, h3, h4, h5, h6'); console.log('[Mobile Catalog] Headers found:', $headers.length); if ($headers.length === 0) { $mobileContainer.html('
([\s\S]*?)<\/code>/',
'$1
',
@@ -2499,16 +2498,16 @@ function comment_mail_notify($comment){
if ($comment == null){
return;
}
- $id = $comment -> comment_ID;
- $commentPostID = $comment -> comment_post_ID;
- $commentAuthor = $comment -> comment_author;
- $parentID = $comment -> comment_parent;
+ $id = $comment->comment_ID;
+ $commentPostID = $comment->comment_post_ID;
+ $commentAuthor = $comment->comment_author;
+ $parentID = $comment->comment_parent;
if ($parentID == 0){
return;
}
$parentComment = get_comment($parentID);
- $parentEmail = $parentComment -> comment_author_email;
- $parentName = $parentComment -> comment_author;
+ $parentEmail = $parentComment->comment_author_email;
+ $parentName = $parentComment->comment_author;
$emailTo = "$parentName <$parentEmail>";
if (get_comment_meta($parentID, "enable_mailnotice", true) == "true"){
if (check_email_address($parentEmail)){
@@ -2555,8 +2554,8 @@ add_action('argon_async_comment_mail_notify', 'argon_async_comment_mail_notify_h
function post_comment_updatemetas($id){
$parentID = $_POST['comment_parent'];
$comment = get_comment($id);
- $commentPostID = $comment -> comment_post_ID;
- $commentAuthor = $comment -> comment_author;
+ $commentPostID = $comment->comment_post_ID;
+ $commentAuthor = $comment->comment_author;
$mailnoticeUnsubscribeKey = get_random_token();
//评论 Markdown 源码
update_comment_meta($id, "comment_content_source", $_POST['comment_content_source']);
@@ -2598,7 +2597,7 @@ function post_comment_updatemetas($id){
update_comment_meta($id, "enable_mailnotice", "false");
}
//向父级评论发送邮件
- if ($comment -> comment_approved == 1){
+ if ($comment->comment_approved == 1){
wp_schedule_single_event(time() + 1, 'argon_async_comment_mail_notify', array($comment->comment_ID));
}
//保存 QQ 号
@@ -2697,7 +2696,7 @@ function pin_comment(){
'msg' => $newPinnedStat ? __('评论已经是置顶状态', 'argon') : __('评论已经是取消置顶状态', 'argon')
)));
}
- if (get_comment($id) -> comment_parent != 0){
+ if (get_comment($id)->comment_parent != 0){
exit(json_encode(array(
'status' => 'failed',
'msg' => __('不能置顶子评论', 'argon')
@@ -2837,8 +2836,8 @@ function get_argon_comment_paginate_links_prev_url(){
//评论重排序(置顶优先)
$GLOBALS['comment_order'] = get_option('comment_order');
function argon_comment_cmp($a, $b){
- $a_pinned = get_comment_meta($a -> comment_ID, 'pinned', true);
- $b_pinned = get_comment_meta($b -> comment_ID, 'pinned', true);
+ $a_pinned = get_comment_meta($a->comment_ID, 'pinned', true);
+ $b_pinned = get_comment_meta($b->comment_ID, 'pinned', true);
if ($a_pinned != "true"){
$a_pinned = "false";
}
@@ -2846,7 +2845,7 @@ function argon_comment_cmp($a, $b){
$b_pinned = "false";
}
if ($a_pinned == $b_pinned){
- return ($a -> comment_date_gmt) > ($b -> comment_date_gmt);
+ return ($a->comment_date_gmt) > ($b->comment_date_gmt);
}else{
if ($a_pinned == "true"){
return ($GLOBALS['comment_order'] == 'desc');
@@ -2858,7 +2857,7 @@ function argon_comment_cmp($a, $b){
function argon_get_comments(){
global $wp_query;
/*$cpage = get_query_var('cpage') ?? 1;
- $maxiumPages = $wp_query -> max_num_pages;*/
+ $maxiumPages = $wp_query->max_num_pages;*/
$args = array(
'post__in' => array(get_the_ID()),
'type' => 'comment',
@@ -2876,7 +2875,7 @@ function argon_get_comments(){
}
$comment_query = new WP_Comment_Query;
- $comments = $comment_query -> query($args);
+ $comments = $comment_query->query($args);
if (get_option("argon_enable_comment_pinning", "false") == "true"){
usort($comments, "argon_comment_cmp");
@@ -2894,7 +2893,7 @@ function argon_get_comments(){
$comments_per_page = get_option('comments_per_page');
$comments_count = 0;
foreach ($comments as $comment){
- if ($comment -> comment_parent == 0){
+ if ($comment->comment_parent == 0){
$comments_count++;
}
}
@@ -2912,10 +2911,10 @@ function argon_get_comments(){
//QQ Avatar 获取
function get_avatar_by_qqnumber($avatar){
global $comment;
- if (!isset($comment) || !isset($comment -> comment_ID)){
+ if (!isset($comment) || !isset($comment->comment_ID)){
return $avatar;
}
- $qqnumber = get_comment_meta($comment -> comment_ID, 'qq_number', true);
+ $qqnumber = get_comment_meta($comment->comment_ID, 'qq_number', true);
if (!empty($qqnumber)){
preg_match_all('/width=\'(.*?)\'/', $avatar, $preg_res);
$size = $preg_res[1][0];
@@ -2977,7 +2976,7 @@ function the_content_filter($content){
$content = argon_fancybox($content);
}
global $post;
- $custom_css = get_post_meta($post -> ID, 'argon_custom_css', true);
+ $custom_css = get_post_meta($post->ID, 'argon_custom_css', true);
if (!empty($custom_css)){
$content .= "";
}
@@ -3066,7 +3065,7 @@ function alert_footer_copyright_changed(){ ?>