4 lines
50 KiB
JavaScript
4 lines
50 KiB
JavaScript
/*! handsome 2020-08-15 */
|
||
|
||
var handsome_ajax={init:function(){this.login_ajax(),this.initAndPjax_Complete()},pjax_complete:function(){this.initAndPjax_Complete()},initAndPjax_Complete:function(){this.password_post_ajax()},login_ajax:function(){function a(){$("#login-submit").attr("disabled",!1).fadeTo("",1)}$("#Login_form").submit(function(){if($(this).hasClass("banLogin"))return location.reload(),!1;$("#login-submit").attr("disabled",!0).fadeTo("slow",.5);var b=$("#navbar-login-user").val(),c=$("#navbar-login-password").val();return""==b?($.message({title:LocalConst.LOGIN_TITLE,message:LocalConst.LOGIN_USERNAME_INFO,type:"warning"}),$("#navbar-login-user").focus(),a(),!1):""==c?($.message({title:LocalConst.LOGIN_TITLE,message:LocalConst.LOGIN_PASSWORD_INFO,type:"warning"}),$("#navbar-login-password").focus(),a(),!1):($("#login-submit").addClass("active"),$("#spin-login").addClass("show inline"),$.ajax({url:$(this).attr("action"),type:$(this).attr("method"),data:$(this).serializeArray(),error:function(){return $.message({title:LocalConst.LOGIN_TITLE,message:LocalConst.LOGIN_SUBMIT_ERROR,type:"error"}),a(),!1},success:function(b){b=$.parseHTML(b),$("#login-submit").removeClass("active"),$("#spin-login").removeClass("show inline");try{if($("#Logged-in",b).length<=0)return $.message({title:LocalConst.LOGIN_TITLE,message:LocalConst.LOGIN_SUBMIT_INFO,type:"error"}),a(),!1;b=$("#easyLogin",b).html(),$("#easyLogin").html(b),$.message({title:LocalConst.LOGIN_TITLE,message:LocalConst.LOGIN_SUBMIT_SUCCESS+' <a onclick="location.reload();">'+LocalConst.CLICK_TO_REFRESH+"</a>",type:"success"})}catch(a){alert("按下F12,查看输出错误信息")}}}),!1)})},password_post_ajax:function(){$("#post-content").delegate("form.protected","submit",function(){return $.ajax({url:$(this).attr("action"),type:$(this).attr("method"),data:$(this).serializeArray(),error:function(a){try{if($("#post-content",data).length<=0)return $.message({title:"提交通知",message:LocalConst.SUBMIT_PASSWORD_INFO,type:"warning"}),!1;window.location.reload()}catch(a){window.location.reload(),console.log(a)}},success:function(a){try{if($("#post-content",a).length<=0)return $.message({title:"提交通知",message:LocalConst.SUBMIT_PASSWORD_INFO,type:"warning"}),!1;window.location.reload()}catch(a){console.log(a),window.location.reload()}}}),!1})}};const handsome_basics={init:function(){this.nav_handle(),this.searchTips(),this.initAndPjax_Complete()},pjax_complete:function(){this.initAndPjax_Complete()},initAndPjax_Complete:function(){},nav_handle:function(){var a=navigator.userAgent;a.indexOf("Safari")>-1&&a.indexOf("Chrome")<1&&$("#left_footer").addClass("hide"),$(document).on("click","[ui-toggle-class]",function(a){a.preventDefault();var b=$(a.target);b.attr("ui-toggle-class")||(b=b.closest("[ui-toggle-class]"));var c=b.attr("ui-toggle-class").split(","),d=b.attr("target")&&b.attr("target").split(",")||Array(b),e=0;$.each(c,function(a,b){var f=d[d.length&&e];$(f).toggleClass(c[a]),e++}),b.toggleClass("active")}),$(document).on("click","[data-toggle-class]",function(a){a.preventDefault();var b=$(this),c=b.data("toggle-class"),d={};$.each(c.split(","),function(){var a=$.trim(this);if(a){var b=a.split("="),c=b[0],e=b[1];d[c]=e}}),$.each(d,function(a,b){$(a).toggleClass(b)})});var b;$(document).on("click","[ui-nav] a .parent_name",function(a){var b=document.createElement("a");b.setAttribute("href",$(this).parent("a").attr("href")),document.body.appendChild(b),b.click()}),$(document).on("click","[ui-nav] a,[ui-nav-fold] a",function(a){b&&b.trigger("mouseleave.nav");var c=$(this);if(c.parent().siblings(".active").toggleClass("active"),c.next().is("ul")&&c.parent().toggleClass("active")&&a.preventDefault(),$(".app-aside-fix").length>0&&$(window).width()>768){var d,c=$(a.target),e=$(window).height();c.is("a")&&c.next().is(".child-nav")&&(b=c.parent().parent()),$(".app-aside-folded").length&&b&&(d=b.position().top,d+b.height()>=e&&b.css("bottom","50px"),d+150>e&&b.css("bottom",e-d-50).css("top","auto")),$(".app-aside-dock").length&&$(window).width()>991&&(console.log("重新计算:click"),console.log("height:"+b.height()+"w_h:"+e+"end:"+(e-115)),120+b.height()>=e?(console.log("height:"+b.height()+"w_h:"+e+"end:"+(e-115)),b.height(e-120)):(console.log("height:"+b.height()+"w_h:"+e+"end:"+(e-115)),b.css("height","auto")))}c.next().is("ul")||$(window).width()<768&&$(".off-screen").removeClass("show off-screen")});var c=!0;$(document).on("mouseenter","[ui-nav] a",function(a){if($(document).on("mouseenter",".app-aside>ul.nav",function(a){c=!0}),$(document).on("mouseleave",".app-aside>ul.nav",function(a){c=!1}),b&&b.trigger("mouseleave.nav"),$("> .nav",$(".app-aside")).remove(),$(".app-aside-fix").length&&!($(window).width()<768)){var d,e=$(a.target),f=$(window).height();!e.is("a")&&(e=e.closest("a")),e.next().is("ul")&&(b=e.next(),$(".app-aside-folded").length&&(e.parent().addClass("active"),b.appendTo(".app-aside"),d=e.parent().position().top,b.css("top",d),b.attr("ui-nav-fold",""),d+b.height()>f&&b.css("bottom","50px"),d+150>f&&b.css("bottom",f-d-50).css("top","auto"),b.on("mouseleave.nav",function(a){c||(b.appendTo(e.parent()),b.off("mouseleave.nav").css("top","auto").css("bottom","auto"),e.parent().removeClass("active"),c=!1)}),$(".smart").length&&$('<div class="dropdown-backdrop"/>').insertAfter(".app-aside").on("click",function(a){a&&a.trigger("mouseleave.nav")})),$(".app-aside-dock").length&&$(window).width()>991&&(console.log("重新计算:hover"),console.log("height:"+b.height()+"w_h:"+f+"end:"+(f-120)),120+b.height()>=f?(console.log("height:"+b.height()+"w_h:"+f+"end:"+(f-120)),b.height(f-120)):(console.log("height:"+b.height()+"w_h:"+f+"end:"+(f-120)),b.css("height","auto"))))}}),$(document).on("mouseleave",".app-aside:not(.app-aside-dock)",function(a){c=!1,b&&b.trigger("mouseleave.nav"),$("> .nav",$(".app-aside")).remove()}),(!!navigator.userAgent.match(/MSIE/i)||!!navigator.userAgent.match(/Trident.*rv:11\./))&&$("html").addClass("ie")},searchTips:function(){this.searchInput(),$(document).on("click",function(a){"search_input"!==a.target.getAttribute("id")&&"search_tips_drop"!==a.target.getAttribute("id")&&$("#search_tips_drop").addClass("hide")})},searchInput:function(){var a=!1;$("#search_input").on("compositionstart",function(){a=!0}),$("#search_input").on("compositionend",function(){a=!1});var b=null,c=null;$("#search_input").on("input",function(){setTimeout(function(){a||(null!==c&&clearTimeout(c),c=setTimeout(function(){var a=$("#search_input").val();if(""!==a.trim()){$("#spin-search").addClass("show inline"),$("#icon-search").addClass("hide"),null!==b&&(b.abort(),b=null),b=$.getJSON("?action=ajax_search&content="+a,function(a){$("#search_tips_drop").text(""),$("#search_tips_drop").removeClass("hide"),$(a.results).appendTo("#search_tips_drop"),$("#spin-search").removeClass("show inline"),$("#icon-search").removeClass("hide"),b=null})}else $("#search_tips_drop").text(""),$("#search_tips_drop").addClass("hide");-1!=$("#search_input").val().indexOf("自杀")&&$.message({message:"含有您正在搜索的字词或标签的信息,通常会鼓吹可能造成伤害甚至导致死亡的行为。如果您目前遭遇难关,我们非常乐意<a href='https://www.baidu.com/s?wd=%E8%87%AA%E6%9D%80'>伸出援手</a>。",title:"需要协助吗?",type:"warning",autoHide:!1,time:"30000"})},150))},0)}),$("#searchform1").submit(function(){var a=LocalConst.BLOG_URL_PHP+"search/"+$(this).find("input").val();handsome_core.onlyPjax.pjax_click();try{$.pjax.submit(event,"#content",{url:a,fragment:"#content",timeout:6e3})}catch(a){}})}},handsome_comment={init:function(){this.initAndPjax_Complete()},pjax_complete:function(){this.initAndPjax_Complete()},initAndPjax_Complete:function(){LocalConst.COMMENT_SYSTEM===LocalConst.COMMENT_SYSTEM_ROOT?(this.loadCommentEmoji(),this.placeholderChange(),this.secretComment(),this.watchInputInComment()):LocalConst.COMMENT_SYSTEM===LocalConst.COMMENT_SYSTEM_CHANGYAN&&this.loadChangYan(),LocalConst.IS_PAJX_COMMENT?this.ajaxComment():this.noAjaxComment(),"function"==typeof registCommentEvent&®istCommentEvent()},placeholderChange:function(){$(function(){$("#comment").blur(function(){$(this).attr("placeholder",LocalConst.COMMENT_REJECT_PLACEHOLDER)}),$("#comment").focus(function(){$(this).attr("placeholder",LocalConst.COMMENT_PLACEHOLDER)})})},loadCommentEmoji:function(){var a=document.getElementsByClassName("OwO")[0],b=document.getElementsByClassName("OwO-textarea")[0];if(void 0!=a&&void 0!=b){new OwO({logo:LocalConst.EMOJI,container:a,target:b,api:LocalConst.BASE_SCRIPT_URL+"usr/OwO.json?v="+LocalConst.THEME_VERSION,position:"down",width:"100%",maxHeight:"220px"})}},loadChangYan:function(){window.changyan=void 0,window.cyan=void 0,1==$("#SOHUCS").length&&($("#spin_comment_changyan").addClass("show inline"),$.getScript("https://changyan.sohu.com/upload/changyan.js",function(){window.changyan.api.config({appid:LocalConst.ChANGYAN_APP_KEY,conf:LocalConst.CHANGYAN_CONF}),$("#spin_comment_changyan").removeClass("show inline")}))},ajaxComment:function(){function a(){$("#submit span:first-child").text("附言"),$("#time_toolbar").addClass("hide"),$("#submit").addClass("padder-v-none"),$("#comment_form").addClass("time_reply_comment"),$(".comment-respond").hasClass("hide")&&($(".comment-respond").removeClass("hide"),$(".comment-respond").addClass("hide_guest"))}function b(){$("#comment_form").removeClass("time_reply_comment"),$("#submit").removeClass("padder-v-none"),$("#time_toolbar").removeClass("hide"),$("#submit span:first-child").text("发表新鲜事"),$(".comment-respond").hasClass("hide_guest")&&$(".comment-respond").addClass("hide")}function c(){$(g+" a").click(function(){$(".time-machine").length>0?(k=$(this).parent().parent().parent().parent().parent().attr("id"),a()):k=$(this).parent().parent().parent().parent().attr("id"),$(h).focus()}),$("#cancel-comment-reply-link").click(function(){$(".time-machine").length>0&&b(),k=""})}function d(a){$(i).attr("disabled",!1).fadeTo("",1)}var e=window.opera?"CSS1Compat"==document.compatMode?$("html"):$("body"):$("html,body"),f="#comments .comments-title",g=".comment-reply",h="#comment",i="#submit",j="",k="";$(".time-machine").length>0&&(g=".comment-time-reply"),c(),$("#comment_form").submit(function(){if($(i).attr("disabled",!0).fadeTo("slow",.5),$("#comment_form").find("#author")[0]){if(""==$("#comment_form").find("#author").val())return $.message({title:LocalConst.COMMENT_TITLE,message:LocalConst.COMMENT_NAME_INFO,type:"warning"}),d("#error"),!1;if(""==$("#comment_form").find("#mail").val()&&"1"===LocalConst.COMMENT_NEED_EMAIL)return $.message({title:LocalConst.COMMENT_TITLE,message:LocalConst.COMMENT_EMAIL_INFO,type:"warning"}),d("#error"),!1;if(!/^[^@\s<&>]+@([a-z0-9]+\.)+[a-z]{2,4}$/i.test($("#comment_form").find("#mail").val())&&"1"===LocalConst.COMMENT_NEED_EMAIL)return $.message({title:LocalConst.COMMENT_TITLE,message:LocalConst.COMMENT_EMAIL_LEGAL_INFO,type:"warning"}),d("#error"),!1}var a=$("#comment_form").find(h).val().replace(/(^\s*)|(\s*$)/g,"");if(null==a||""===a)return $.message({title:LocalConst.COMMENT_TITLE,message:LocalConst.COMMENT_CONTENT_INFO,type:"warning"}),d("#error"),!1;var l=$(this).serializeArray();return $(".time-machine").length>0&&l.length<=9&&!LocalConst.USER_LOGIN?void $.message({title:"没有权限",message:"您没有权限在时光机页面发送说说",type:"error"}):($("#secret_comment_checkbox").is(":checked")&&(l[1].value="[secret] "+l[1].value+"\n[/secret]"),$(i).addClass("active"),$("#spin").addClass("show inline"),$.ajax({url:$(this).attr("action"),type:$(this).attr("method"),data:l,error:function(){return $.message({title:LocalConst.COMMENT_TITLE,message:"评论失败,检查网络问题",type:"warning"}),$(i).removeClass("active"),$("#spin").removeClass("show inline"),d("#error"),!1},success:function(a){$(i).removeClass("active"),$("#spin").removeClass("show inline");try{if(!$(".comment-list",a).length){var l="";return[/<div class="container">([\s\S]*)<\/div>/,/Typecho_Widget_Exception:(.*?) in/].some(function(b,c,d){var e=b.exec(a);if(null!=e)return l=e[1].trim(),!0}),""===l&&(l=LocalConst.COMMENT_CONTENT_LEGAL_INFO),$.message({title:LocalConst.COMMENT_TITLE,message:l,type:"warning"}),$(i).removeClass("active"),$("#spin").removeClass("show inline"),d("#error"),!1}if(j=$(".comment-list",a).html().match(/id=\"?comment-\d+/g).join().match(/\d+/g).sort(function(a,b){return a-b}).pop(),$(".page-navigator .prev").length&&""==k)j="";else if($(".comment-list").length>0){const m=$(".comment-list").html().match(/id=\"?comment-\d+/g).join().match(/\d+/g).sort(function(a,b){return a-b}).pop();if(m===j)return j="",$.message({title:LocalConst.COMMENT_TITLE,message:LocalConst.COMMENT_CONTENT_CHECK_INFO,type:"warning"}),TypechoComment.cancelReply(),$(h).val(""),d("#error"),!1}d("#success"),k?(a=$("#comment-"+j,a).hide(),$("#"+k).find(".comment-children").length<=0&&($(".time-machine").length>0?$("#"+k+" .time-machine .panel-footer").append("<div class='comment-children text-muted'><ol class='comment-list'></ol></div>"):$("#"+k).append("<div class='comment-children list-unstyled m-l-xxl'><ol class='comment-list'></ol></div>")),j&&$("#"+k+" .comment-children .comment-list").prepend(a),k=""):(a=$("#comment-"+j,a).hide(),$(".time-machine").length>0?$(".comment-list").prepend(a):($(".comment-list").length||$("#comments").prepend('<h4 class="comments-title m-t-lg m-b special"> 0 条评论</h4><ol class="comment-list"></ol>'),$(".comment-list").prepend(a))),$("#comment-"+j).fadeIn();var n;$(f).length&&(n=parseInt($(f).text().match(/\d+/)),$(f).html($(f).html().replace(n,n+1))),TypechoComment.cancelReply(),$(h).val(""),$(g+" a, #cancel-comment-reply-link").unbind("click"),c(),$(i).attr("disabled",!1).fadeTo("slow",1),j?e.animate({scrollTop:$("#comment-"+j).offset().top-LocalConst.OFF_SCROLL_HEIGHT},500):e.animate({scrollTop:$("#comments").offset().top-LocalConst.OFF_SCROLL_HEIGHT},500),$(".time-machine").length>0&&b(),feather&&feather.replace(),handsome_content.md_parse_after("comments")}catch(a){window.location.reload()}}}),!1)})},noAjaxComment:function(){$("#submit").bind("click",function(){var a=$("#author").val(),b=$("#mail").val();return""===$("#comment").val()?($.message({title:LocalConst.COMMENT_TITLE,message:LocalConst.COMMENT_CONTENT_INFO,type:"warning"}),$("#comment").focus(),!1):""===a?($.message({title:LocalConst.COMMENT_TITLE,message:LocalConst.COMMENT_NAME_INFO,type:"warning"}),$("#author").focus(),!1):""===b&&"1"===LocalConst.COMMENT_NEED_EMAIL?($.message({title:LocalConst.COMMENT_TITLE,message:LocalConst.COMMENT_EMAIL_INFO,type:"warning"}),$("#mail").focus(),!1):($(this).addClass("active"),$("#spin").addClass("show inline"),void $("#comment_form").submit())})},secretComment:function(){$("#secret_comment_checkbox").change(function(){$(this).is(":checked")?($("#comment").addClass("secret_comment_textarea"),$(this).attr("placeholder","")):$("#comment").removeClass("secret_comment_textarea")})},watchInputInComment:function(){$('input[name = "mail"]').blur(function(){var a=$(this).val();return""!=a&&$.ajax({type:"GET",data:{action:"ajax_avatar_get",form:LocalConst.BLOG_URL,email:a},success:function(a){$(".author-avatar").attr("src",a)}}),!1})}},handsome_enhance={init:function(){this.statisticPane(),this.skPlayer(),this.initAndPjax_Complete()},pjax_complete:function(){this.initAndPjax_Complete(),"water_fall"===LocalConst.THUMB_STYLE&&this.initWaterFall()},initAndPjax_Complete:function(){this.mobile_right(),this.feather(),this.plusFont(),this.showShareImg(),this.bindInsertMediumButton(),this.bindShowDiv()},feather:function(){feather.replace({width:"16px",height:"16px"})},statisticPane:function(){$("#statistic_pane").on("click",function(){"true"!==$("#statistic_pane").attr("data-status")&&(Number(window.innerWidth)<767&&$("#statistic_pane ~ .dropdown-menu .info-icons").addClass("hide"),handsome_util.addScript("https://cdn.jsdelivr.net/npm/vditor@3.2.9/dist/js/echarts/echarts.min.js","echarts_js",function(){$.getJSON("?action=get_statistic&size="+window.innerWidth,function(a){handsome_enhance.showTheEChart(a),$("#statistic_pane").attr("data-status","true")}).fail(function(){handsome_util.adminAlert("请求失败,可能原因;1. 未在Handsome插件构建搜索索引 2. 伪静态设置错误")})}))})},mobile_right:function(){$(".off-screen-toggle").click(function(){$("#aside").toggleClass("off-screen")})},showTheEChart:function(a){$(".loading-echart").addClass("hide"),$(".top-echart").removeClass("hide");const b=echarts.init(document.getElementById("post-calendar"),handsome_UI.mode),c=echarts.init(document.getElementById("posts-chart"),handsome_UI.mode),d=echarts.init(document.getElementById("categories-chart"),handsome_UI.mode),e=echarts.init(document.getElementById("tags-chart"),handsome_UI.mode),f=echarts.init(document.getElementById("category-radar"),handsome_UI.mode);var g,h,i,j;"light"===handsome_UI.mode?(g=["#ebedf0","#c6e48b","#7bc96f","#239a3b","#196127"],h="#fff",i="#3C4858",j="#f9f9f9"):(g=["#ebedf0","#c6e48b","#7bc96f","#239a3b","#196127"],h="#000",i="#fff",j="#212121");const k={backgroundColor:j,tooltip:{padding:10,backgroundColor:"#555",borderColor:"#777",borderWidth:1,formatter:function(a){var b=a.value;return'<div style="font-size: 14px;">'+b[0]+":"+b[1]+"</div>"}},visualMap:{show:!1,showLabel:!0,min:0,max:a.post_calendar.max,calculable:!1,inRange:{symbol:"rect",color:g},itemWidth:12,itemHeight:12,orient:"horizontal",left:"center",top:0},calendar:[{top:50,left:"center",range:a.post_calendar.range,cellSize:[13,13],splitLine:{show:!1},name:{textStyle:{color:i}},itemStyle:{borderColor:h,borderWidth:2},yearLabel:{show:!1},monthLabel:{nameMap:"cn",fontSize:11,color:i},dayLabel:{formatter:"{start} 1st",nameMap:"cn",fontSize:11,color:i}}],series:[{type:"heatmap",coordinateSystem:"calendar",calendarIndex:0,data:a.post_calendar.series}]},l={backgroundColor:j,tooltip:{},radar:{top:0,name:{textStyle:{color:i}},indicator:a.category_radar.indicator,center:["50%","55%"],radius:"66%"},series:[{type:"radar",color:["#3ecf8e"],itemStyle:{normal:{areaStyle:{type:"default"}}},data:[{value:a.category_radar.series,name:"文章分类数量"}]}]},m={backgroundColor:j,tooltip:{trigger:"axis"},xAxis:{type:"category",data:a.post_chart.xAxis},yAxis:{type:"value"},series:[{name:"文章篇数",type:"line",color:["#6772e5"],data:a.post_chart.series,markPoint:{symbolSize:45,color:["#fa755a","#3ecf8e","#82d3f4"],data:[{type:"max",itemStyle:{color:["#3ecf8e"]},name:"最大值"},{type:"min",itemStyle:{color:["#fa755a"]},name:"最小值"}]},markLine:{itemStyle:{color:["#ab47bc"]},data:[{type:"average",name:"平均值"}]}}]},n={backgroundColor:j,tooltip:{trigger:"item",formatter:"{a} <br/>{b} : {c} ({d}%)"},pie:{top:0},series:[{name:"分类",type:"pie",radius:"50%",color:a.categories_chart.color,data:a.categories_chart.indicator,itemStyle:{emphasis:{shadowBlur:10,shadowOffsetX:0,shadowColor:"rgba(0, 0, 0, 0.5)"}}}]},o={backgroundColor:j,tooltip:{},xAxis:[{type:"category",data:a.tags_chart.indicator}],yAxis:[{type:"value"}],series:[{type:"bar",color:["#82d3f4"],barWidth:18,data:a.tags_chart.series,markPoint:{symbolSize:45,data:[{type:"max",itemStyle:{color:["#3ecf8e"]},name:"最大值"},{type:"min",itemStyle:{color:["#fa755a"]},name:"最小值"}]},markLine:{itemStyle:{color:["#ab47bc"]},data:[{type:"average",name:"平均值"}]}}]};b.setOption(k),c.setOption(m),d.setOption(n),e.setOption(o),f.setOption(l)},skPlayer:function(){$(".skPlayer-list-switch").bind("click",function(){player.toggleList()})},reInitAPlayer:function(){$(".aplayer").length<=0||loadMeting()},plusFont:function(){$(".plus-font-size").click(function(){var a=$("#post-content").css("font-size"),b=parseFloat(a,10);a.slice(-2);b<=14?b+=2:b-=2,$("#post-content").css("font-size",b+"px")})},showShareImg:function(){$("#generateShareImg").click(function(){$.message({title:LocalConst.OPERATION_NOTICE,message:LocalConst.SCREENSHOT_BEGIN,type:"info",autoClose:!1}),html2canvas(document.getElementById("mdx-share-img"),{allowTaint:!0,useCORS:!0,scale:3,onrendered:function(a){try{var b=new Image;b.setAttribute("crossOrigin","Anonymous");var c=a.toDataURL("image/png");b.src=c,$.message({title:LocalConst.OPERATION_NOTICE,message:LocalConst.SCREENSHORT_SUCCESS,type:"success"}),$.fancybox.open([{src:c,opts:{caption:LocalConst.SCREENSHOT_NOTICE,thumb:c}}],{loop:!1})}catch(a){$.message({title:LocalConst.OPERATION_NOTICE,message:LocalConst.SCREENSHORT_ERROR,type:"error"})}}})})},bindInsertMediumButton:function(){var a=document.getElementById("comment");$("#imageInsertOk").bind("click",function(){var b=$("input[ name='imageInsertModal']").val();b='<img src="'+b+'">',handsome_enhance.insertContentInText(a,b,"#imageInsertModal")}),$("#videoInsertOk").bind("click",function(){var b=$("input[ name='videoInsertModal']").val();b='[vplayer url="'+b+'" /]\n',handsome_enhance.insertContentInText(a,b,"#videoInsertModal")}),$("#musicInsertOk").bind("click",function(){var b=$("input[ name='musicInsertModal']").val();$.ajax({type:"POST",url:LocalConst.BASE_SCRIPT_URL+"libs/interface/Get.php",data:{data:b,size:"small"},async:!1,success:function(c){b=c,handsome_enhance.insertContentInText(a,b,"#musicInsertModal")}})})},insertContentInText:function(a,b,c){if($(c).modal("hide"),document.selection){a.focus();document.selection.createRange().text=b,a.focus()}else if(a.selectionStart||"0"==a.selectionStart){var d=a.selectionStart,e=a.selectionEnd,f=d;a.value=a.value.substring(0,d)+b+a.value.substring(e,a.value.length),f+=b.length,a.selectionStart=f,a.selectionEnd=f,a.focus()}else a.value+=b,a.focus()},bindShowDiv:function(){$(".show_hide_div").bind("click",function(){$("#author_info").toggleClass("hide")})},initWaterFall:function(){if($(".water-fall-container").length>0){var a=Macy({container:".water-fall-container",trueOrder:!1,margin:24,columns:3,breakAt:{1500:3,1100:2,940:2,520:1,400:1},useContainerForBreakpoints:!0});setTimeout(function(){console.log("recalculate"),a.recalculate()},0)}}},handsome_content={featherReplace:!1,postSingleParse:!1,allSingleParseFlag:!1,init:function(){this.initAndPjax_Complete()},pjax_complete:function(){this.featherReplace=!1,this.postSingleParse=!1,this.allSingleParseFlag=!1,window.removeEventListener("scroll",handsome_content.tocScrollEvent),this.initAndPjax_Complete()},initAndPjax_Complete:function(){window.speechSynthesis&&window.speechSynthesis.cancel(),setTimeout(function(){handsome_content.vditorInit()},0)},vditorInit:function(){handsome_content.parseContainer("md_handsome_origin","md_handsome","handsome_md_text"),handsome_content.readMode(),handsome_content.parseContainer("comments","","")},readMode:function(){if($("#morphing").length>0)try{$("[data-morphing]").fancyMorph({hash:"morphing"}),LocalConst.AUTO_READ_MODE&&$("#morphing").click()}catch(a){}},parseContainer:function(a,b,c){""!==b&&this.vditorParse(b,c),handsome_content.originParse(a)},highlight:function(a){if(LocalConst.THEME_HIGHLIGHT_CODE){var b=""===LocalConst.CODE_STYLE_LIGHT?"github":LocalConst.CODE_STYLE_LIGHT;"dark"===handsome_UI.mode&&(b=""===LocalConst.CODE_STYLE_DARK?"dracula":LocalConst.CODE_STYLE_DARK),!0===a?handsome_util.addOrReplaceStyle(LocalConst.VDITOR_CDN+"/dist/js/highlight.js/styles/"+b+".css","highlight_css"+b):(handsome_util.addStyle(LocalConst.VDITOR_CDN+"/dist/js/highlight.js/styles/"+b+".css","highlight_css_"+b),handsome_util.addStyle(LocalConst.VDITOR_CDN+"/dist/js/highlight.js/styles/"+b+".css","highlight__test_css_"+b)),handsome_util.addScript(LocalConst.VDITOR_CDN+"/dist/js/highlight.js/highlight.pack.js","highlight_js_",function(){$("pre code").each(function(a,b){$(this).addClass("hljs"),hljs.highlightBlock(b)})})}},allSingleParse:function(a){this.allSingleParseFlag||(this.allSingleParseFlag=!0,handsome_content.highlight(),LocalConst.THEME_MATHJAX&&"vditor"!==LocalConst.EDITOR_CHOICE&&handsome_util.addScript(LocalConst.MATHJAX_SVG_CDN,"mathjax_js",function(){MathJax.typeset()}))},originParse:function(a){$("#"+a).length>0&&"true"!==$("#"+a).attr("click_status")&&($("#"+a).attr("click_status","true"),handsome_content.md_parse_after(a),handsome_content.allSingleParse(a))},vditorParse:function(a,b){if($("#"+b).length>0&&"true"!==$("#"+b).attr("click_status")){$("#"+b).attr("click_status","true");var c=$("#"+b).text(),d=""===LocalConst.CODE_STYLE_LIGHT?"github":LocalConst.CODE_STYLE_LIGHT;"dark"===handsome_UI.mode&&(d=""===LocalConst.CODE_STYLE_DARK?"dracula":LocalConst.CODE_STYLE_DARK),Vditor.preview(document.getElementById(a),c,{theme:{current:null},speech:{enable:LocalConst.POST_SPEECH},hljs:{enable:LocalConst.THEME_HIGHLIGHT_CODE,lineNumber:!0,style:d},markdown:{sanitize:!1},anchor:0,math:{engine:"MathJax",macros:{bf:"{\\boldsymbol f}",bu:"{\\boldsymbol u}",bv:"{\\boldsymbol v}",bw:"{\\boldsymbol w}"},inlineDigit:!0},after:function(){b!==a&&$("#"+b).hide(),$("#"+a+" pre code").each(function(a,b){$(this).addClass("hljs")}),handsome_content.md_loading(a),handsome_content.md_parse_after(a)}})}},post_speech:function(a){if($(".speech-button").length>0){const b=new SpeechSynthesisUtterance($("#"+a).text());void 0!==speechSynthesis.onvoiceschanged&&(speechSynthesis.onvoiceschanged=handsome_content.getVoice());const c=handsome_content.getVoice();c?(b.voice=c,b.onend=function(){$(".speech-button").removeClass("speech-current"),speechSynthesis.cancel(),$(".speech-button").html(feather.icons["play-circle"].toSvg({width:"16px",height:"16px"}))},$(".speech-button").on("click",function(){$(this).hasClass("speech-current")?$(this).hasClass("paused")?(speechSynthesis.resume(),feather.icons.circle.toSvg(),$(".speech-button").html(feather.icons["pause-circle"].toSvg({width:"16px",height:"16px"})),$(this).removeClass("paused")):(speechSynthesis.pause(),$(".speech-button").html(feather.icons["play-circle"].toSvg({width:"16px",height:"16px"})),$(this).addClass("paused")):(speechSynthesis.speak(b),$(this).addClass("speech-current"),$(".speech-button").html(feather.icons["pause-circle"].toSvg({width:"16px",height:"16px"})))})):$(".speech-button").hide()}},getVoice:function(){const a="zh_CN",b=speechSynthesis.getVoices();var c,d;return b.forEach(function(b){b.lang===a.replace("_","-")&&b.localService&&(c=b),b.default&&(d=b)}),c||(c=d),c},urlOpen:function(a){a="comments"===a?".comment-content-true":"#"+a,$(a+" a:not(.light-link):not(.no-external-link)").each(function(){const a=$(this).attr("href");a&&(-1!==a.indexOf(LocalConst.BLOG_URL_N)||-1===a.indexOf("http")||($(this).attr("target","_blank"),$(this).append('<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-external-link"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>'),$(this).prop("outerHTML",'<span class="external-link">'+$(this).prop("outerHTML")+"</span>")))})},md_parse_after:function(a){handsome_content.reInitAPlayer(a),handsome_content.reInitDPlayer(a),handsome_content.table_wrap(a),handsome_content.setWechatAndio(a),handsome_content.setVideoTag(a),!this.featherReplace&&$("#md_handsome").length>0&&-1!==a.indexOf("md_handsome")&&(feather.replace(),this.featherReplace=!0),handsome_content.urlOpen(a),handsome_content.seFancyBox(a),this.postSingleParse||-1===a.indexOf("md_handsome")||(this.postSingleParse=!0,window.speechSynthesis?handsome_content.post_speech(a):$(".speech-button").hide(),$("#support_author").on("click",function(){$(".pay-img").each(function(){$(this).attr("src",$(this).attr("data-original"))})}),$("#morphing").on("click",function(){$(this).attr("click_status","true"),handsome_content.parseContainer("morphing-content-real_origin","morphing-content-real","morphing-content-real_text")}),LocalConst.THEME_TOC&&handsome_content.toc(a))},md_loading:function(a){$(".loading-post").addClass("hide"),$("#"+a).removeClass("hide")},table_wrap:function(a){$("#"+a).find("table").wrap("<div class='table-responsive box-shadow-wrap-lg'></div>")},setVideoTag:function(a){$("#"+a+" video").each(function(){$(this).hasClass("dplayer-video")||(void 0!==$(this).attr("controls")&&$(this).removeAttr("controls"),void 0===$(this).attr("preload")&&$(this).attr("preload","preload"),$(this).wrap('<div class="kyt-player"></div>'),$(this).parent().append('<div class="play-button"></div>'),$(this).on("loadedmetadata",function(){$(this).height("auto"),$(this).width("auto"),$(this).height()>$(this).width()?($(this).width("auto"),$(this).height("90vh")):$(this).width("100%"),$(this).parent(".kyt-player").height($(this).height()),$(this).parent(".kyt-player").css("width",$(this).width())}),$(this).bind("click",function(){console.log("video click"),$(this).next(".play-button").is(":hidden")&&($(this).next(".play-button").css("display","block"),$(this).removeAttr("controls"),$(this).get(0).pause())}))}),$(window).resize(function(){$(".kyt-player").each(function(){$(this).css("height",$(this).find("video")[0].offsetHeight)})}),$("#"+a).delegate(".play-button","click",function(a){$(this).prev("video").css("background-image","none"),$(this).parent(".kyt-player").css("height",$(this).prev("video").height()),$(this).parent(".kyt-player").css("width",$(this).prev("video").width()),$(this).is(":visible")&&($(this).css("display","none"),$(this).parent().children("video").attr("controls","controls"),$(this).parent().children("video")[0].play())})},setWechatAndio:function(a){$(".weixinAudio").each(function(){var a=$(this),b=a.children("audio"),c=a.find(".audio_title"),d=a.find(".audio_source"),e=a.children("input[ name='url']").attr("value");""!==e?$.ajax({type:"GET",url:e,error:function(a){},success:function(a){var e=$.parseJSON(a);b.children("source").attr("src",e.url),b.load(),c.text(e.name),d.text(e.author)}}):(b.attr("src",a.children("input[ name='mp3']").attr("value")),b.init(),c.text(a.children("input[ name='title']").attr("value")),d.text(a.children("input[ name='tips']").attr("value")))});var b=$(".weixinAudio").weixinAudio();$(".weixinAudio").on("click",function(a){var c=$(this),d=c.index(".weixinAudio");$.each(b,function(a,b){a!="weixinAudio"+d&&b.pause()})})},outlineRender:function(a,b,c){var d="";"children"in a&&($(a).children().each(function(a,b){if(b=$(this)[0],handsome_util.hasClosestByHeadings(b)){const e=parseInt(b.tagName.substring(1),10),f=handsome_util.repeatify(" ",e-1);var g="";g=c&&"ir"===c.currentMode?b.textContent.substring(e+1).trim():b.textContent.trim();const h=b.id.lastIndexOf("_"),i=b.id.substring(0,-1===h?void 0:h);b.id=i+"_"+a,d+='<div data-id="'+b.id+'" class="vditor-outline__item">'+f+g+"</div>"}}),b.innerHTML=d,b.querySelectorAll(".vditor-outline__item").forEach(function(a){a.addEventListener("click",function(c){const d=a.getAttribute("data-id");$("html,body").animate({scrollTop:document.getElementById(d).offsetTop-parseInt(LocalConst.OFF_SCROLL_HEIGHT)},300),b.querySelectorAll(".vditor-outline__item").forEach(function(a){a.classList.remove("vditor-outline__item--current")}),a.classList.add("vditor-outline__item--current")})}))},toc:function(a){const b=window.innerWidth<=992?"tocTree":"toc";if($("#"+b).length>0){const c=document.getElementById(b);c&&(handsome_content.outlineRender(document.getElementById(a),c),""!==c.innerText.trim()?(c.style.display="block",this.initOutline(a)):$("#tag_toc_body").hide())}},parsePhotos:function(a){$(handsome_util.getChildName(a,".album_block")).shortcode({album:function(){const a=/<img.*?src="(.*?)"(.*?)(alt="(.*?)")??(.*?)\/?>/g,b=/alt="(.*?)"/,c=this.options&&"photos"===this.options.type;var d,e=!1,f="";for(f+=c?"<div class='album-photos'>":"<div class='photos'>";null!==(d=a.exec(this.contents));){e||(e=!0);var g=b.exec(d[5]),h=null==g?"":g[1];c?(f+="<figure>"+d[0].toString()+"<figcaption>",f+=h.toString()+"</figcaption></figure>"):f+='<figure class="image-thumb" itemprop="associatedMedia" itemscope="" itemtype="http://schema.org/ImageObject">'+d[0]+'<figcaption itemprop="caption description">'+h+"</figcaption></figure>"}return e||(f='<small class="text-muted letterspacing indexWords">相册无图片</small>'),f+="</div>"}})},setPhotosAuto:function(a){$.each($(handsome_util.getChildName(a,".album-photos figure")),function(a,b){var c=new Image
|
||
;if("1"===LocalConst.LAZY_LOAD){const d=$(b).find("img").attr("data-src");c.src=d||$(b).find("img").attr("src")}else c.src=$(b).find("img").attr("src");c.onload=function(){var a=parseFloat(c.width),d=parseFloat(c.height);$(b).css("flex-grow",50*a/d),$(b).find("a").css("padding-top",d/a*100+"%")}})},setImageFancyBox:function(a){$.fancybox.defaults.hash=!1,$.fancybox.defaults.buttons=["zoom","download","thumbs","close"],$(handsome_util.getChildName(a,"img")).each(function(){var a=$(this);if(void 0!==a.attr("alt"))var b=a.attr("alt");else var b="";var c=a.parent("a"),d=typeof a.attr("noGallery"),e=typeof a.attr("noAlt"),f=typeof a.attr("imgBlur");if(void 0!==a.attr("max")&&a.wrap('<div class="max-img small-scroll-bar"></div>'),"undefined"===d&&c.size()<1){var g;g=void 0===this.getAttribute("data-original")||""===this.getAttribute("data-original")||null===this.getAttribute("data-original")?this.getAttribute("src"):this.getAttribute("data-original"),g=g.replace(/(.*?)[!|\?]\/.*/,"$1");var h=a.attr("class"),i="";void 0!==h&&-1!==h.indexOf("emotion")||((a.parent().hasClass("image-thumb")||LocalConst.SHOW_IMAGE_ALT&&"undefined"===e)&&(i='<figcaption class="post-img-figcaption">'+b+"</figcaption>"),a.addClass("block"));var j=a.prop("outerHTML");j+=i,"undefined"!==f?a.prop("outerHTML",'<a class="light-link img-blur" data-fancybox="gallery" style="background-image: url('+g+')" no-pjax data-type="image" data-caption="'+b+'" href="'+g+'">'+j+"</a>"):a.prop("outerHTML",'<a class="light-link" data-fancybox="gallery" no-pjax data-type="image" data-caption="'+b+'" href="'+g+'">'+j+"</a>")}})},seFancyBox:function(a){handsome_content.parsePhotos(a),handsome_content.setImageFancyBox(a),handsome_content.setPhotosAuto(a),"1"===LocalConst.LAZY_LOAD&&$(handsome_util.getChildName(a,"img")).lazyload({effect:"fadeIn",threshold:"200",vertical_only:!0})},reInitDPlayer:function(container){if(!("undefined"==typeof dPlayerOptions||"undefined"==typeof dPlayers||$(".dplayer").length<=0)){var regex=/<script>(dPlayerOptions.*?)<\/script>/,result=regex.exec($("#"+container).html());if(null!=result){const js=result[1].trim();eval(js)}for(var len=dPlayerOptions.length,i=0;i<len;i++)dPlayers[i]=new DPlayer({container:document.getElementById("player"+dPlayerOptions[i].id),element:document.getElementById("player"+dPlayerOptions[i].id),screenshot:!1,autoplay:dPlayerOptions[i].autoplay,video:dPlayerOptions[i].video,theme:dPlayerOptions[i].theme,danmaku:dPlayerOptions[i].danmaku})}},reInitAPlayer:function(a){$(handsome_util.getChildName(a,".aplayer")).length<=0||loadMeting()},tocScrollEvent:function(){var a=window.scrollY;window.innerWidth>992&&(startPos<0&&(startPos=Number($("#tag_toc").offset().top)-Number(parseInt(LocalConst.OFF_SCROLL_HEIGHT))),a>startPos?$("#tag_toc").addClass("fixed"):$("#tag_toc").removeClass("fixed"));var b=document.querySelector(".vditor-outline__item--current"),c=-1;if(a>toc[toc.length-1].offsetTop-LocalConst.OFF_SCROLL_HEIGHT-2)c=toc.length-1;else for(var d=0,e=toc.length;d<e;d++)if(a<toc[d].offsetTop-LocalConst.OFF_SCROLL_HEIGHT-2){c=d>0?d-1:0;break}-1!==c&&c!==currIndex&&(currIndex=c,b&&b.classList.remove("vditor-outline__item--current"),document.querySelector('div[data-id="'+toc[c].id+'"]')&&document.querySelector('div[data-id="'+toc[c].id+'"]').classList.add("vditor-outline__item--current"))},initOutline:function(a){var b=[];if(Array.from(document.getElementById(a).children).forEach(function(a){2===a.tagName.length&&"HR"!==a.tagName&&0===a.tagName.indexOf("H")&&b.push(a)}),b.length<=0)$("#tag_toc_body").hide();else{if(currIndex=-1,handsome_content.updateTocList(b),ResizeObserver){new ResizeObserver(function(a){handsome_content.updateTocList(b)}).observe(document.getElementById(a))}window.innerWidth>992&&($("#tag_toc").length>0&&(startPos=Number($("#tag_toc").offset().top)-Number(parseInt(LocalConst.OFF_SCROLL_HEIGHT)),$("#tag_toc").css("top",Number(parseInt(LocalConst.OFF_SCROLL_HEIGHT)))),$(".tocify-mobile-panel").hide()),window.addEventListener("scroll",handsome_content.tocScrollEvent)}},updateTocList:function(a){toc=[],a.forEach(function(a){toc.push({id:a.id,offsetTop:a.offsetTop,height:a.height})})}},handsome_pjax={init:function(){$(document).pjax&&$(document).pjax('a[href^="'+LocalConst.BLOG_URL_N+'"]:not(a[target="_blank"], a[no-pjax])',{container:"#content",fragment:"#content",timeout:8e3}).on("pjax:send",function(){}).on("pjax:click",function(){handsome_core.onlyPjax.pjax_click()}).on("pjax:complete",function(){handsome_core.onlyPjax.pjax_complete(),"1"===LocalConst.LAZY_LOAD&&("1"===LocalConst.PAGE_ANIMATE?$(".app-content-body").animateCss("fadeIn",function(){$(".lazy").lazyload({effect:"fadeIn",threshold:"500"})}):$(".lazy").lazyload({effect:"fadeIn",threshold:"500"}))}).on("pjax:end",function(){handsome_core.onlyPjax.pjax_end()})},pjax_click:function(){"default"===LocalConst.PJAX_ANIMATE&&$("#loading").removeClass("hide"),"default"!==LocalConst.PJAX_ANIMATE&&""!==LocalConst.PJAX_ANIMATE&&Pace.restart(),"0"===LocalConst.PJAX_TO_TOP&&$("body,html").animate({scrollTop:0},Number(LocalConst.TO_TOP_SPEED))},pjax_complete:function(){"default"!==LocalConst.PJAX_ANIMATE&&""!==LocalConst.PJAX_ANIMATE&&"whiteRound"!==LocalConst.PJAX_ANIMATE&&"customise"!==LocalConst.PJAX_ANIMATE||$("#loading").addClass("hide"),new Function(LocalConst.USER_COMPLETED.data)(),this.initAndPjax_Complete()},initAndPjax_Complete:function(){}},handsome_setting={init:function(){if(LocalConst.SHOW_SETTING_BUTTON){handsome_util.getPrefersDarkModeState(!1),$("body").on("click","#mode_set input",function(){"dark"===handsome_UI.mode?handsome_UI.mode="light":handsome_UI.mode="dark",handsome_content.highlight(!0)});var a={defaults:{"header-fixed":LocalConst.THEME_HEADER_FIX,"aside-fix":LocalConst.THEME_ASIDE_FIX,"aside-folded":LocalConst.THEME_ASIDE_FOLDED,"aside-dock":LocalConst.THEME_ASIDE_DOCK,"layout-boxed":LocalConst.THEME_CONTAINER_BOX,dark_mode:LocalConst.THEME_DARK_MODE,color:LocalConst.THEME_COLOR},sections:{settings:{"header-fixed":LocalConst.HEADER_FIX,"aside-fix":LocalConst.ASIDE_FIX,"aside-folded":LocalConst.ASIDE_FOLDED,"aside-dock":LocalConst.ASIDE_DOCK,"layout-boxed":LocalConst.CONTAINER_BOX,dark_mode:LocalConst.DARK_MODE},colors:[{navbarHeader:"bg-black",navbarCollapse:"bg-white-only",aside:"bg-black"},{navbarHeader:"bg-dark",navbarCollapse:"bg-white-only",aside:"bg-dark"},{navbarHeader:"bg-white-only",navbarCollapse:"bg-white-only",aside:"bg-black"},{navbarHeader:"bg-primary",navbarCollapse:"bg-white-only",aside:"bg-dark"},{navbarHeader:"bg-info",navbarCollapse:"bg-white-only",aside:"bg-black"},{navbarHeader:"bg-success",navbarCollapse:"bg-white-only",aside:"bg-dark"},{navbarHeader:"bg-danger",navbarCollapse:"bg-white-only",aside:"bg-dark"},{navbarHeader:"bg-black",navbarCollapse:"bg-black",aside:"bg-white"},{navbarHeader:"bg-dark",navbarCollapse:"bg-dark",aside:"bg-light"},{navbarHeader:"bg-info dker",navbarCollapse:"bg-info dker",aside:"bg-light dker"},{navbarHeader:"bg-primary",navbarCollapse:"bg-primary",aside:"bg-dark"},{navbarHeader:"bg-info dker",navbarCollapse:"bg-info dk",aside:"bg-black"},{navbarHeader:"bg-success",navbarCollapse:"bg-success",aside:"bg-dark"},{navbarHeader:"bg-danger",navbarCollapse:"bg-danger",aside:"bg-dark"}]},localStorageKey:"handsome_customizer_settings"};window.wp=window.wp||{},function(a){wp.template=_.memoize(function(b){var c,d={evaluate:/<#([\s\S]+?)#>/g,interpolate:/\{\{\{([\s\S]+?)\}\}\}/g,escape:/\{\{([^\}]+?)\}\}(?!\})/g,variable:"data"};return function(e){return(c=c||_.template(a("#tmpl-"+b).html(),d))(e)}})}(jQuery),function(a,b,c,d,e){"use strict";function f(){function c(){if(!r){if(""!==LocalConst.THEME_COLOR_EDIT){var b=LocalConst.THEME_COLOR_EDIT.split("-");d.sections.colors.push({navbarHeader:"bg-"+b[0],navbarCollapse:"bg-"+b[1],aside:"bg-"+b[2]})}r=!0,q=f().appendTo("body"),i(),a(".setting_body_panel i").tooltip(),feather.replace(),a(".setting_body_panel button").tooltip()}}function f(){var b={sections:d.sections,defaults:a.extend({},d.defaults,p())},c=wp.template("customizer"),e=c(b),e=a(e);return e.find(":input").change(g),e.find("[name=reset]").click(h),e}function g(){var b=a(this).attr("name"),c=m(b);j(b,c),p(b,c),"dark_mode"===b&&(a("#mode_set span").html(LocalConst.DARK_MODE_FIXED),a("#mode_set small").hide()),o("aside-fix")&&o("aside-dock")&&!o("header-fixed")&&(m("header-fixed",!0),j("header-fixed",!0),p("header-fixed",!0))}function h(){a.each(d.defaults,function(a,b){m(a,b),j(a,b)}),a("#mode_set span").html(LocalConst.DARK_MODE_AUTO),a("#mode_set small").show(),p(null,null)}function i(){a.each(o(),j)}function j(b,c){switch(b){case"header-fixed":case"aside-fix":case"aside-folded":case"aside-dock":case"layout-boxed":var d=(c?"add":"remove")+"Class",e=(c?"remove":"add")+"Class",f=a(".app");"layout-boxed"===b?(f[d]("container"),f[e]("no-container"),a("html")[d]("bg")):f[d]("app-"+b);break;case"color":k(c);break;case"dark_mode":"auto"!==c?("dark"!==c&&1!=c||handsome_UI.dark_mode(),"light"!==c&&0!=c||handsome_UI.light_mode()):"dark"===handsome_UI.mode?handsome_UI.dark_mode():"light"===handsome_UI.mode&&handsome_UI.light_mode()}}function k(a){l("#header > .navbar-header","navbarHeader",a),l("#header > .collapse","navbarCollapse",a),l("#aside","aside",a)}function l(b,c,e){for(var f=d.sections.colors,g=f[e],h=a(b),i=0;i<f.length;++i)h.removeClass(f[i][c]);h.addClass(g[c])}function m(b,c){var d;return q.find(":input").each(function(){var f,g=a(this);if(g.attr("name")===b){if(f=g.attr("type"),c===e)switch(f){case"checkbox":d=g.prop("checked");break;case"radio":if(!g.prop("checked"))return;d=g.val();break;default:d=g.val()}else switch(f){case"checkbox":"dark_mode"===b&&"auto"===c?(handsome_util.getPrefersDarkModeState(!0),g.prop("checked","dark"===handsome_UI.mode)):g.prop("checked",1==c||"dark"===c);break;case"radio":if(g.val()!=c)return;g.prop("checked",!0);break;default:g.val(c)}return!1}}),d!==e&&(d=n(b,d)),d}function n(b,c){switch(b){case"color":c=!a.isNumeric(c)||c<=0?0:c>d.sections.colors.length-1?d.sections.colors.length-1:parseInt(c);break;default:c=!!c}return c}function o(b){var c=a.extend({},d.defaults);return a.each(c,function(a){var b=m(a);b!==e&&(c[a]=b)}),b===e?c:c[b]}function p(b,c){var f,g=d.localStorageKey,h=s.getItem(g);return f=h?JSON.parse(h):{},b?c===e?f[b]:(null===c?delete f[b]:f[b]=c,a.isEmptyObject(f)?s.removeItem(g):s.setItem(g,JSON.stringify(f))):null===b&&null===c?s.removeItem(g):f}var q,r=!1,s=b.localStorage;return s&&a(c),{load:c,generateCustomizer:f,formChange:g,formResetDefaults:h,loadStyle:i,setStyle:j,setAllColor:k,setPartColor:l,formItem:m,sanitizeSetting:n,getCurrentSettings:o,saveSettings:p}}b.handsome=b.handsome||{},b.handsome.customizer=new f}(jQuery,window,document,a)}},pjax_complete:function(){this.initAndPjax_Complete()},initAndPjax_Complete:function(){}},handsome_UI={mode:"",darkMoonSystemSet:!1,init:function(){handsome_util.getPrefersDarkModeState(!1)?this.dark_mode():this.light_mode(),this.bindBackToTop(),this.initAndPjax_Complete(),window.addEventListener("unload",function(a){a.preventDefault(),a.returnValue="",window.speechSynthesis&&window.speechSynthesis.cancel()}),window.history&&window.history.pushState&&(window.onpopstate=function(){($("#morphing").length<0||"true"!==$("#morphing").attr("click_status"))&&(console.log("you are backing"),handsome_core.onlyPjax.pjax_complete())})},dark_mode:function(){handsome_UI.mode="dark",$("#navbar-brand-dark").length>0&&($("#navbar-brand-dark").removeClass("hide"),$("#navbar-brand-day").hide()),document.cookie="theme_dark=1;max-age=3600;path=/",handsome_util.addStyle(LocalConst.STATIC_PATH+"css/features/dark.min.css?v="+LocalConst.THEME_VERSION,"theme_dark_css"),$("html").hasClass("theme-dark")||$("html").addClass("theme-dark")},light_mode:function(){handsome_UI.mode="light",$("#navbar-brand-dark").length>0&&($("#navbar-brand-dark").addClass("hide"),$("#navbar-brand-day").show()),document.cookie="theme_dark=0;max-age=3600;path=/",$("html").removeClass("theme-dark")},pjax_click:function(){},pjax_complete:function(){this.loginBan(),this.initAndPjax_Complete()},initAndPjax_Complete:function(){$('[data-toggle="tooltip"]').tooltip(),this.anchorScroll()},bindBackToTop:function(){var a=$("#goToTop");$(a).click(function(){$("body,html").animate({scrollTop:0},600)}),$(window).scroll(function(){$(window).scrollTop()>200?a.removeClass("hide"):a.addClass("hide")})},loginBan:function(){$("#Login_form").hasClass("banLogin")||($("#Login_form").addClass("banLogin"),$("#navbar-login-user").attr("disabled","disabled"),$("#navbar-login-password").attr("disabled","disabled"))},skeleton:function(){$(".item-thumb").addClass("skeleton"),$(".index-post-title").addClass("skeleton"),$(".post-item-foot-icon").addClass("skeleton"),$(".post-summary").addClass("skeleton")},anchorScroll:function(){if(LocalConst.THEME_HEADER_FIX){$("#comments,#small_widgets,#post-content").delegate('a[href^=\\#][href!=\\#][data-toggle!="tab"]',"click",function(){var a=document.getElementById(this.hash.slice(1));if(a){var b=$(a).offset().top-LocalConst.OFF_SCROLL_HEIGHT;return $("html,body").animate({scrollTop:b},300),!1}});var a=decodeURIComponent(window.location.hash);window.location.hash.indexOf("#")>=0&&$(a).length&&setTimeout(function(){$("html,body").animate({scrollTop:$(a).offset().top-LocalConst.OFF_SCROLL_HEIGHT+"px"},400)},700)}}},handsome_util={init:function(){this.initAndPjax_Complete()},pjax_complete:function(){this.initAndPjax_Complete()},initAndPjax_Complete:function(){},addStyle:function(a,b){if(!document.getElementById(b)){const c=document.createElement("link");c.id=b,c.rel="stylesheet",c.type="text/css",c.href=a,document.getElementsByTagName("head")[0].appendChild(c)}},addOrReplaceStyle:function(a,b){if(document.getElementById(b)){const c=document.getElementById(b);c.parentElement.insertBefore(c,null)}else this.addStyle(a,b)},set_innner_html:function(a,b,c){var d=[],e=[],f=[],g=[],h=null,i="";if(null==h)h=a;else{if(void 0===c)return g[a+"_html"]=b,void window.setTimeout("set_innerHTML('"+a+"', global_lock_pool['"+a+"_html']);",10);if(h!=a)return g[a+"_html"]=b,void window.setTimeout("set_innerHTML('"+a+"', global_lock_pool['"+a+"_html'], "+c+");",10)}i="",document.write=function(a){i+=a},document.writeln=function(a){i+=a+"\n"},d=[];var j=[];b=b.split(/<\/script>/i);for(var k=0;k<b.length;k++)d[k]=b[k].replace(/<script[\s\S]*$/gi,""),j[k]={text:"",src:""},j[k].text=b[k].substr(d[k].length),j[k].src=j[k].text.substr(0,j[k].text.indexOf(">")+1),j[k].src=j[k].src.match(/src\s*=\s*(\"([^\"]*)\"|\'([^\']*)\'|([^\s]*)[\s>])/i),j[k].src?(j[k].src[2]?j[k].src=j[k].src[2]:j[k].src[3]?j[k].src=j[k].src[3]:j[k].src[4]?j[k].src=j[k].src[4]:j[k].src="",j[k].text=""):(j[k].src="",j[k].text=j[k].text.substr(j[k].text.indexOf(">")+1),j[k].text=j[k].text.replace(/^\s*<\!--\s*/g,""));var l;l=void 0===c?0:c;for(var m,n,o,k=0;k<j.length;k++){var p="document_buffer += global_html_pool["+k+"];\n";p+="document.getElementById('"+a+"').innerHTML = document_buffer;\n",m=document.createElement("script"),j[k].src?(m.src=j[k].src,void 0===f[m.src]?(f[m.src]=!0,l+=2e3):l+=10):(m.text=j[k].text,l+=10),m.defer=!0,m.type="text/javascript",m.id=function(){return"script_"+(new Date).getTime().toString(36)+Math.floor(1e8*Math.random()).toString(36)}(),e[m.id]=m,n=p,n+="document.getElementsByTagName('head').item(0)",n+=".appendChild(global_script_pool['"+m.id+"']);\n",window.setTimeout(n,l),o="document.getElementsByTagName('head').item(0)",o+=".removeChild(document.getElementById('"+m.id+"'));\n",o+="delete global_script_pool['"+m.id+"'];\n",window.setTimeout(o,l+1e4)}var q="if (document_buffer.match(/<\\/script>/i)) {\n";q+="set_innerHTML('"+a+"', document_buffer, "+l+");\n",q+="}\n",q+="else {\n",q+="document.getElementById('"+a+"').innerHTML = document_buffer;\n",q+="innerhtml_lock = null;\n",q+="}",window.setTimeout(q,l)},addScript:function(a,b,c){var d=$.Deferred();$.when(function(c){if(document.getElementById(b))return c.resolve(),!1;var d=document.createElement("script");return d.src=a,d.async=!0,document.head.appendChild(d),d.onload=function(){if(document.getElementById(b))return d.remove(),c.resolve(),!1;d.id=b,c.resolve()},c}(d)).done(function(){c()})},repeatify:function(a,b){for(var c=a,d=0;d<b;d++)c+=a;return c},addScriptList:function(a,b){var c=$.Deferred(),d=0;const e=a.length;$.when(function(b){return a.some(function(a,c){if(document.getElementById(a.id))return++d>=e&&(b.resolve(),!0);var f=document.createElement("script");f.src=a.path,f.async=!0,document.head.appendChild(f),f.onload=function(){if(document.getElementById(a.id))return f.remove(),!1;f.id=a.id,++d>=e&&b.resolve()}}),b}(c)).done(function(){b()})},getDeviceState:function(a){var b;return window.getComputedStyle?b=window.getComputedStyle(a).getPropertyValue("z-index"):a.currentStyle&&(b=a.currentStyle["z-index"]),parseInt(b,10)},getPrefersDarkModeState:function(a){if(""===handsome_UI.mode||a){var b=!1;if("auto"===LocalConst.THEME_DARK_MODE){if(window.matchMedia("(prefers-color-scheme: dark)").addListener(function(a){a.matches?handsome_UI.dark_mode():handsome_UI.light_mode()}),"time"===LocalConst.THEME_DARK_MODE_VALUE){const c=new Date;b=c.getHours()>=LocalConst.THEME_DARK_HOUR||c.getHours()<LocalConst.THEME_LIGHT_HOUR}else if("auto"===LocalConst.THEME_DARK_MODE_VALUE)b=window.matchMedia("(prefers-color-scheme: dark)").matches;else if("compatible"===LocalConst.THEME_DARK_MODE_VALUE)if(window.matchMedia("(prefers-color-scheme: light)").matches){const c=new Date;b=c.getHours()>=LocalConst.THEME_DARK_HOUR||c.getHours()<LocalConst.THEME_LIGHT_HOUR}else b=!0}else b="light"!==LocalConst.THEME_DARK_MODE;return handsome_UI.mode=b?"dark":"light",b}return"dark"===handsome_UI.mode},hasClosestByHeadings:function(a){const b=this.hasClosestByTag(a,"H");return!(!b||2!==b.tagName.length||"HR"===b.tagName)&&b},getChildName:function(a,b){return"#"+a+" "+b},hasClosestByTag:function(a,b){if(!a)return!1;3===a.nodeType&&(a=a.parentElement);for(var c=a,d=!1;c&&!d&&!c.classList.contains("vditor-reset");)0===c.nodeName.indexOf(b)?d=!0:c=c.parentElement;return d&&c},adminAlert:function(a){LocalConst.USER_LOGIN&&$.message({title:"主题提示(仅登录用户可见)",message:a,type:"warning",time:"30000"})}},handsome_core={init:function(){handsome_ajax.init(),handsome_basics.init(),handsome_comment.init(),handsome_enhance.init(),LocalConst.IS_PJAX&&handsome_pjax.init(),handsome_UI.init(),handsome_util.init(),handsome_content.init(),handsome_setting.init()},onlyPjax:{pjax_click:function(){handsome_pjax.pjax_click(),handsome_UI.pjax_click()},pjax_complete:function(){handsome_pjax.pjax_complete(),handsome_ajax.pjax_complete(),handsome_basics.pjax_complete(),handsome_comment.pjax_complete(),handsome_enhance.pjax_complete(),handsome_UI.pjax_complete(),handsome_util.pjax_complete(),handsome_content.pjax_complete(),handsome_setting.pjax_complete()},pjax_end:function(){}}};$(function(){handsome_core.init()}),console.log("\n %c handsome v"+LocalConst.THEME_VERSION_PRO+" Pro %c by友人C | www.ihewro.com","color:#444;background:#eee;padding:5px 0;","color:#eee;background:#444;padding:5px 0;"); |