refactor: 代码规范化 - 统一格式风格

- style.css: 移除 4277 行多余空行 (16556 -> 12279 行)
- style.css: 修复文件头注释格式
- style.css: 移除空规则集
- style.css: 统一缩进风格
- argontheme.js: 统一比较运算符为严格相等 (=== / !==)
- argontheme.js: 移除多余空行
- 新增 .kiro/steering/code-style.md 代码规范文档
This commit is contained in:
2026-01-16 11:18:51 +08:00
parent b613e019df
commit a5419b0c6e
3 changed files with 199 additions and 4406 deletions

View File

@@ -0,0 +1,88 @@
# Argon 主题代码规范
## CSS 规范
### 格式化规则
- 使用 Tab 缩进1 Tab = 4 空格宽度)
- 每个属性独占一行
- 属性之间不要有空行
- 规则块之间保留一个空行
- 选择器与 `{` 之间有一个空格
- 属性值后的 `;` 前不要有空格
### 示例
```css
/* 正确 */
.selector {
property: value;
another-property: value;
}
.another-selector {
property: value;
}
/* 错误 - 属性之间有空行 */
.selector {
property: value;
another-property: value;
}
```
### 注释规范
- 区块注释使用 `/* ========== 区块名称 ========== */`
- 普通注释使用 `/* 注释内容 */`
- 多行注释每行以 ` * ` 开头
## JavaScript 规范
### 格式化规则
- 使用 Tab 缩进
- 字符串优先使用单引号 `'`
- 比较运算符使用严格相等 `===``!==`
- 语句末尾必须有分号 `;`
- 函数名与括号之间无空格
- 关键字后有空格if, for, while, function 等)
### 变量声明
- 优先使用 `let``const`
- 避免使用 `var`(除非需要函数作用域)
### 注释规范
- 区块注释使用 `// ========== 区块名称 ==========`
- 函数注释使用 JSDoc 格式
- 单行注释使用 `//`
### 示例
```javascript
// ========== 功能模块名称 ==========
/**
* 函数说明
* @param {string} param - 参数说明
* @returns {boolean} 返回值说明
*/
function functionName(param) {
if (param === 'value') {
return true;
}
return false;
}
```
## PHP 规范
### 格式化规则
- 使用 Tab 缩进
- 字符串优先使用单引号
- 数组使用短语法 `[]`
- 类名使用 PascalCase
- 函数名使用 snake_case遵循 WordPress 规范)
### WordPress 特定
- 使用 `esc_html()`, `esc_attr()` 等函数转义输出
- 使用 `wp_nonce_field()` 进行安全验证
- 遵循 WordPress Coding Standards

View File

@@ -77,10 +77,10 @@ if (typeof jQuery !== 'undefined') {
} }
// ========== 原有代码 ========== // ========== 原有代码 ==========
if (typeof(argonConfig) == "undefined"){ if (typeof(argonConfig) === "undefined"){
var argonConfig = {}; var argonConfig = {};
} }
if (typeof(argonConfig.wp_path) == "undefined"){ if (typeof(argonConfig.wp_path) === "undefined"){
argonConfig.wp_path = "/"; argonConfig.wp_path = "/";
} }
/*Cookies 操作*/ /*Cookies 操作*/
@@ -96,10 +96,10 @@ function getCookie(cname) {
let ca = decodedCookie.split(';'); let ca = decodedCookie.split(';');
for (let i = 0; i < ca.length; i++) { for (let i = 0; i < ca.length; i++) {
let c = ca[i]; let c = ca[i];
while (c.charAt(0) == ' ') { while (c.charAt(0) === ' ') {
c = c.substring(1); c = c.substring(1);
} }
if (c.indexOf(name) == 0) { if (c.indexOf(name) === 0) {
return c.substring(name.length, c.length); return c.substring(name.length, c.length);
} }
} }
@@ -293,10 +293,10 @@ translation['zh_TW'] = {
}; };
function __(text){ function __(text){
let lang = argonConfig.language; let lang = argonConfig.language;
if (typeof(translation[lang]) == "undefined"){ if (typeof(translation[lang]) === "undefined"){
return text; return text;
} }
if (typeof(translation[lang][text]) == "undefined"){ if (typeof(translation[lang][text]) === "undefined"){
return text; return text;
} }
return translation[lang][text]; return translation[lang][text];
@@ -365,7 +365,7 @@ function __(text){
document.addEventListener("scroll", changeToolbarOnTopClass, {passive: true}); document.addEventListener("scroll", changeToolbarOnTopClass, {passive: true});
return; return;
} }
if (argonConfig.headroom == "absolute") { if (argonConfig.headroom === "absolute") {
toolbar.classList.add("navbar-ontop"); toolbar.classList.add("navbar-ontop");
return; return;
} }
@@ -417,11 +417,11 @@ $(document).on("input" , "#navbar_search_input" , function(){
} }
}); });
$(document).on("keydown" , "#navbar_search_input_container #navbar_search_input" , function(e){ $(document).on("keydown" , "#navbar_search_input_container #navbar_search_input" , function(e){
if (e.keyCode != 13){ if (e.keyCode !== 13){
return; return;
} }
let word = $(this).val(); let word = $(this).val();
if (word == ""){ if (word === ""){
$("#navbar_search_input_container").blur(); $("#navbar_search_input_container").blur();
return; return;
} }
@@ -430,12 +430,12 @@ $(document).on("keydown" , "#navbar_search_input_container #navbar_search_input"
}); });
/*顶栏搜索 (Mobile)*/ /*顶栏搜索 (Mobile)*/
$(document).on("keydown" , "#navbar_search_input_mobile" , function(e){ $(document).on("keydown" , "#navbar_search_input_mobile" , function(e){
if (e.keyCode != 13){ if (e.keyCode !== 13){
return; return;
} }
let word = $(this).val(); let word = $(this).val();
$("#navbar_global .collapse-close button").click(); $("#navbar_global .collapse-close button").click();
if (word == ""){ if (word === ""){
return; return;
} }
let scrolltop = $(document).scrollTop(); let scrolltop = $(document).scrollTop();
@@ -454,11 +454,11 @@ $(document).on("blur" , "#leftbar_search_container" , function(){
$("#leftbar_search_input").attr("readonly", "readonly"); $("#leftbar_search_input").attr("readonly", "readonly");
}); });
$(document).on("keydown" , "#leftbar_search_input" , function(e){ $(document).on("keydown" , "#leftbar_search_input" , function(e){
if (e.keyCode != 13){ if (e.keyCode !== 13){
return; return;
} }
let word = $(this).val(); let word = $(this).val();
if (word == ""){ if (word === ""){
$("#leftbar_search_container").blur(); $("#leftbar_search_container").blur();
return; return;
} }
@@ -477,7 +477,7 @@ $(document).on("change" , ".search-filter" , function(e){
$(".search-filter:checked").each(function(){ $(".search-filter:checked").each(function(){
postTypes.push($(this).attr("name")); postTypes.push($(this).attr("name"));
}); });
if (postTypes.length == 0){ if (postTypes.length === 0){
postTypes = ["none"]; postTypes = ["none"];
} }
let url = new URL(document.location.href); let url = new URL(document.location.href);
@@ -490,7 +490,7 @@ $(document).on("change" , ".search-filter" , function(e){
/*左侧栏随页面滚动浮动*/ /*左侧栏随页面滚动浮动*/
!function(){ !function(){
if ($("#leftbar").length == 0){ if ($("#leftbar").length === 0){
let contentOffsetTop = $('#content').offset().top; let contentOffsetTop = $('#content').offset().top;
function changeLeftbarStickyStatusWithoutSidebar(){ function changeLeftbarStickyStatusWithoutSidebar(){
let scrollTop = document.documentElement.scrollTop || document.body.scrollTop; let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
@@ -519,7 +519,7 @@ $(document).on("change" , ".search-filter" , function(e){
function changeLeftbarStickyStatus(){ function changeLeftbarStickyStatus(){
let scrollTop = document.documentElement.scrollTop || document.body.scrollTop; let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
if( part1OffsetTop + part1OuterHeight + 10 - scrollTop <= (argonConfig.headroom != "absolute" ? 90 : 18) ){ if( part1OffsetTop + part1OuterHeight + 10 - scrollTop <= (argonConfig.headroom !== "absolute" ? 90 : 18) ){
//滚动条在页面中间浮动状态 //滚动条在页面中间浮动状态
leftbarPart2.classList.add('sticky'); leftbarPart2.classList.add('sticky');
if (leftbarPart3) { if (leftbarPart3) {
@@ -553,7 +553,7 @@ $(document).on("change" , ".search-filter" , function(e){
}(); }();
/*Headroom*/ /*Headroom*/
if (argonConfig.headroom == "true"){ if (argonConfig.headroom === "true"){
var headroom = new Headroom(document.querySelector("body"),{ var headroom = new Headroom(document.querySelector("body"),{
"tolerance" : { "tolerance" : {
up : 0, up : 0,
@@ -575,7 +575,7 @@ if (argonConfig.headroom == "true"){
/*瀑布流布局*/ /*瀑布流布局*/
function waterflowInit() { function waterflowInit() {
if (argonConfig.waterflow_columns == "1") { if (argonConfig.waterflow_columns === "1") {
return; return;
} }
$("#main.article-list img").each(function(index, ele){ $("#main.article-list img").each(function(index, ele){
@@ -584,7 +584,7 @@ function waterflowInit() {
} }
}); });
let columns; let columns;
if (argonConfig.waterflow_columns == "2and3") { if (argonConfig.waterflow_columns === "2and3") {
if ($("#main").outerWidth() > 1000) { if ($("#main").outerWidth() > 1000) {
columns = 3; columns = 3;
} else { } else {
@@ -593,9 +593,9 @@ function waterflowInit() {
}else{ }else{
columns = parseInt(argonConfig.waterflow_columns); columns = parseInt(argonConfig.waterflow_columns);
} }
if ($("#main").outerWidth() < 650 && columns == 2) { if ($("#main").outerWidth() < 650 && columns === 2) {
columns = 1; columns = 1;
}else if ($("#main").outerWidth() < 800 && columns == 3) { }else if ($("#main").outerWidth() < 800 && columns === 3) {
columns = 1; columns = 1;
} }
@@ -625,7 +625,7 @@ function waterflowInit() {
} }
let $items = $container.find("article.post:not(.no-results), .shuoshuo-preview-container"); let $items = $container.find("article.post:not(.no-results), .shuoshuo-preview-container");
columns = Math.max(Math.min(columns, $items.length), 1); columns = Math.max(Math.min(columns, $items.length), 1);
if (columns == 1) { if (columns === 1) {
$container.removeClass("waterflow"); $container.removeClass("waterflow");
$items.css("transition", "").css("position", "").css("width", "").css("top", "").css("left", "").css("margin", ""); $items.css("transition", "").css("position", "").css("width", "").css("top", "").css("left", "").css("margin", "");
$(".waterflow-placeholder").remove(); $(".waterflow-placeholder").remove();
@@ -650,7 +650,7 @@ function waterflowInit() {
} }
} }
waterflowInit(); waterflowInit();
if (argonConfig.waterflow_columns != "1") { if (argonConfig.waterflow_columns !== "1") {
$(window).resize(function(){ $(window).resize(function(){
waterflowInit(); waterflowInit();
}); });
@@ -755,7 +755,7 @@ if (argonConfig.waterflow_columns != "1") {
} }
}); });
if (localStorage['Argon_fabs_Floating_Status'] == "left"){ if (localStorage['Argon_fabs_Floating_Status'] === "left"){
$fabtns.addClass("fabtns-float-left"); $fabtns.addClass("fabtns-float-left");
} }
$toggleSidesBtn.on("click" , function(){ $toggleSidesBtn.on("click" , function(){
@@ -789,9 +789,9 @@ if (argonConfig.waterflow_columns != "1") {
$("html").addClass("use-serif"); $("html").addClass("use-serif");
localStorage['Argon_Use_Serif'] = "true"; localStorage['Argon_Use_Serif'] = "true";
}); });
if (localStorage['Argon_Use_Serif'] == "true"){ if (localStorage['Argon_Use_Serif'] === "true"){
$("html").addClass("use-serif"); $("html").addClass("use-serif");
}else if (localStorage['Argon_Use_Serif'] == "false"){ }else if (localStorage['Argon_Use_Serif'] === "false"){
$("html").removeClass("use-serif"); $("html").removeClass("use-serif");
} }
//阴影 //阴影
@@ -803,19 +803,19 @@ if (argonConfig.waterflow_columns != "1") {
$("html").addClass("use-big-shadow"); $("html").addClass("use-big-shadow");
localStorage['Argon_Use_Big_Shadow'] = "true"; localStorage['Argon_Use_Big_Shadow'] = "true";
}); });
if (localStorage['Argon_Use_Big_Shadow'] == "true"){ if (localStorage['Argon_Use_Big_Shadow'] === "true"){
$("html").addClass("use-big-shadow"); $("html").addClass("use-big-shadow");
}else if (localStorage['Argon_Use_Big_Shadow'] == "false"){ }else if (localStorage['Argon_Use_Big_Shadow'] === "false"){
$("html").removeClass("use-big-shadow"); $("html").removeClass("use-big-shadow");
} }
//滤镜 //滤镜
function setBlogFilter(name){ function setBlogFilter(name){
if (name == undefined || name == ""){ if (name === undefined || name === ""){
name = "off"; name = "off";
} }
if (!$("html").hasClass("filter-" + name)){ if (!$("html").hasClass("filter-" + name)){
$("html").removeClass("filter-sunset filter-darkness filter-grayscale"); $("html").removeClass("filter-sunset filter-darkness filter-grayscale");
if (name != "off"){ if (name !== "off"){
$("html").addClass("filter-" + name); $("html").addClass("filter-" + name);
} }
} }
@@ -830,11 +830,11 @@ if (argonConfig.waterflow_columns != "1") {
//UI 样式切换 (玻璃拟态/新拟态) //UI 样式切换 (玻璃拟态/新拟态)
function setUIStyle(style){ function setUIStyle(style){
if (style == undefined || style == ""){ if (style === undefined || style === ""){
style = "default"; style = "default";
} }
$("html").removeClass("style-glass style-neumorphism"); $("html").removeClass("style-glass style-neumorphism");
if (style != "default"){ if (style !== "default"){
$("html").addClass("style-" + style); $("html").addClass("style-" + style);
} }
$(".blog-setting-style-btn").removeClass("active"); $(".blog-setting-style-btn").removeClass("active");
@@ -858,7 +858,7 @@ if (argonConfig.waterflow_columns != "1") {
$readingProgressDetails.html((percent * 100).toFixed(0) + "%"); $readingProgressDetails.html((percent * 100).toFixed(0) + "%");
$readingProgressBar.css("width" , (percent * 100).toFixed(0) + "%"); $readingProgressBar.css("width" , (percent * 100).toFixed(0) + "%");
} }
if ($("article.post.post-full").length == 0){ if ($("article.post.post-full").length === 0){
hideReadingProgress(); hideReadingProgress();
}else{ }else{
let a = $window.scrollTop() - ($("article.post.post-full").offset().top - 80); let a = $window.scrollTop() - ($("article.post.post-full").offset().top - 80);
@@ -983,7 +983,7 @@ if (argonConfig.waterflow_columns != "1") {
$('#post_comment').addClass("editing"); $('#post_comment').addClass("editing");
$("#post_comment_content").val($("#comment-" + editID + " .comment-item-source").text()); $("#post_comment_content").val($("#comment-" + editID + " .comment-item-source").text());
$("#post_comment_content").trigger("change"); $("#post_comment_content").trigger("change");
if ($("#comment-" + editID).data("use-markdown") == true && document.getElementById("comment_post_use_markdown") != null){ if ($("#comment-" + editID).data("use-markdown") === true && document.getElementById("comment_post_use_markdown") !== null){
document.getElementById("comment_post_use_markdown").checked = true; document.getElementById("comment_post_use_markdown").checked = true;
}else{ }else{
document.getElementById("comment_post_use_markdown").checked = false; document.getElementById("comment_post_use_markdown").checked = false;
@@ -1002,7 +1002,7 @@ if (argonConfig.waterflow_columns != "1") {
editing = false; editing = false;
editID = 0; editID = 0;
$("#post_comment").removeClass("post-comment-force-privatemode-on post-comment-force-privatemode-off"); $("#post_comment").removeClass("post-comment-force-privatemode-on post-comment-force-privatemode-off");
if (clear == true) $("#post_comment_content").val(""); if (clear === true) $("#post_comment_content").val("");
$("#post_comment_content").trigger("change"); $("#post_comment_content").trigger("change");
$('#post_comment').removeClass("editing"); $('#post_comment').removeClass("editing");
} }
@@ -1047,7 +1047,7 @@ if (argonConfig.waterflow_columns != "1") {
}, },
success: function(result){ success: function(result){
$("#comment_pin_comfirm_dialog").modal('hide'); $("#comment_pin_comfirm_dialog").modal('hide');
if (result.status == "success"){ if (result.status === "success"){
if (pinned){ if (pinned){
$("#comment-" + commentID + " .comment-name .badge-pinned").remove(); $("#comment-" + commentID + " .comment-name .badge-pinned").remove();
$("#comment-" + commentID + " .comment-unpin").removeClass("comment-unpin").addClass("comment-pin").html(__("置顶")); $("#comment-" + commentID + " .comment-unpin").removeClass("comment-unpin").addClass("comment-pin").html(__("置顶"));
@@ -1105,7 +1105,6 @@ if (argonConfig.waterflow_columns != "1") {
$("#comment_pin_comfirm_dialog").modal(null); $("#comment_pin_comfirm_dialog").modal(null);
} }
//显示/隐藏额外输入框 (评论者网站) //显示/隐藏额外输入框 (评论者网站)
$(document).on("click" , "#post_comment_toggle_extra_input" , function(){ $(document).on("click" , "#post_comment_toggle_extra_input" , function(){
$("#post_comment").toggleClass("show-extra-input"); $("#post_comment").toggleClass("show-extra-input");
@@ -1182,7 +1181,7 @@ if (argonConfig.waterflow_columns != "1") {
} }
} }
}else{ }else{
if (commentEmail.length || (document.getElementById("comment_post_mailnotice") != null && document.getElementById("comment_post_mailnotice").checked == true)){ if (commentEmail.length || (document.getElementById("comment_post_mailnotice") !== null && document.getElementById("comment_post_mailnotice").checked === true)){
if ($("#post_comment").hasClass("enable-qq-avatar")){ if ($("#post_comment").hasClass("enable-qq-avatar")){
if (!(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(commentEmail) && !(/^[1-9][0-9]{4,10}$/).test(commentEmail)){ if (!(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(commentEmail) && !(/^[1-9][0-9]{4,10}$/).test(commentEmail)){
isError = true; isError = true;
@@ -1196,7 +1195,7 @@ if (argonConfig.waterflow_columns != "1") {
} }
} }
} }
if (commentLink != "" && !(/https?:\/\//).test(commentLink)){ if (commentLink !== "" && !(/https?:\/\//).test(commentLink)){
isError = true; isError = true;
errorMsg += __("网站格式错误 (不是 http(s):// 开头)") + "</br>"; errorMsg += __("网站格式错误 (不是 http(s):// 开头)") + "</br>";
} }
@@ -1224,11 +1223,11 @@ if (argonConfig.waterflow_columns != "1") {
} }
} else { } else {
// 原有的数学验证码检查 // 原有的数学验证码检查
if (commentCaptcha == ""){ if (commentCaptcha === ""){
isError = true; isError = true;
errorMsg += __("验证码未输入"); errorMsg += __("验证码未输入");
} }
if (commentCaptcha != "" && !(/^[0-9]+$/).test(commentCaptcha)){ if (commentCaptcha !== "" && !(/^[0-9]+$/).test(commentCaptcha)){
isError = true; isError = true;
errorMsg += __("验证码格式错误"); errorMsg += __("验证码格式错误");
} }
@@ -1399,7 +1398,7 @@ if (argonConfig.waterflow_columns != "1") {
} }
//判断是否有错误 //判断是否有错误
if (result.status == "failed"){ if (result.status === "failed"){
// 使用 setTimeout 确保 iziToast 操作在下一个事件循环中执行 // 使用 setTimeout 确保 iziToast 操作在下一个事件循环中执行
setTimeout(function() { setTimeout(function() {
try { try {
@@ -1445,15 +1444,15 @@ if (argonConfig.waterflow_columns != "1") {
//插入新评论 //插入新评论
result.html = result.html.replace(/<(\/).noscript>/g, ""); result.html = result.html.replace(/<(\/).noscript>/g, "");
let parentID = result.parentID; let parentID = result.parentID;
if (parentID == "" || parentID == null){ if (parentID === "" || parentID === null){
parentID = 0; parentID = 0;
} }
parentID = parseInt(parentID); parentID = parseInt(parentID);
if (parentID == 0){ if (parentID === 0){
if ($("#comments > .card-body > ol.comment-list").length == 0){ if ($("#comments > .card-body > ol.comment-list").length === 0){
$("#comments > .card-body").html("<h2 class='comments-title'><i class='fa fa-comments'></i> " + __("评论") + "</h2><ol class='comment-list'></ol>"); $("#comments > .card-body").html("<h2 class='comments-title'><i class='fa fa-comments'></i> " + __("评论") + "</h2><ol class='comment-list'></ol>");
} }
if (result.commentOrder == "asc"){ if (result.commentOrder === "asc"){
$("#comments > .card-body > ol.comment-list").append(result.html); $("#comments > .card-body > ol.comment-list").append(result.html);
}else{ }else{
$("#comments > .card-body > ol.comment-list").prepend(result.html); $("#comments > .card-body > ol.comment-list").prepend(result.html);
@@ -1610,7 +1609,7 @@ if (argonConfig.waterflow_columns != "1") {
$("#post_comment_send .btn-inner--text.hide-on-comment-not-editing").html(__("编辑")); $("#post_comment_send .btn-inner--text.hide-on-comment-not-editing").html(__("编辑"));
//判断是否有错误 //判断是否有错误
if (result.status == "failed"){ if (result.status === "failed"){
iziToast.destroy(); iziToast.destroy();
iziToast.show({ iziToast.show({
title: __("评论编辑失败"), title: __("评论编辑失败"),
@@ -1632,7 +1631,7 @@ if (argonConfig.waterflow_columns != "1") {
result.new_comment = result.new_comment.replace(/<(\/).noscript>/g, ""); result.new_comment = result.new_comment.replace(/<(\/).noscript>/g, "");
$("#comment-" + editID + " .comment-item-text").html(result.new_comment); $("#comment-" + editID + " .comment-item-text").html(result.new_comment);
$("#comment-" + editID + " .comment-item-source").html(result.new_comment_source); $("#comment-" + editID + " .comment-item-source").html(result.new_comment_source);
if ($("#comment-" + editID + " .comment-info .comment-edited").length == 0){ if ($("#comment-" + editID + " .comment-info .comment-edited").length === 0){
$("#comment-" + editID + " .comment-info").prepend("<div class='comment-edited'><i class='fa fa-pencil' aria-hidden='true'></i>" + __("已编辑") + "</div>") $("#comment-" + editID + " .comment-info").prepend("<div class='comment-edited'><i class='fa fa-pencil' aria-hidden='true'></i>" + __("已编辑") + "</div>")
} }
if (result.can_visit_edit_history){ if (result.can_visit_edit_history){
@@ -1668,7 +1667,7 @@ if (argonConfig.waterflow_columns != "1") {
$("#post_comment_edit_cancel").removeAttr("disabled"); $("#post_comment_edit_cancel").removeAttr("disabled");
$("#post_comment_send .btn-inner--icon.hide-on-comment-not-editing").html("<i class='fa fa-pencil'></i>"); $("#post_comment_send .btn-inner--icon.hide-on-comment-not-editing").html("<i class='fa fa-pencil'></i>");
$("#post_comment_send .btn-inner--text.hide-on-comment-not-editing").html(__("编辑")); $("#post_comment_send .btn-inner--text.hide-on-comment-not-editing").html(__("编辑"));
if (result.readyState != 4 || result.status == 0){ if (result.readyState !== 4 || result.status === 0){
iziToast.destroy(); iziToast.destroy();
iziToast.show({ iziToast.show({
title: __("评论编辑失败"), title: __("评论编辑失败"),
@@ -1723,7 +1722,7 @@ if (argonConfig.waterflow_columns != "1") {
} }
} }
}else{ }else{
if (commentEmail.length || (document.getElementById("comment_post_mailnotice") != null && document.getElementById("comment_post_mailnotice").checked == true)){ if (commentEmail.length || (document.getElementById("comment_post_mailnotice") !== null && document.getElementById("comment_post_mailnotice").checked === true)){
if ($("#post_comment").hasClass("enable-qq-avatar")){ if ($("#post_comment").hasClass("enable-qq-avatar")){
if (!(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(commentEmail) && !(/^[1-9][0-9]{4,10}$/).test(commentEmail)){ if (!(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(commentEmail) && !(/^[1-9][0-9]{4,10}$/).test(commentEmail)){
isError = true; isError = true;
@@ -1737,7 +1736,7 @@ if (argonConfig.waterflow_columns != "1") {
} }
} }
} }
if (commentLink != "" && !(/https?:\/\//).test(commentLink)){ if (commentLink !== "" && !(/https?:\/\//).test(commentLink)){
isError = true; isError = true;
errorMsg += __("网站格式错误 (不是 http(s):// 开头)") + "</br>"; errorMsg += __("网站格式错误 (不是 http(s):// 开头)") + "</br>";
} }
@@ -1837,7 +1836,7 @@ $(document).on("click" , ".comment-upvote" , function(){
}, },
success : function(result){ success : function(result){
$this.removeClass("comment-upvoting"); $this.removeClass("comment-upvoting");
if (result.status == "success"){ if (result.status === "success"){
$(".comment-upvote-num" , $this).html(result.total_upvote); $(".comment-upvote-num" , $this).html(result.total_upvote);
$this.addClass("upvoted"); $this.addClass("upvoted");
}else{ }else{
@@ -1919,10 +1918,10 @@ $(document).on("dragstart" , ".emotion-keyboard .emotion-item > img, .comment-st
e.preventDefault(); e.preventDefault();
}); });
document.addEventListener('click', (e) => { document.addEventListener('click', (e) => {
if (document.getElementById("comment_emotion_btn") == null){ if (document.getElementById("comment_emotion_btn") === null){
return; return;
} }
  if(e.target.id != "comment_emotion_btn" && e.target.id != "emotion_keyboard" && !document.getElementById("comment_emotion_btn").contains(e.target) && !document.getElementById("emotion_keyboard").contains(e.target)){   if(e.target.id !== "comment_emotion_btn" && e.target.id !== "emotion_keyboard" && !document.getElementById("comment_emotion_btn").contains(e.target) && !document.getElementById("emotion_keyboard").contains(e.target)){
$("#comment_emotion_btn").removeClass("comment-emotion-keyboard-open"); $("#comment_emotion_btn").removeClass("comment-emotion-keyboard-open");
  }   }
}) })
@@ -1942,7 +1941,7 @@ function showCommentEditHistory(id){
id: id id: id
}, },
success: function(result){ success: function(result){
if ($("#comment_edit_history").data("request-id") != requestID){ if ($("#comment_edit_history").data("request-id") !== requestID){
return; return;
} }
$("#comment_edit_history .modal-body").hide(); $("#comment_edit_history .modal-body").hide();
@@ -1950,7 +1949,7 @@ function showCommentEditHistory(id){
$("#comment_edit_history .modal-body").fadeIn(300); $("#comment_edit_history .modal-body").fadeIn(300);
}, },
error: function(result){ error: function(result){
if ($("#comment_edit_history").data("request-id") != requestID){ if ($("#comment_edit_history").data("request-id") !== requestID){
return; return;
} }
$("#comment_edit_history .modal-body").hide(); $("#comment_edit_history .modal-body").hide();
@@ -1964,7 +1963,7 @@ $(document).on("click" , ".comment-edited.comment-edithistory-accessible" , func
}); });
/*过长评论折叠*/ /*过长评论折叠*/
function foldLongComments(){ function foldLongComments(){
if (argonConfig.fold_long_comments == false){ if (argonConfig.fold_long_comments === false){
return; return;
} }
$(".comment-item-inner").each(function(){ $(".comment-item-inner").each(function(){
@@ -1988,7 +1987,7 @@ function generateCommentTextAvatar(img){
emailHash = img.attr("src").match(/([a-f\d]{32}|[A-F\d]{32})/)[0]; emailHash = img.attr("src").match(/([a-f\d]{32}|[A-F\d]{32})/)[0];
}catch{ }catch{
emailHash = img.parent().parent().parent().find(".comment-name").text().trim(); emailHash = img.parent().parent().parent().find(".comment-name").text().trim();
if (emailHash == '' || emailHash == undefined){ if (emailHash === '' || emailHash === undefined){
emailHash = img.parent().find("*[class*='comment-author']").text().trim(); emailHash = img.parent().find("*[class*='comment-author']").text().trim();
} }
} }
@@ -1998,7 +1997,7 @@ function generateCommentTextAvatar(img){
} }
let colors = ['#e25f50', '#f25e90', '#bc67cb', '#9672cf', '#7984ce', '#5c96fa', '#7bdeeb', '#45d0e2', '#48b7ad', '#52bc89', '#9ace5f', '#d4e34a', '#f9d715', '#fac400', '#ffaa00', '#ff8b61', '#c2c2c2', '#8ea3af', '#a1877d', '#a3a3a3', '#b0b6e3', '#b49cde', '#c2c2c2', '#7bdeeb', '#bcaaa4', '#aed77f']; let colors = ['#e25f50', '#f25e90', '#bc67cb', '#9672cf', '#7984ce', '#5c96fa', '#7bdeeb', '#45d0e2', '#48b7ad', '#52bc89', '#9ace5f', '#d4e34a', '#f9d715', '#fac400', '#ffaa00', '#ff8b61', '#c2c2c2', '#8ea3af', '#a1877d', '#a3a3a3', '#b0b6e3', '#b49cde', '#c2c2c2', '#7bdeeb', '#bcaaa4', '#aed77f'];
let text = $(".comment-name", img.parent().parent().parent()).text().trim()[0]; let text = $(".comment-name", img.parent().parent().parent()).text().trim()[0];
if (text == '' || text == undefined){ if (text === '' || text === undefined){
text = img.parent().find("*[class*='comment-author']").text().trim()[0]; text = img.parent().find("*[class*='comment-author']").text().trim()[0];
} }
let classList = img.attr('class') + " text-avatar"; let classList = img.attr('class') + " text-avatar";
@@ -2078,7 +2077,7 @@ $(document).on("submit" , ".post-password-form" , function(){
NProgress.done(); NProgress.done();
$vdom = $(result); $vdom = $(result);
$("#comments > .card-body > ol.comment-list").append($("#comments > .card-body > ol.comment-list", $vdom).html()); $("#comments > .card-body > ol.comment-list").append($("#comments > .card-body > ol.comment-list", $vdom).html());
if ($("#comments_more", $vdom).length == 0){ if ($("#comments_more", $vdom).length === 0){
$("#comments_more").remove(); $("#comments_more").remove();
$(".comments-navigation-more").html("<div class='comments-navigation-nomore'>" + __("没有更多了") + "</div>"); $(".comments-navigation-more").html("<div class='comments-navigation-nomore'>" + __("没有更多了") + "</div>");
}else{ }else{
@@ -2098,13 +2097,13 @@ $(document).on("submit" , ".post-password-form" , function(){
/*URL 中 # 根据 ID 定位*/ /*URL 中 # 根据 ID 定位*/
function gotoHash(hash, durtion, easing = 'easeOutExpo'){ function gotoHash(hash, durtion, easing = 'easeOutExpo'){
if (hash.length == 0){ if (hash.length === 0){
return; return;
} }
if ($(hash).length == 0){ if ($(hash).length === 0){
return; return;
} }
if (durtion == null){ if (durtion === null){
durtion = 200; durtion = 200;
} }
$("body,html").stop().animate({ $("body,html").stop().animate({
@@ -2145,7 +2144,7 @@ showPostOutdateToast();
/*Zoomify*/ /*Zoomify*/
function zoomifyInit(){ function zoomifyInit(){
if (argonConfig.zoomify == false){ if (argonConfig.zoomify === false){
return; return;
} }
if (typeof $.fn.zoomify === 'function') { if (typeof $.fn.zoomify === 'function') {
@@ -2286,7 +2285,7 @@ $.pjax.defaults.container = ['#primary', '#leftbar_part1_menu', '#leftbar_part2_
$.pjax.defaults.fragment = ['#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'];
$(document).pjax("a[href]:not([no-pjax]):not(.no-pjax):not([target='_blank']):not([download]):not(.reference-link):not(.reference-list-backlink)") $(document).pjax("a[href]:not([no-pjax]):not(.no-pjax):not([target='_blank']):not([download]):not(.reference-link):not(.reference-list-backlink)")
.on('pjax:click', function(e, f, g){ .on('pjax:click', function(e, f, g){
if (argonConfig.disable_pjax == true){ if (argonConfig.disable_pjax === true){
e.preventDefault(); e.preventDefault();
return; return;
} }
@@ -2340,8 +2339,8 @@ $(document).pjax("a[href]:not([no-pjax]):not(.no-pjax):not([target='_blank']):no
pjaxLoading = false; pjaxLoading = false;
NProgress.inc(); NProgress.inc();
try{ try{
if (MathJax != undefined){ if (MathJax !== undefined){
if (MathJax.Hub != undefined){ if (MathJax.Hub !== undefined){
MathJax.Hub.Typeset(); MathJax.Hub.Typeset();
}else{ }else{
MathJax.typeset(); MathJax.typeset();
@@ -2349,7 +2348,7 @@ $(document).pjax("a[href]:not([no-pjax]):not(.no-pjax):not([target='_blank']):no
} }
}catch (err){} }catch (err){}
try{ try{
if (renderMathInElement != undefined){ if (renderMathInElement !== undefined){
renderMathInElement(document.body,{ renderMathInElement(document.body,{
delimiters: [ delimiters: [
{left: "$$", right: "$$", display: true}, {left: "$$", right: "$$", display: true},
@@ -2374,7 +2373,7 @@ $(document).pjax("a[href]:not([no-pjax]):not(.no-pjax):not([target='_blank']):no
foldLongShuoshuo(); foldLongShuoshuo();
$("html").trigger("resize"); $("html").trigger("resize");
if (typeof(window.pjaxLoaded) == "function"){ if (typeof(window.pjaxLoaded) === "function"){
try{ try{
window.pjaxLoaded(); window.pjaxLoaded();
}catch (err){ }catch (err){
@@ -2471,11 +2470,11 @@ $(document).on("click" , "#blog_categories .tag" , function(){
}); });
// 移动端侧边栏搜索 // 移动端侧边栏搜索
$(document).on("keydown" , "#leftbar_mobile_search_input" , function(e){ $(document).on("keydown" , "#leftbar_mobile_search_input" , function(e){
if (e.keyCode != 13){ if (e.keyCode !== 13){
return; return;
} }
let word = $(this).val(); let word = $(this).val();
if (word == ""){ if (word === ""){
return; return;
} }
$("html").removeClass("leftbar-opened"); $("html").removeClass("leftbar-opened");
@@ -3001,7 +3000,7 @@ $(document).on("click" , ".collapse-block .collapse-block-title" , function(){
function getGithubInfoCardContent(){ function getGithubInfoCardContent(){
$(".github-info-card").each(function(){ $(".github-info-card").each(function(){
(function($this){ (function($this){
if ($this.attr("data-getdata") == "backend"){ if ($this.attr("data-getdata") === "backend"){
$(".github-info-card-description" , $this).html($this.attr("data-description")); $(".github-info-card-description" , $this).html($this.attr("data-description"));
$(".github-info-card-stars" , $this).html($this.attr("data-stars")); $(".github-info-card-stars" , $this).html($this.attr("data-stars"));
$(".github-info-card-forks" , $this).html($this.attr("data-forks")); $(".github-info-card-forks" , $this).html($this.attr("data-forks"));
@@ -3018,7 +3017,7 @@ function getGithubInfoCardContent(){
dataType : "json", dataType : "json",
success : function(result){ success : function(result){
description = result.description; description = result.description;
if (result.homepage != "" && result.homepage != null){ if (result.homepage !== "" && result.homepage !== null){
description += " <a href='" + result.homepage + "' target='_blank' no-pjax>" + result.homepage + "</a>" description += " <a href='" + result.homepage + "' target='_blank' no-pjax>" + result.homepage + "</a>"
} }
$(".github-info-card-description" , $this).html(description); $(".github-info-card-description" , $this).html(description);
@@ -3026,7 +3025,7 @@ function getGithubInfoCardContent(){
$(".github-info-card-forks" , $this).html(result.forks_count); $(".github-info-card-forks" , $this).html(result.forks_count);
}, },
error : function(xhr){ error : function(xhr){
if (xhr.status == 404){ if (xhr.status === 404){
$(".github-info-card-description" , $this).html(__("找不到该 Repo")); $(".github-info-card-description" , $this).html(__("找不到该 Repo"));
}else{ }else{
$(".github-info-card-description" , $this).html(__("获取 Repo 信息失败")); $(".github-info-card-description" , $this).html(__("获取 Repo 信息失败"));
@@ -3053,7 +3052,7 @@ $(document).on("click" , ".shuoshuo-upvote" , function(){
}, },
success : function(result){ success : function(result){
$this.removeClass("shuoshuo-upvoting"); $this.removeClass("shuoshuo-upvoting");
if (result.status == "success"){ if (result.status === "success"){
$(".shuoshuo-upvote-num" , $this).html(result.total_upvote); $(".shuoshuo-upvote-num" , $this).html(result.total_upvote);
$("i.fa-thumbs-o-up" , $this).addClass("fa-thumbs-up").removeClass("fa-thumbs-o-up"); $("i.fa-thumbs-o-up" , $this).addClass("fa-thumbs-up").removeClass("fa-thumbs-o-up");
$this.addClass("upvoted"); $this.addClass("upvoted");
@@ -3105,7 +3104,7 @@ $(document).on("click" , ".shuoshuo-upvote" , function(){
}); });
//折叠长说说 //折叠长说说
function foldLongShuoshuo(){ function foldLongShuoshuo(){
if (argonConfig.fold_long_shuoshuo == false){ if (argonConfig.fold_long_shuoshuo === false){
return; return;
} }
$("#main .shuoshuo-foldable > .shuoshuo-content").each(function(){ $("#main .shuoshuo-foldable > .shuoshuo-content").each(function(){
@@ -3135,7 +3134,7 @@ function rgb2hsl(R,G,B){
let H, S, L = (var_Max + var_Min) / 2; let H, S, L = (var_Max + var_Min) / 2;
if (del_Max == 0){ if (del_Max === 0){
H = 0; H = 0;
S = 0; S = 0;
}else{ }else{
@@ -3149,13 +3148,13 @@ function rgb2hsl(R,G,B){
del_G = (((var_Max - g) / 6) + (del_Max / 2)) / del_Max; del_G = (((var_Max - g) / 6) + (del_Max / 2)) / del_Max;
del_B = (((var_Max - b) / 6) + (del_Max / 2)) / del_Max; del_B = (((var_Max - b) / 6) + (del_Max / 2)) / del_Max;
if (r == var_Max){ if (r === var_Max){
H = del_B - del_G; H = del_B - del_G;
} }
else if (g == var_Max){ else if (g === var_Max){
H = (1 / 3) + del_R - del_B; H = (1 / 3) + del_R - del_B;
} }
else if (b == var_Max){ else if (b === var_Max){
H = (2 / 3) + del_G - del_R; H = (2 / 3) + del_G - del_R;
} }
if (H < 0) H += 1; if (H < 0) H += 1;
@@ -3180,7 +3179,7 @@ function Hue_2_RGB(v1,v2,vH){
} }
function hsl2rgb(h,s,l){ function hsl2rgb(h,s,l){
let r, g, b, var_1, var_2; let r, g, b, var_1, var_2;
if (s == 0){ if (s === 0){
r = l; r = l;
g = l; g = l;
b = l; b = l;
@@ -3252,7 +3251,7 @@ function hex2str(hex){
return rgb2str(hex2rgb(hex)); return rgb2str(hex2rgb(hex));
} }
//颜色选择器 & 切换主题色 //颜色选择器 & 切换主题色
if ($("meta[name='argon-enable-custom-theme-color']").attr("content") == 'true'){ if ($("meta[name='argon-enable-custom-theme-color']").attr("content") === 'true'){
let themeColorPicker = new Pickr({ let themeColorPicker = new Pickr({
el: '#theme-color-picker', el: '#theme-color-picker',
container: 'body', container: 'body',
@@ -3330,7 +3329,6 @@ function updateThemeColor(color, setcookie){
document.documentElement.style.setProperty('--themecolor-S', HSL['S']); document.documentElement.style.setProperty('--themecolor-S', HSL['S']);
document.documentElement.style.setProperty('--themecolor-L', HSL['L']); document.documentElement.style.setProperty('--themecolor-L', HSL['L']);
if (rgb2gray(RGB['R'], RGB['G'], RGB['B']) < 50){ if (rgb2gray(RGB['R'], RGB['G'], RGB['B']) < 50){
$("html").addClass("themecolor-toodark"); $("html").addClass("themecolor-toodark");
}else{ }else{
@@ -3362,7 +3360,7 @@ function startTypeEffect($element, text, interval){
typeEffect($element, text, 1, interval); typeEffect($element, text, 1, interval);
} }
!function(){ !function(){
if ($(".banner-title").data("interval") != undefined){ if ($(".banner-title").data("interval") !== undefined){
let interval = $(".banner-title").data("interval"); let interval = $(".banner-title").data("interval");
let $title = $(".banner-title-inner"); let $title = $(".banner-title-inner");
let $subTitle = $(".banner-subtitle"); let $subTitle = $(".banner-subtitle");
@@ -3401,7 +3399,7 @@ function randomString(len) {
} }
var codeOfBlocks = {}; var codeOfBlocks = {};
function getCodeFromBlock(block){ function getCodeFromBlock(block){
if (codeOfBlocks[block.id] != undefined){ if (codeOfBlocks[block.id] !== undefined){
return codeOfBlocks[block.id]; return codeOfBlocks[block.id];
} }
let lines = $(".hljs-ln-code", block); let lines = $(".hljs-ln-code", block);
@@ -3415,10 +3413,10 @@ function getCodeFromBlock(block){
return res; return res;
} }
function highlightJsRender(){ function highlightJsRender(){
if (typeof(hljs) == "undefined"){ if (typeof(hljs) === "undefined"){
return; return;
} }
if (typeof(argonConfig.code_highlight.enable) == "undefined"){ if (typeof(argonConfig.code_highlight.enable) === "undefined"){
return; return;
} }
if (!argonConfig.code_highlight.enable){ if (!argonConfig.code_highlight.enable){
@@ -3560,7 +3558,7 @@ function humanTimeDiff(time){
theDayBeforeYesterday.setMinutes(0); theDayBeforeYesterday.setMinutes(0);
theDayBeforeYesterday.setSeconds(0); theDayBeforeYesterday.setSeconds(0);
theDayBeforeYesterday.setMilliseconds(0); theDayBeforeYesterday.setMilliseconds(0);
if (time > theDayBeforeYesterday && argonConfig.language.indexOf("zh") == 0){ if (time > theDayBeforeYesterday && argonConfig.language.indexOf("zh") === 0){
return __("前天") + " " + time.getHours() + ":" + addPreZero(time.getMinutes(), 2); return __("前天") + " " + time.getHours() + ":" + addPreZero(time.getMinutes(), 2);
} }
if (delta < 1000 * 60 * 60 * 24 * 30){ if (delta < 1000 * 60 * 60 * 24 * 30){
@@ -3574,17 +3572,17 @@ function humanTimeDiff(time){
theFirstDayOfThisYear.setSeconds(0); theFirstDayOfThisYear.setSeconds(0);
theFirstDayOfThisYear.setMilliseconds(0); theFirstDayOfThisYear.setMilliseconds(0);
if (time > theFirstDayOfThisYear){ if (time > theFirstDayOfThisYear){
if (argonConfig.dateFormat == "YMD" || argonConfig.dateFormat == "MDY"){ if (argonConfig.dateFormat === "YMD" || argonConfig.dateFormat === "MDY"){
return (time.getMonth() + 1) + "-" + time.getDate(); return (time.getMonth() + 1) + "-" + time.getDate();
}else{ }else{
return time.getDate() + "-" + (time.getMonth() + 1); return time.getDate() + "-" + (time.getMonth() + 1);
} }
} }
if (argonConfig.dateFormat == "YMD"){ if (argonConfig.dateFormat === "YMD"){
return time.getFullYear() + "-" + (time.getMonth() + 1) + "-" + time.getDate(); return time.getFullYear() + "-" + (time.getMonth() + 1) + "-" + time.getDate();
}else if (argonConfig.dateFormat == "MDY"){ }else if (argonConfig.dateFormat === "MDY"){
return time.getDate() + "-" + (time.getMonth() + 1) + "-" + time.getFullYear(); return time.getDate() + "-" + (time.getMonth() + 1) + "-" + time.getFullYear();
}else if (argonConfig.dateFormat == "DMY"){ }else if (argonConfig.dateFormat === "DMY"){
return time.getDate() + "-" + (time.getMonth() + 1) + "-" + time.getFullYear(); return time.getDate() + "-" + (time.getMonth() + 1) + "-" + time.getFullYear();
} }
} }
@@ -3598,7 +3596,6 @@ setInterval(function(){
calcHumanTimesOnPage() calcHumanTimesOnPage()
}, 15000); }, 15000);
/*Console*/ /*Console*/
!function(){ !function(){
void 0; void 0;

4312
style.css

File diff suppressed because it is too large Load Diff