function setCopyBtn(){$(".CopyToClipboard").each(function(){var e=new ZeroClipboard.Client;e.setHandCursor(!0),e.addEventListener("load",function(e){}),e.addEventListener("mouseOver",function(e){var t=e.movie.parentNode.parentNode.parentNode.parentNode.parentNode.nextSibling.innerHTML;t=t.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&"),e.setText(t)}),e.addEventListener("complete",function(e,t){alert("代码已经复制到你的剪贴板。")}),e.glue(this,this.parentNode)})}function computePos(){"object"==typeof toolBar&&(toolBar.setPosX(),toolBar.computePositon())}function getRecommendListUrl(){return null!==getRecommendListUrlArr?getRecommendListUrlArr:(getRecommendListUrlArr=[[],[]],$(".recommend-box div.recommend-item-box").each(function(e,t){if($(t).data("url")){var o=$(t).data("url").toLowerCase().split("://"),n=$(t).data("url").toLowerCase().split("article/details/");getRecommendListUrlArr[0].push(2==o.length?o[1]:o[0]),getRecommendListUrlArr[1].push(2==n.length?"article/details/"+n[1]:n[0])}}),getRecommendListUrlArr)}function baidudatatemp(e,t,o,n){var i="blog",a='博客';e.linkUrl.indexOf("download.csdn.net")>-1?(i="download",a='下载'):e.linkUrl.indexOf("edu.csdn.net")>-1&&(i="edu",a='课程');var s=highlight.map(function(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")});10==setBaiduJsCount&&(a=""),s="("+s.join("|")+")";var c=new RegExp(s,"gi"),r=/<[^>]*>/g,l=e["abstract"].replace(r,"").replace(c,"$1"),d=e.dispTime.replace(/^(\d*)-/,""),m=e.linkUrl,p=e.title.replace(r,"").replace(c,"$1"),u=m.split("?")[0].split("/").splice(-1)[0],h='"extra":"{\\"utm_medium\\":\\"distribute.'+baiduSearchChannel+".none-task-"+i+"-2~default~baidujs_"+baiduSearchType+"~default-"+t+"-"+u+"-blog-"+articleId+baiduSearchIdentification+'\\",\\"dist_request_id\\":\\"'+distRequestId+'\\",\\"parent_index\\":\\"'+o+'\\"}",',f='
\t
\t\t
\t\t\t
'+a+'\t\t\t\t \t\t\t\t\t
'+p+'
\t\t\t\t
\t\t\t
'+d+'
";return f}function showDownRecommend(e){var t=highlight.map(function(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")});t="("+t.join("|")+")";var o=new RegExp(t,"gi"),n=/<[^>]*>/g,i=e.linkUrl,a=e.title.replace(n,"").replace(o,"$1"),s='
相关资源:'+a+"
";$("#recommendDown").html(s)}function showResult(e,t){var o=[],n=recommendRegularDomainArr||["blog.csdn.net/.+/article/details/","download.csdn.net/download/","edu.csdn.net/course/detail/"],i=new RegExp(n.join("|"));if(!e||e.length<=0)return!1;if(e&&e.length>0){for(var a=0;a?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘',。、<\/em>"]/g,"").replace(/\s/g,"").toLowerCase();for(var a=0;a0)for(var c=[],a=0;a?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘',。、<\/em>"]/g,"").replace(/\s/g,"").toLowerCase();if(2==l.split("article/details/").length){var u=l.split("article/details/")[1];u.replace("/",""),d=u,u&&c.indexOf(u)===-1&&(c.push(u),m="article/details/"+u)}$.inArray(l.toLowerCase(),getRecommendListUrl()[0])==-1&&$.inArray(m.toLowerCase(),getRecommendListUrl()[1])==-1&&$.inArray(d,getRecommendListUrl()[1])==-1&&a<10&&p!==articleTitleContent&&t!==e[a].linkUrl&&o.push(e[a])}var h=$(".insert-baidu-box").children().not("script").not("dl"),f="",g=0,v=0,w=1;o=o.slice(0,setBaiduJsCount),(!baiduCount||baiduCount<=0)&&(baiduCount=2);for(var a=isBaiduPre?0:baiduCount;a0?2*baiduCount*v:0:2*baiduCount*v+baiduCount,x=$(".insert-baidu-box .recommend-item-box").eq(b),y=0;$(x).children().length&&$(x).find("a.tit").attr("data-report-click")&&(y=JSON.parse($(x).find("a.tit").attr("data-report-click")).index),f+=baidudatatemp(isBaiduPre?o[s]:o[s-baiduCount],isBaiduPre?a+s:s+v*baiduCount,y,w),w+=1}$(h[a]).length&&($(h[a]).after(f),v+=1),f="",g=v*baiduCount}if(g-1&&(t.splice(o,1),this.className=t.join(" ")),this},e.hasClass=function(e){return!!this.className.match(new RegExp("\\s*"+e+"\\s*"))},e},setMoviePath:function(e){this.moviePath=e},dispatch:function(e,t,o){var n=this.clients[e];n&&n.receiveEvent(t,o)},register:function(e,t){this.clients[e]=t},getDOMObjectPosition:function(e,t){for(var o={left:0,top:0,width:e.width?e.width:e.offsetWidth,height:e.height?e.height:e.offsetHeight};e&&e!=t;)o.left+=e.offsetLeft,o.top+=e.offsetTop,e=e.offsetParent;return o},Client:function(e){this.handlers={},this.id=ZeroClipboard.nextId++,this.movieId="ZeroClipboardMovie_"+this.id,ZeroClipboard.register(this.id,this),e&&this.glue(e)}};ZeroClipboard.Client.prototype={id:0,ready:!1,movie:null,clipText:"",handCursorEnabled:!0,cssEffects:!0,handlers:null,glue:function(e,t,o){this.domElement=ZeroClipboard.$(e);var n=99;this.domElement.style.zIndex&&(n=parseInt(this.domElement.style.zIndex,10)+1),"string"==typeof t?t=ZeroClipboard.$(t):"undefined"==typeof t&&(t=document.getElementsByTagName("body")[0]);var i=ZeroClipboard.getDOMObjectPosition(this.domElement,t);this.div=document.createElement("div");var a=this.div.style;if(a.position="absolute",a.left=""+i.left+"px",a.top=""+i.top+"px",a.width=""+i.width+"px",a.height=""+i.height+"px",a.zIndex=n,"object"==typeof o)for(addedStyle in o)a[addedStyle]=o[addedStyle];t.appendChild(this.div),this.div.innerHTML=this.getHTML(i.width,i.height)},getHTML:function(e,t){var o="",n="id="+this.id+"&width="+e+"&height="+t;if(navigator.userAgent.match(/MSIE/)){var i=location.href.match(/^https/i)?"https://":"http://";o+=''}else o+='';return o},hide:function(){this.div&&(this.div.style.left="-2000px")},show:function(){this.reposition()},destroy:function(){if(this.domElement&&this.div){this.hide(),this.div.innerHTML="";var e=document.getElementsByTagName("body")[0];try{e.removeChild(this.div)}catch(t){}this.domElement=null,this.div=null}},reposition:function(e){if(e&&(this.domElement=ZeroClipboard.$(e),this.domElement||this.hide()),this.domElement&&this.div){var t=ZeroClipboard.getDOMObjectPosition(this.domElement),o=this.div.style;o.left=""+t.left+"px",o.top=""+t.top+"px"}},setText:function(e){this.clipText=e,this.ready&&this.movie.setText(e)},addEventListener:function(e,t){e=e.toString().toLowerCase().replace(/^on/,""),this.handlers[e]||(this.handlers[e]=[]),this.handlers[e].push(t)},setHandCursor:function(e){this.handCursorEnabled=e,this.ready&&this.movie.setHandCursor(e)},setCSSEffects:function(e){this.cssEffects=!!e},receiveEvent:function(e,t){switch(e=e.toString().toLowerCase().replace(/^on/,"")){case"load":if(this.movie=document.getElementById(this.movieId),!this.movie){var o=this;return void setTimeout(function(){o.receiveEvent("load",null)},1)}if(!this.ready&&navigator.userAgent.match(/Firefox/)&&navigator.userAgent.match(/Windows/)){var o=this;return setTimeout(function(){o.receiveEvent("load",null)},100),void(this.ready=!0)}this.ready=!0,this.movie.setText(this.clipText),this.movie.setHandCursor(this.handCursorEnabled);break;case"mouseover":this.domElement&&this.cssEffects&&(this.domElement.addClass("hover"),this.recoverActive&&this.domElement.addClass("active"));break;case"mouseout":this.domElement&&this.cssEffects&&(this.recoverActive=!1,this.domElement.hasClass("active")&&(this.domElement.removeClass("active"),this.recoverActive=!0),this.domElement.removeClass("hover"));break;case"mousedown":this.domElement&&this.cssEffects&&this.domElement.addClass("active");break;case"mouseup":this.domElement&&this.cssEffects&&(this.domElement.removeClass("active"),this.recoverActive=!1)}if(this.handlers[e])for(var n=0,i=this.handlers[e].length;n-1?e("body").css({overflow:"auto","margin-left":"0"}):e("body").css({overflow:"auto"}),e(".imgViewDom").fadeOut(300)}t=t?t:"#content_views";var n=e(t+" img:not(.contentImg-no-view)"),i=navigator.userAgent.toLowerCase();if(0===n.length)return!1;for(var a="",s=0;s'}if(0===e(".imgViewDom").length){e("body").append('
'+a+'
');var r=new Swiper(".imgViewDom .swiper",{autoplay:!1,loop:!1,mousewheel:!0,keyboard:!0,navigation:{nextEl:".swiper-button-next",prevEl:".swiper-button-prev"}});e(".imgViewDom a.close-btn").on("click",function(){o()}),e(document).keyup(function(t){if("none"!==e(".imgViewDom").css("display")){var n=t||event,i=n.which||n.keyCode;27==i&&o()}}),e(".imgViewDom").click(function(t){0===e(".imgViewDom>.swiper").has(t.target).length&&o()})}return r};window.CSDNviewImg=n,window.csdn=window.csdn||{},window.csdn.random_num=t}(jQuery),$(function(){function e(e){if(l&&c){var t=$(window).height(),o=$(document).scrollTop(),i=e.offset().top,a=e.height();io&&(n(e),c=!1)}}function t(e){return'
'+e.title+' '+e.titleRight+' '+e.topCenter+'
'+e.topRightNumber+' '+e.topRight+'
'+e.introTitle+'
'+e.intro+' '+e.buttonText+"
"}function o(o){if(o)var n={authorUserName:username,contentKey:articleTitle,pageSpm:JSON.parse(articleReport).spm,positions:542};else var n={authorUserName:username,contentKey:articleTitle,pageSpm:JSON.parse(articleReport).spm,positions:544};$.ajax({type:"GET",url:"https://kunpeng.csdn.net/ad/json/list",dataType:"json",data:n,xhrFields:{withCredentials:!0},success:function(n){200==n.code&&n.data.length?(l="articleContentAd",o?$("#content_views").append("
"+t(n.data[0])+"
"):$(i[Math.floor(a/2)]).after("
"+t(n.data[0])+"
"),r=n.data[0].exposureUrl,e($("#"+l))):l=""},error:function(e){l=""}})}function n(e){e.append('')}var i=$("#content_views").children(),a=i.length,s=$("#content_views").height(),c=!0,r="",l="";if(4===articleSource&&a>8&&s>300){var d=(null!=(_ref1=/(; )?(uuid_tt_dd|_javaeye_cookie_id_)=([^;]+)/.exec(window.document.cookie))?_ref1[3]:void 0)||"",m=d?d.substring(d.length-6)%16:0;o(m<=7)}$(document).on("scroll",function(){e($("#"+l))}),a>contentViewsCount&&s>contentViewsHeight}),$(function(){function e(e,t,o){clearTimeout(d),document.selection?l=document.selection.createRange().text:window.getSelection()&&(l=window.getSelection()),l=l.toString().replace(/\n/g,"").trim();var a=!0;if(""!=l){(l.length<=2||$.isNumeric(l)||null!==n(l)||null!==i(l))&&(a=!1);var s="//so.csdn.net/so/search?from=pc_blog_select&q="+encodeURIComponent(l.toString()),c='
'+(a?'搜索':"")+' 评论 笔记
';$("body").append(c),$(document).on("click","#articleSearchTip .article-search",function(){window.csdn&&window.csdn.report&&window.csdn.report.reportClick({spm:"1001.2101.3001.6607",extra:JSON.stringify({searchword:l.toString()})})}),window.csdn.report&&"function"==typeof window.csdn.report.reportView&&(window.csdn.report.reportView({spm:"1001.2101.3001.6607",extra:JSON.stringify({searchword:l.toString()})}),window.csdn.report.reportView({spm:"1001.2101.3001.6773"})),$("#articleSearchTip").css({top:o.pageY-t-8,left:e})}}function t(e){var t="";e.download_url&&(t='

下载

');var o='

'+e.format_path+'

已加入 GitHub加速计划 每天同步更新

收藏

'+t+'
'+e.description+'
'+e.language+'

'+e.star_count+'

'+e.fork_count+"

"+e.updated_at_format+"更新
";return o}function o(e,o,n){$.ajax({url:"https://gitcode.net/api/v4/project_card/base_info",type:"get",data:{url:e},xhrFields:{withCredentials:!1},success:function(i){200==i.status&&i.data&&!$.isEmptyObject(i.data)?($("body").append(t(i.data)),"none"===$(".git-hub-box").css("display")&&$(".git-hub-box").show(),m=e,$(".git-hub-box").css({top:o+"px",left:n+"px"}),window.csdn.report&&"function"==typeof window.csdn.report.reportClick&&window.csdn.report.reportView({spm:"3001.9232"}),$(".git-hub-box").click(function(e){window.csdn.report&&"function"==typeof window.csdn.report.reportClick&&window.csdn.report.reportClick({spm:"3001.9232"}),window.open(i.data.link)}),$("#git-hub-download").click(function(e){window.open(i.data.download_url)}),$(".git-hub-box").mouseleave(function(){$(".git-hub-box").hide(),u=!1}),$(".git-hub-box").mouseenter(function(){u=!0})):m=""},error:function(e){m=""}})}function n(e){var t="(https?|http|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]";return s=e.match(t),s}function i(e){var t=/[Γ∫∞​∀∈∋N∏∑ϕ⎡⎤⇒⇏⟹⇑⇓⇕⨿%†‡…⋯◯△▽⪇≦≰≨≯⋍≂≅≆∮]/g;return s=e.match(t),s}function a(e){var t=$("#commentQuote"),o=$("#pcCommentSideBox"),n=''+e+'';t.length?t.html(n):(o.prepend('
'+n+"
"),$("#commentSideBoxshadow").fadeIn()),$("input.bt-comment-show").trigger("click")}var c=0,r=0,l="",d=null;$("#content_views").mouseup(function(t){$(".article-search-tip").remove();var o=t.pageY-r,n=Math.min(t.pageX,c);return Math.abs(n)<=5&&Math.abs(o)<=5?(clearTimeout(d),!1):(o=o>0?o:0,clearTimeout(d),void(d=setTimeout(function(){e(n,o,t)},1e3)))}).mousedown(function(e){c=e.pageX,r=e.pageY,l="",$(".git-hub-box").hide(),$("#articleSearchTip").remove()});var m="",p=0,u=!1,h=null;$(document).on("mouseenter mouseleave","#article_content a",function(e){if("mouseenter"==e.type){var t=$(this).offset().top+20,n=$(this).offset().left;$(this).offset().top-p>246&&(t=$(this).offset().top-226),clearTimeout(h),$(this).attr("href").indexOf("github.com")==-1&&$(this).attr("href").indexOf("gitcode.net")==-1||(m!==$(this).attr("href")?($(".git-hub-box").length>=1&&$(".git-hub-box").remove(),o($(this).attr("href"),t,n)):($(".git-hub-box").show(),$(".git-hub-box").css({top:t+"px",left:n+"px"})))}else"mouseleave"==e.type&&(h=setTimeout(function(){u||$(".git-hub-box").hide()},300))}),$(window).scroll(function(){p=$(window).scrollTop()}),$(document).on("click",".article-href",function(e){var t=$(this).data("type");if(void 0!==t)switch(t){case"comment":if(getCookie("UserName"))if(l.toString().length){var o=$("#csdn-toolbar").height(),n=$(document).scrollTop();n<52&&(o=2*o),a(l.toString().replace(//g,">")),e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}else $("#articleSearchTip").remove(),showToast({text:"选中内容为空,请重新选中",bottom:"10%",zindex:9e3,speed:500,time:1500});else window.csdn.loginBox.show();break;case"cnote":if(getCookie("UserName"))if(l.toString().length){l=l.toString().replace(//g,">");var i=new Date,s=i.getMonth()+1,c=i.getDate(),r=i.getFullYear()+"年"+s+"月"+c+"日",d={noteTabName:"博客笔记",topicTitle:"博客摘录「 "+articleTitle+"」 "+r,content:articleDetailUrl?"文章来源:"+articleDetailUrl+"
":"",source:{hostname:"blog.csdn.net",url:articleDetailUrl,title:articleTitle,selection:l}};$.ajax({url:"https://note-ccloud.csdn.net/v1/community/content/sendNote",type:"post",contentType:"application/json",dataType:"json",data:JSON.stringify(d),xhrFields:{withCredentials:!0},success:function(e){},error:function(e){}});var m=articleTitle;articleTitle&&articleTitle.length>=80&&(m=articleTitle.slice(0,77)+"..."),blogApiAxios({article_id:"",title:"博客摘录「 "+m+"」"+r,description:"",content:"

"+l+"

\n",type:"original",status:2,read_type:"public",authorized_status:!1,check_original:!1,source:"pc_postedit",not_auto_saved:1,cover_type:1,vote_id:0,scheduled_time:0,is_new:1,tags:"笔记"}),e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}else $("#articleSearchTip").remove(),showToast({text:"选中内容为空,请重新选中",bottom:"10%",zindex:9e3,speed:500,time:1500});else window.csdn.loginBox.show()}}),$(document).on("click",".comment-quote-close",function(e){var t=$("#commentQuote");t.animate({height:0},300,function(){t.remove()})})}),window.apiOpenEditor=function(e){console.log(e,8886666),showToast({text:"请稍后再试",bottom:"10%",zindex:9e3,speed:500,time:2e3})},function(){function e(e){o.hasClass("no-login")||($("div.article_content").removeAttr("style"),0==$(".column-mask").length&&$(".hide-article-box").hide(),o.hasClass("fans_read_more")&&($("#btnAttent").hasClass("attented")||e.originalEvent&&($(".tool-attend").trigger("click"),window.csdn.report.reportClick({mod:"popu_376",spm:"1001.2101.3001.4248",extend1:"粉丝登录阅读更多"}))))}function t(t,o){var n=($(window).height(),$("div.article_content")),i=n.height();$("#btn-readmore").attr("height",o),i>2e3?(n.css({height:"2000px",overflow:"hidden"}),t.click(e)):t.parent().hide()}var o=$(".btn-readmore");o.length>0||$(".vip-mask").length>0?currentUserName?t(o,3):t(o,2):0==$(".column-mask").length&&$(".hide-article-box").addClass("hide-article-style");var n=window.location.hash,i=RegExp(/\#/);n.match(i)&&($(".btn-readmore").parent().hide(),$("div.article_content").removeAttr("style")),window.csdn=window.csdn?window.csdn:{},window.csdn.clearReadMoreBtn=e}(),$(function(){function e(e){e.list&&e.list.length&&($.each(e.list,function(e,t){var o="",n="";articleId==t.articleId&&(o="active"),t.preView&&(n='试读'),i.columnlistStr+='"}),e.total-e.page*e.size>0?(i.columnPage+=1,i.columnlistStr+='

查看更多

'):i.columnlistStr+='

暂无更多内容

',$(document).find(i.columnlistHeight).append(i.columnlistStr),i.columnlistStr="")}function t(e,t,o,n){$.ajax({type:"GET",url:blogUrl+e,dataType:"json",xhrFields:{withCredentials:!0},data:t,success:function(e){200==e.code&&o(e.data)},error:function(e){}})}function o(e,t){if(getCookie("UserName")){var o=blogUrl+"phoenix/web/v1/subscribe/subscribe";$.ajax({url:o,type:"post",dataType:"json",data:e,xhrFields:{withCredentials:!0},success:function(e){200===e.code&&(e.data.status&&showToast({text:e.data.msg,bottom:"10%",zindex:9003,speed:500,time:1500}),t.removeClass("articleColumnFreeBt").html("已订阅"))}})}else window.csdn.loginBox.show({spm:"1001.2101.3001.8607"})}function n(e,t,o){if($(document).find(e).length){var n=$(document).find(e).outerHeight(!0),i=$(document).find(t).outerHeight(!0),a=$(document).find(o).outerHeight(!0);$(document).find(o).css({height:n-i+a})}}var i={columnlistBox:"#columnlistBox",columnlistClose:".columnlist-close",columnlistContent:".columnlist-content-box",columnlistHeight:".columnlist-list-box",columnlistShow:$(".bt-columnlist-show"),columnlistShadow:$(".directory-boxshadow"),columnlistItem:$(".column-group"),columnlistUrl:"phoenix/web/v1/column/article-list",columnId:"",columnPage:1,columnlistStr:""};i.columnlistItem.on("click",function(e){$(this).children().length>1&&!$(e.target).is(".item-target")&&($(this).hasClass("open")?($(this).removeClass("open"),$(this).find(".dec").show()):($(this).addClass("open"),$(this).find(".dec").hide()))});var a="";studyLearnWord&&(a=''+studyLearnWord+""),i.columnlistShow.on("click",function(o){i.columnId=$(this).data("id");var s="",c="",r="",l="",d="",m="";isOwner||($(this).data("free")?s=$(this).data("subscribe")?'已订阅':'订阅专栏':($(this).data("join")?$(this).data("studyvip")?$(this).data("subscribe")?s='已订阅 8折续费 '+a+"":(s=' 会员已订阅 ',s+=' 会员免费订 ',s+=$(this).data("studysubscribe")?'8折续费 '+a+"":'8折续费 '+a+""):s=$(this).data("subscribe")?'已订阅 超级会员免费看 '+a+" ":'订阅专栏 超级会员免费看 '+a+" ":s=$(this).data("subscribe")?'已订阅':'订阅专栏', c='
¥'+$(this).data("price")+"
")),l='
'+$(this).data("sum")+" 篇文章 "+$(this).data("people")+" 订阅
",d='
作者:'+nickName+"
"+c+'
",m='
专栏目录
',r='
'+l+d+m+'
',$("body").append(r),i.columnlistShadow.fadeIn(function(){$("html,body").addClass("forbidden-htmlbody-scroll"),$(document).find(i.columnlistBox).addClass("open"),n(i.columnlistBox,i.columnlistContent,i.columnlistHeight)}),t(i.columnlistUrl,{columnId:i.columnId,page:i.columnPage},e,i.columnlistBox);var p=o||window.event;p.stopPropagation?p.stopPropagation():p.cancelBubble=!0}),i.columnlistShadow.click(function(){$(i.columnlistClose).trigger("click")}),$(document).on("click",i.columnlistClose,function(){$(document).find(i.columnlistBox).removeClass("open"),i.columnlistShadow.fadeOut(function(){$("html,body").removeClass("forbidden-htmlbody-scroll"),$(document).find(i.columnlistBox).remove(),i.columnPage=1,i.columnId="",i.columnlistStr=""})}),$(document).on("click",".look-more-article",function(o){if($(this).hasClass("active")){$(this).fadeOut(function(){$(this).remove()}),t(i.columnlistUrl,{columnId:i.columnId,page:i.columnPage},e,i.columnlistBox);var n=o||window.event;n.stopPropagation?n.stopPropagation():n.cancelBubble=!0}}),$(document).on("click",".articleColumnFreeBt",function(e){var t=$(this).data("id");o({columnId:t},$(this));var n=e||window.event;n.stopPropagation?n.stopPropagation():n.cancelBubble=!0}),$(window).resize(function(){n(i.columnlistBox,i.columnlistContent,i.columnlistHeight)})}),$(function(){function e(){this.rewardSettingJson=null,this.rewardInfo={name:"",sendAmount:"",money:""},this.minSendAmount=10,this.minMoney=5,this.availableAmount=0,this.presetTitle=[],this.currentRedEnvolope=null,this.hasShowGuideBottom=getCookie("hasShowRRGuideBottom"),this.hasShowGuideSide=getCookie("hasShowRRGuideSide"),this.redEnvolope=$("#redEnvolope"),this.formRewardBox=$(".comment-reward-box"),this.dialogRewardModal=$(".comment-rewarddialog-box"),this.commentRewardForm=this.dialogRewardModal.find("#commentRewardForm"),this.txtName=this.commentRewardForm.find("#txtName"),this.txtSendAmount=this.commentRewardForm.find("#txtSendAmount"),this.txtMoney=this.commentRewardForm.find("#txtMoney"),this.getSetting()}function t(){this.commentForm=$("#commentform"),this.txtComment=$("#comment_content"),this.commentCountObj=this.commentForm.find("em"),this.commtCode=$("#commentCode"),this.domLi="",this.btnShowMore=$("#btnMoreComment"),this.commentBox=$("div.comment-list-box"),this.commentBoxDefault=$("div.has-comment-con"),this.commentPagination=$("#commentPage"),this.commentLineBox="",this.commentTxt=$("#comment_replyId"),this.cancelBtn=this.commentForm.find(".btn-cancel"),this.articleId=$("article_id"),this.curH=0,this.pageCount=0,this.pageIndex=1,this.curFloor=1,this.commentCount=0,this.commentPageObj=null,this.commentFontLimit=1e3,this.firstLoad=!0,this.pageSize=10,this.showAll=!1,this.commentFold={pageSize:10,pageIndex:1,pageCount:0,total:0,fold:"fold"},this.lookBadComment=$("#lookBadComment"),this.lookUnFlodComment=$("#lookUnFlodComment"),this.commentUnFold={pageSize:10,pageIndex:1,pageCount:0,total:0,fold:"unfold"},this.lookFlodComment=$("#lookFlodComment"),this.lookGoodComment=$("#lookGoodComment"),this.isCommentFold=!1,this.initHotComment=!0,this.bindBtnFoldMore(),this.commentFoldTextareaStr(),this.initTxt(),this.init(),this.bindBtn(),this.bindTxt(),this.commentCode(),this.comment(),this.lookMoreComment(),this.lookMoreFlodComment(),this.gosideComment(),this.commentSideTitClose(),this.cancelBtnBindEvent(),this.getPagination=function(e){var t=e,o=function(o,n){o&&(o.list&&0==o.list.length&&e-1>=1&&(t=e-1,n.commentPageObj.go(t),1==t&&$("#commentPage").hide()),n.pageCount=o.pageCount,n.commentCount=o.floorCount,n.commentPageObj.render({count:o.floorCount,current:t}),n.renderData(o.list))};this.getData(t,o)},this.bindLikedClick(),this.bindRedRewardClick()}function o(e){username===e.userName?isBloger='作者':isBloger=""}function n(){$("pre.code2").each(function(e,t){hljs.highlightBlock(t),hljs.getLines(t.innerHTML).length>1?hljs.lineNumbersBlock(t):hljs.lineNumbersBlock(t,{singleLine:!0}),$(t).removeClass("code2")})}function i(){$(document).on("click",".comment-reward-item",function(e){if(!getCookie("UserName"))return window.csdn.loginBox.show(),!1;var t=$(this).data("id");g.showRedEnvolope(t)})}function a(){$(document).on("click",".comment-like",function(e){if(!getCookie("UserName"))return window.csdn.loginBox.show(),!1;var t=$(this).hasClass("liked")?"undigg":"digg",o=$(this).data("commentid"),n=this,i={articleId:articleId,commentId:o};$.ajax({url:blogUrl+"phoenix/web/v1/comment/"+t,type:"post",dataType:"json",data:i,xhrFields:{withCredentials:!0},success:function(e){var t=$(n).find("span").text()?parseInt($(n).find("span").text()):0;if($(n).hasClass("liked")){var o=t-1;o=o>0?o:"",$(n).removeClass("liked"),$(n).find(".unclickImg").css("display","inline-block"),$(n).find(".clickedImg").css("display","none"),$(n).find("span").text(o).css("color","#999AAA"),window.csdn.report&&"function"==typeof window.csdn.report.reportClick&&window.csdn.report.reportClick({spm:"1001.2101.3001.6253",extend1:'{"praise":0}'})}else $(n).addClass("liked"),$(n).find(".unclickImg").css("display","none"),$(n).find(".clickedImg").css("display","inline-block"),$(n).find("span").text(t+1).css("color","#FC5531"),window.csdn.report&&"function"==typeof window.csdn.report.reportClick&&window.csdn.report.reportClick({spm:"1001.2101.3001.6253",extend1:'{"praise":1}'});$(n).parents(".right-box").children(".comment-like").html($(n).html()),$(".comment-like-img-hover").css("display","none")}})})}function s(e){var t="";return 0==e.length?"":(t=e.replace(//g,">"))}function c(){for(var e="",t=1;t<=72;t++){var o="";o=t<10?"00"+t:t>=10&&t<100?"0"+t:t,e+=''}return e}function r(e){var t=window.location.href.split(e)[1];return null!=t?t:""}var l="https://liveapi.csdn.net/";e.prototype.bindInit=function(){var e=this;this.rewardInfo.money=this.rewardSettingJson["default"].variables.DEFAULT_AMOUNT,this.rewardInfo.sendAmount=this.rewardSettingJson["default"].variables.DEFAULT_NUM;var t=$(".guide-rr-first");t.remove();var o=$(".rr-guide-box");o.remove();var n=function(t,o){var n=t.parents(".ipt-box"),i=n.find(".notice"),a=t.val().trim();if(0===a.length)"sendAmount"===o?i.text("请输入红包数量"):"money"===o&&i.text("红包金额最低"+e.minMoney+"元"),n.addClass("error");else{var s=!0;"sendAmount"===o?parseInt(a)"),s=!1):parseFloat(a)>parseFloat(e.availableAmount)?(e.commentRewardForm.find(".balance-info-box").addClass("error"),e.commentRewardForm.find(".link-charge").text("余额不足请充值")):(e.commentRewardForm.find(".balance-info-box").removeClass("error"),e.commentRewardForm.find(".link-charge").text("前往充值 >"))),s?n.removeClass("error"):n.addClass("error");var c=e.txtSendAmount.parents(".ipt-box"),r=e.txtSendAmount.val(),l=e.txtMoney.val();if(r&&parseFloat(l)>=5&&.1*parseFloat(r)>parseFloat(l)){var d=Math.floor(parseFloat(l)/.1);c.find(".notice").text("红包个数范围为"+e.minSendAmount+"-"+d+"个"),c.addClass("error")}else parseInt(r)>10&&c.removeClass("error")}},i=function(e,t,o){var n=e.indexOf(t),i="";return n===-1?e:"-"===t&&0!==n?e.slice(0,n):("."===t&&e.match(/^(\.|-\.)/)&&(i=n?"-0":"0"),i+e.slice(0,n+1)+e.substr(n+1,2).replace(o,""))},a=function(e,t){e=t?i(e,".",/\./g):e.split(".")[0];var o=t?/[^-0-9.]/g:/[^-0-9]/g;return e.replace(o,"")},s=function(){var t=e.txtName.val(),o=e.txtSendAmount.val(),n=e.txtMoney.val();""!==t&&""!==o&&""!==n&&0===e.commentRewardForm.find(".ipt-box.error,.balance-info-box.error").length?(e.commentRewardForm.find(".btn-submit").removeAttr("disabled"),e.commentRewardForm.find(".pay-info").find(".price").text(parseFloat(n).toFixed(2)),e.commentRewardForm.find(".pay-info").show()):(e.commentRewardForm.find(".btn-submit").attr("disabled",!0),e.commentRewardForm.find(".pay-info").hide())};this.txtName.val(this.rewardInfo.name),this.commentRewardForm.find(".btn-random").click(function(){e.randomTitle()}),this.dialogRewardModal.find("a.btn-form-close").click(function(){e.hideRewardForm()}),this.commentRewardForm.find("input:text").keyup(function(){var e=$(this).attr("name");"sendAmount"===e?$(this).val(a($(this).val(),!1)):"money"===e&&$(this).val(a($(this).val(),!0)),n($(this),e),s()}),this.commentRewardForm.find("input:text").blur(function(){var e=$(this).attr("name");n($(this),e),s()}),this.formRewardBox.find(".btn-remove-reward").click(function(){e.formRewardBox.hide(),e.rewardInfo={name:"",sendAmount:"",money:""},e.txtName.val(e.rewardSettingJson["default"].defaultTitle),e.txtSendAmount.val(""),e.txtMoney.val(""),e.commentRewardForm.find(".error").removeClass("error")}),this.commentRewardForm.find(".btn-submit").click(function(){e.rewardInfo.name=e.txtName.val(),e.rewardInfo.sendAmount=e.txtSendAmount.val(),e.rewardInfo.money=e.txtMoney.val(),e.formRewardBox.find(".info").text(e.rewardInfo.name);var t=new Number(e.rewardInfo.money).toFixed(2);e.formRewardBox.find(".price").text(t+"元"),e.formRewardBox.show(),e.dialogRewardModal.hide()}),this.commentRewardForm.find(".btn-cancel").click(function(){e.hideRewardForm()})},e.prototype.getSetting=function(){var e=this;$.get("https://img-home.csdnimg.cn/data_json/jsconfig/redPacket.json",function(t){e.rewardSettingJson=t,e.rewardInfo.name=t["default"].defaultTitle,e.presetTitle=t["default"].presetTitle,e.bindInit(),e.formRewardBox.css(t["default"].redCardSty),e.redEnvolope.find(".top").css(t["default"].preOpenSty),e.redEnvolope.find(".red-openbtn").css(t["default"].preOpenBtnSty),e.redEnvolope.find("footer").css(t["default"].preFooterSty),e.redEnvolope.find("a.rule").attr("href",t.blog.ruleUrl)})},e.prototype.getRedPacketVerifyBatch=function(){var e=$(".comment-reward-item[data-uncheck='1']");if(e.length>0){for(var t=[],o=0;o0)for(var o=0;o .tt").text(c),s.find(".author > .tt").data("creatorUserName",i.creatorUserName);var r='红包规则',l="";switch(t.redPacketStatus){case"received":l='
'+t.currentUserReceivedInfo.receivedMoney+'
已放入你的CSDN钱包, 点击查看
已领取'+i.receivedAmount+"/"+i.totalAmount+"个,共"+i.receivedMoney+"/"+i.totalMoney+"元
"+r;break;case"completed":l='
'+i.totalAmount+"个红包,"+i.completeTimeInterval+"被抢光
"+r;break;case"expired":l='
该红包已过期,已领取'+i.receivedAmount+"/"+i.totalAmount+"个,共"+i.receivedMoney+"/"+i.totalMoney+"元
"+r}s.find(".receive-box header").html(l);var d=function(e){return e=e<10?"0"+e:e},m=function(e){var t=new Date(e);return d(t.getMonth()+1)+"-"+d(t.getDate())+" "+d(t.getHours())+":"+d(t.getMinutes())};if(t.receivedInfos&&t.receivedInfos.length>0){for(var p="",u=0;u';p+='
'+h.receivedMoney+"元"+f+"
"}s.find(".receive-box .receive-list").html(p)}o()},e.prototype.receiveRedPacket=function(e){var t=this.redEnvolope.find("#preOpen"),o=this.redEnvolope.find("#opened"),n=this;t.find(".red-openbtn").addClass("rotate-start"),$.ajax({type:"POST",url:l+"mp/live-gift/v1.0/redPacket/receiveRedPacket",contentType:"application/json; charset=utf-8",headers:{requestID:(new Date).getTime(),xappid:"pc_blog",xdeviceid:"pc_blog"},data:JSON.stringify({orderNo:e,username:currentUserName}),xhrFields:{withCredentials:!0},success:function(i){i.message&&showToast({text:i.message,bottom:"10%",zindex:9e3,speed:500,time:2e3});var a=o.find(".author > .tt").data("creatorUserName");username!==currentUserName&&a!==username&&($("#btnAttent").hasClass("attented")||(window.followByRR=!0,$("#btnAttent").trigger("click"))),n.getReceiveList(e,function(){setTimeout(function(){t.find(".red-openbtn").addClass("red-hidebtn"),t.find(".top").addClass("slide-top"),t.find("footer").addClass("slide-bottom"),setTimeout(function(){t.css("display","none"),o.css("display","flex"),t.find(".top").removeClass("slide-top"),t.find("footer").removeClass("slide-bottom"),t.find(".red-openbtn").removeClass("rotate-start").removeClass("red-hidebtn")},800)},800)})},error:function(){showToast({text:"请求失败,请重试",bottom:"10%",zindex:9e3,speed:500,time:2e3})}})},e.prototype.showRedEnvolope=function(e){var t=this;this.getReceiveList(e,function(){"received"!==t.currentRedEnvolope.redPacketStatus&&"expired"!==t.currentRedEnvolope.redPacketStatus&&"completed"!==t.currentRedEnvolope.redPacketStatus||(t.redEnvolope.find("#preOpen").hide(),t.redEnvolope.find("#opened").css("display","flex")),t.redEnvolope.show(),t.redEnvolope.find(".close-btn").one("click",function(){t.redEnvolope.hide(),t.redEnvolope.find("#preOpen").removeAttr("style"),t.redEnvolope.find("#opened").removeAttr("style")})})};'
  • '+username+'
    '+nickName+':这篇文章对你有帮助吗?作为一名程序工程师,在评论区留下你的困惑或你的见解,大家一起来交流吧!
','';t.prototype.lookMoreComment=function(){var e=this;$(document).on("click","#lookGoodComment",function(t){e.getPagination(e.commentUnFold.pageIndex)})},t.prototype.lookMoreFlodComment=function(){var e=this;$(document).on("click","#lookBadComment",function(t){e.getFoldList(e.commentFold)})},t.prototype.gosideComment=function(){$(document).on("click",".go-side-comment",function(){getCookie("UserName")?($("#commentSideBoxshadow").fadeIn(),$(this).hasClass("focus")&&$("#comment_content").focus()):window.csdn.loginBox.show()})},t.prototype.commentSideTitClose=function(){var e=this;$(document).on("click",".comment-side-tit-close",function(t){t.target.className.indexOf("comment-side-tit-close")>-1&&($("#commentSideBoxshadow").fadeOut(function(){e.isCommentFold&&(e.isCommentFold=!1,e.commentUnFold.pageIndex=1,e.getPagination(e.commentUnFold.pageIndex),$("#pcFlodCommentSideBox").hide(),$("#pcCommentSideBox").show(),$("#pcFlodCommentSideBox .comment-fold-content").html(""))}),$("#commentQuote").remove())}),$(document).keyup(function(e){var t=e.which,o=$("#commentSideBoxshadow");27==t&&"block"==o.css("display")&&o.trigger("click")})},t.prototype.getData=function(e,t){if(!getCookie("UserName"))return!1;var o=this;o.pageIndex=void 0!==e?e:o.pageIndex;var n=null,i="&commentId="+m;o.pageIndex>1&&(i=""),$.ajax({url:blogUrl+"phoenix/web/v1/comment/list/"+articleId+"?page="+o.pageIndex+"&size="+o.pageSize+"&fold=unfold"+i,type:"post",xhrFields:{withCredentials:!0},success:function(e){200===e.code&&(n=e.data,n&&(o.curFloor=n.floorCount-(o.pageIndex-1)*o.pageSize,o.commentUnFold.pageIndex+=1,o.commentUnFold.pageCount=n.pageCount,o.commentUnFold.total=n.floorCount,o.commentFold.total=n.foldCount,o.commentUnFold.pageIndex>o.commentUnFold.pageCount?(o.lookGoodComment.hide(),o.commentFold.total>0?o.lookFlodComment.show():o.lookFlodComment.hide()):(o.lookGoodComment.show(),o.lookFlodComment.hide()),$(".tool-item-comment .count").html(n.count),$(".comment-side-tit-count .count").html(n.count),$(".has-comment-tit .count").html(n.count),$(".has-comment-bt-left .count").html(n.count),$(".look-flod-comment .count").html(o.commentFold.total),$(".comment-fold-tit .count").html(o.commentFold.total),o.commentFold.total>0||o.lookFlodComment.hide(),n.count>0?($("#pcCommentBox").removeClass("comment-box-nostyle"),$("#pcCommentBox .has-comment").css({display:"block"}),$("#pcCommentBox .unhas-comment").css({display:"none"})):getCookie("UserName")?($("#pcCommentBox").addClass("comment-box-nostyle"),$("#pcCommentBox .has-comment").css({display:"none"}),$("#pcCommentBox .unhas-comment").css({display:"none"})):($("#pcCommentBox").removeClass("comment-box-nostyle"),$("#pcCommentBox .has-comment").css({display:"none"}),$("#pcCommentBox .unhas-comment").css({display:"flex"}))))},complete:function(){t&&t(n,o)}})},t.prototype.init=function(){window.localStorage.getItem("AM_comment_data")&&window.localStorage.getItem("AM_comment_id")==articleId&&(this.txtComment[0].focus(),this.txtComment.val(window.localStorage.getItem("AM_comment_data")),this.commentTxt.val(window.localStorage.getItem("AM_comment_replyId")),$(window).scrollTop(this.txtComment.offset().top));var e=function(e,t){if(null!==e){var o="";if(getCookie("UserName")||(o="登录 "),t.pageCount=e.pageCount,t.curFloor=e.floorCount,t.commentCount=e.floorCount,t.btnShowMore.html(""+o+"查看 "+e.count+' 条热评'),t.renderData(e.list),getCookie("UserName")?(t.btnShowMore.parent("div.opt-box").remove(),t.showAll=!0,e.floorCount<=t.pageSize?t.commentPagination.addClass("d-none"):0===$("#btnMoreComment").length&&t.commentPagination.removeClass("d-none")):e.floorCount<=3?(t.btnShowMore.parent("div.opt-box").remove(),t.showAll=!0):e.floorCount<=t.pageSize?t.commentPagination.addClass("d-none"):0===$("#btnMoreComment").length&&t.commentPagination.removeClass("d-none"),null===t.commentPageObj?e.pageCount>0&&(t.commentPageObj=new Paging,t.commentPageObj.init({target:t.commentPagination,pagesize:t.pageSize,count:t.commentCount,current:1,firstTpl:"",lastTpl:"",callback:function(e,o,n){t.getPagination(e)}})):t.commentPageObj.render({count:t.commentCount}),""!==m){var n=$("div.has-comment-con ul.comment-list:first-child").find("li.comment-line-box");$(n).each(function(e,t){if(m==$(t).data("commentid")){var o=$(document).scrollTop(),i=$("#csdn-toolbar").height(),a=16;o<52&&(i=2*i);var s=$(n)[e].offsetTop-i-a;return setTimeout(function(){$("html,body").animate({scrollTop:s},200)},850),!1}})}}else t.btnShowMore.parent("div.opt-box").remove(),t.showAll=!0};this.firstLoad?this.getData(1,e):blogMoveHomeArticle&&this.btnShowMore.parent("div.opt-box").remove()},t.prototype.initTxt=function(){var e=this;$("#comment_content").length&&$("#comment_content").focus(function(){e.addId(e);var t=e.commentFontLimit-parseInt($(this).val().length);e.commentCountObj.text(t>=0?t:0),e.cancelBtnToggle(!1),e.commentLineBox.length>0&&($("#commentEditBox").siblings(".comment-list-item").find("a.btn-reply").html("回复"),e.commentLineBox.find(".comment-edit-box").remove())}),getCookie("UserName")&&($(document).click(function(t){if(!$(t.target).is("div.comment-edit-box *")&&!$(t.target).is(".right_recommend_comment_button *")&&!$(t.target).is(".reply")&&($(".comment-operate-isshow").hide(),e.txtComment.length>0)){var o=e.commentFontLimit-e.txtComment.val().length;e.commentCountObj.text(o>=0?o:0)}}),$(document).click(function(e){$(e.target).is(".comment-line-box *")||($("#commentEditBox").siblings(".comment-list-item").find("a.btn-reply").html("回复"),$("#commentEditBox").remove())})),$("input.btn-comment-defualt").click(function(){$(".tool-item-comment").trigger("click")}),$(".tool-item-comment").click(function(){setTimeout(function(){$("#pcCommentBox").show(),$("#comment_content").focus()},0)})},t.prototype.bindBtn=function(){function e(e){return"svg"===this.nodeName||getCookie("UserName")?(t.commentCount>t.pageSize&&t.commentPagination.removeClass("d-none"),$(this).parent("div.opt-box").remove(),$(this).parent().parent("div.opt-box").remove(),t.showAll=!0,t.curH=0,void(window.event?window.event.cancelBubble=!0:e.stopPropagation())):(csdn.loginBox.show(),!1)}var t=this;$(document).on("click",".comment-operate-item",function(e){var o=$(e.target).data("type");if(void 0!==o)switch(o){case"report":var n=$(e.target).parents("li.comment-line-box"),i=n.data("commentid"),a=n.data("replyname");window.csdn.loginBox.key({biz:"blog",subBiz:"other_service",cb:function(){window.csdn.feedback({type:"blog",rtype:"comment",rid:i,reportedName:a,submitOptions:{contentUrl:articleDetailUrl},callback:function(){showToast({text:"感谢您的举报,我们会尽快审核!",bottom:"10%",zindex:9e3,speed:500,time:1500})}})}});break;case"reply":var s=$(e.target)[0].innerText;if($(this).find("a.btn-reply").text("回复"),$(e.target)[0].innerText="回复"==s?"收起":"回复",t.isCommentFold){if(!getCookie("UserName"))return window.csdn.loginBox.show(),!1;$("#commentEditBox").remove();var c=t.commentFoldTextareaStr("commentEditBox","New");if(!$("#commentEditBox").length&&"回复"==s){$(e.target).parents(".comment-list-item").after(c);var r=$(e.target).parents(".comment-line-box");t.addId(t,"new"),t.comment(),t.bindTxt(),curComment={},curComment.Id=r.data("commentid"),curComment.User=r.data("replyname"),curComment.text=r.find(".name").text()+(r.find(".nick-name").length?" 回复 "+r.find(".nick-name").text():"")+r.find(".comment").text(),t.cancelBtnToggle(!0),t.replayComment(curComment),t.txtComment.trigger("focus"),t.commentCode()}}else"回复"==s?"":$("#commentEditBox").remove();break;case"delete":var l=$(e.target).data("nickname"),d=$(e.target).parents("li.comment-line-box"),i=d.data("commentid");showConfirm({tit:"删除评论",text:'确认将 "'+l+'" 的评论删除吗?',isBlack:"Black"==skinStatus,rightText:"确定",zindex:9e3,success:function(){t.commentIsDelete(i)},cancel:function(){}});break;case"istop":var l=$(e.target).data("nickname"),m="false"!=$(e.target).attr("data-status"),p=$(e.target).parents("li.comment-line-box"),i=p.data("commentid");showConfirm({tit:m?"取消置顶":"置顶评论",text:m?'确认将 "'+l+'" 的评论取消置顶吗?':'确认将 "'+l+'" 的评论置顶吗?',isBlack:"Black"==skinStatus,rightText:"确定",zindex:9e3,success:function(){t.commentIsTop(i,m)},cancel:function(){}});break;case"blacklist":var m="false"!=$(e.target).attr("data-status"),u=$(e.target).data("username"),l=$(e.target).data("nickname");showConfirm({tit:m?"取消屏蔽":"屏蔽用户",text:isCurrentUserVip?m?'确认将 "'+l+'" 取消屏蔽吗?取消后对方即可在您的内容下进行评论':'确认将 "'+l+'" 屏蔽吗?屏蔽后对方将无法在您的内容下进行评论':"屏蔽用户为会员权益,您可加入会员行使该权益",isBlack:"Black"==skinStatus,rightText:isCurrentUserVip?"确定":"开通会员",zindex:9e3,success:function(){var e="";isCurrentUserVip?(e=m?"1001.2101.3001.6915":"1001.2101.3001.6913",t.commentIsBlack(username,u,m)):(window.open("https://www.csdn.net/vip?utm_source=commentblocking","_blank"),e="1001.2101.3001.6917"),window.csdn.report&&"function"==typeof window.csdn.report.reportClick&&window.csdn.report.reportClick({spm:e})},cancel:function(){}})}}),this.btnShowMore.click(e),this.btnShowMore.find("svg").click(e)},t.prototype.bindTxt=function(){var e=this;this.txtComment.blur(function(){}),this.txtComment.keyup(function(){var t=e.commentCountObj,o=e.commentFontLimit-$(this).val().length;o<0?t.text(0):t.text(o),$(this).val().length||$(this).data("replayUser")?e.cancelBtnToggle(!0):e.cancelBtnToggle(!1)})},t.prototype.renderData=function(e){var t=this,o=t.commentFoldTextareaStr("commentEditBox","New");t.buildListDom(e,!1,this,!0),$(".comment-list li.comment-line-box").on("click",function(e){if($(e.target).data("flag")&&(t.commentLineBox&&t.commentLineBox[0]!=$(this)[0]&&t.commentLineBox.find(".comment-edit-box").remove(),0==$(this).find(".comment-edit-box").length)){if(getCookie("UserName")){getCookie("UserName")&&($(this).append(o),$("#closeNew").on("click",function(e){$(this).parents(".comment-edit-box").remove()}),t.addId(t,"new"),t.comment(),t.bindTxt(),curComment={},curComment.Id=$(this).data("commentid"),curComment.User=$(this).data("replyname"),curComment.text=$(this).find(".name").text()+($(this).find(".nick-name").length?" 回复 "+$(this).find(".nick-name").text():"")+$(this).find(".comment").text(),t.cancelBtnToggle(!0),t.replayComment(curComment),t.txtComment.trigger("focus"),t.commentCode());var n=$(document).scrollTop(),i=$("#csdn-toolbar").height();n<52&&(i=2*i)}else csdn.loginBox.show();t.commentLineBox=$(this)}}),n()},t.prototype.commentFoldTextareaStr=function(e,t){if($("#isShowCommentAuth").length&&1==$("#isShowCommentAuth").data("type"))var o=' | 博主筛选后可见';else var o="";var n='
还能输入1000个字符'+o+'
'; return n},t.prototype.buildListDom=function(e,t,o,n){for(var i="",a="",s=0;s',i+=o.buildHtml(c,l,!0,c.userName?c.userName:"",n),l>0){i+='
  • ',i+='
      ';for(var d=0;d1&&(i+='
      查看全部 '+l+' 条回复
      '),i+="
    ",i+="
  • "}if(i+="",t)a+=i;else{if(o.commentBox.append($(i)),2==o.commentUnFold.pageIndex&&0==s&&o.initHotComment&&e.length){var p=e[0].info,u="";p.content=this.replaceQuote(p.content);var h=this.getQuoteInfo(p.content);h.length>1?(quotename=h[1],quotecontent=this.getCodeInfo(h[2]),quotecontent=this.replaceNewUBB(quotecontent),content=this.getCodeInfo(h[3]),content=this.replaceNewUBB(content),content='引用“'+quotename+"”的评论:
    "+quotecontent+"
    "+content):(content=this.replaceNewUBB(h[0]),content=this.getCodeInfo(content));var f,v=null!==p.redEnvelopeInfo,w=v?JSON.parse(p.redEnvelopeInfo):null;v&&(f=JSON.stringify({spm:"3001.9224",extend1:{orderNo:p.orderNo}}),w.money=parseFloat(parseInt(w.money)/100).toFixed(2)),u='
    '+p.nickName+'热评'+(v?'
    '+w.money+"元
    ":"")+'
    '+content+"
    ",o.commentBoxDefault.html($(u)),o.initHotComment=!1}o.curFloor--}}return!e.length&&o.commentUnFold.total<=0&&o.commentBoxDefault.html(""),t?a:void g.getRedPacketVerifyBatch()},t.prototype.addId=function(e,t){"new"==t?(e.commentForm=$("#commentformNew"),e.txtComment=$("#comment_contentNew"),e.commentCountObj=e.commentForm.find("em"),e.commtCode=$("#commentCodeNew"),e.commentTxt=$("#comment_replyIdNew"),e.articleId=$("#article_idNew")):(e.commentForm=$("#commentform"),e.txtComment=$("#comment_content"),e.commentCountObj=e.commentForm.find("em"),e.commtCode=$("#commentCode"),e.commentTxt=$("#comment_replyId"),e.articleId=$("#article_id"))},t.prototype.bindBtnFoldMore=function(){var e=this;$(document).on("click","#lookFlodComment",function(){e.isCommentFold=!0,e.commentFold.pageIndex=1,e.getFoldList(e.commentFold),$("#pcFlodCommentSideBox").show(),$("#pcCommentSideBox").hide(),$("#pcCommentSideBox .comment-list-box").html("")}),$(document).on("click","#lookUnFlodComment",function(){e.isCommentFold=!1,e.commentUnFold.pageIndex=1,e.getPagination(e.commentUnFold.pageIndex),$("#pcFlodCommentSideBox").hide(),$("#pcCommentSideBox").show(),$("#pcFlodCommentSideBox .comment-fold-content").html("")}),t.prototype.getFoldList=function(t){$.ajax({url:blogUrl+"phoenix/web/v1/comment/list/"+articleId+"?page="+e.commentFold.pageIndex+"&size="+e.commentFold.pageSize+"&fold="+e.commentFold.fold,type:"post",xhrFields:{withCredentials:!0},success:function(t){if(200===t.code){result=t.data;result.foldCount;if($(".tool-item-comment .count").html(result.count),$(".comment-side-tit-count .count").html(result.count),$(".has-comment-tit .count").html(result.count),$(".has-comment-bt-left .count").html(result.count),$(".look-flod-comment .count").html(result.foldCount),$(".comment-fold-tit .count").html(result.foldCount),result.foldCount>0?e.lookFlodComment.show():e.lookFlodComment.hide(),result.count>0?($("#pcCommentBox").removeClass("comment-box-nostyle"),$("#pcCommentBox .has-comment").css({display:"block"}),$("#pcCommentBox .unhas-comment").css({display:"none"})):getCookie("UserName")?($("#pcCommentBox").addClass("comment-box-nostyle"),$("#pcCommentBox .has-comment").css({display:"none"}),$("#pcCommentBox .unhas-comment").css({display:"none"})):($("#pcCommentBox").removeClass("comment-box-nostyle"),$("#pcCommentBox .has-comment").css({display:"none"}),$("#pcCommentBox .unhas-comment").css({display:"flex"})),result.list.length){var o=e.buildListDom(result.list,!0,e,!1),n=document.createElement("div");n.classList.add("comment-fold-con","comment-list-box","comment-operate-item"),n.innerHTML=o,$("#pcFlodCommentSideBox .comment-fold-content").append(n),e.commentFold.pageIndex+=1,e.commentFold.pageCount=result.pageCount,e.commentFold.pageIndex>e.commentFold.pageCount?e.lookBadComment.hide():e.lookBadComment.show()}}}})}};var d="";t.prototype.buildHtml=function(e,t,n,i,a){var s="",c="",r="",l="",m=!1,p="",u="";if(e.content=this.replaceUrl(e.content),n){d=i,p=this.getQuote(e.content),e.content=this.replaceQuote(e.content);var h=this.getQuoteInfo(e.content);h.length>1?(r=h[1],l=this.getCodeInfo(h[2]),l=this.replaceNewUBB(l),s=this.getCodeInfo(h[3]),s=this.replaceNewUBB(s),s='引用“'+r+"”的评论:
    "+l+"
    "+s):(s=this.replaceNewUBB(h[0]),s=this.getCodeInfo(s)),username===getCookie("UserName")&&(m=!0)}else{var h=this.getReplyInfo(e.content);c=h[1];var f=h.length>2?this.getQuoteInfo(h[2]):this.getQuoteInfo(h[0]);f.length>1?(r=f[1],l=this.getCodeInfo(f[2]),l=this.replaceNewUBB(l),s=this.getCodeInfo(f[3]),s=this.replaceNewUBB(s),s='引用“'+r+"”的评论:
    "+l+"
    "+s):(s=this.replaceNewUBB(f[0]),s=this.getCodeInfo(s))}if(o(e),n&&p&&""!=p&&(u='
    '+p+"
    "),n)var g="";else var g="comment-line-box-hide";var v,w=n&&null!==e.redEnvelopeInfo,b=w?JSON.parse(e.redEnvelopeInfo):null;w&&(v=JSON.stringify({spm:"3001.9224",extend1:{orderNo:e.orderNo}}),b.money=parseFloat(parseInt(b.money)/100).toFixed(2));var x="匿名用户"!=e.userName?blogUrl+e.userName:"javascript:void(0);",$='
  • ";return $},t.prototype.setNewLine=function(e){var t=/\
    ([\s\S]*?)\<\/pre\>/gi,o=[];if(e.replace(t,function(e){o.push(e)}),o.length)for(var n=e.replace(t,function(e){return"[csdnCommentPreCode]"}),i=n.replace(/\n/g,"
    "),a=0;a");return i},t.prototype.getReplyInfo=function(e){var t=e.split(/\[reply]([\s\S]*?)\[\/reply\][\r\n]{0,1}/gi);return t},t.prototype.getQuoteInfo=function(e){var t=e.split(/\[quote=([\w#\.]+)\]([\s\S]*?)\[\/quote\][\r\n]{0,2}/gi);return t},t.prototype.getCodeInfo=function(e){var t=e.replace(/\[code=([\w#\.]+)\]([\s\S]*?)\[\/code\]/gi,function(e,t,o){return""==$.trim(o)?"":'
    '+s(o.trim())+"
    "});return t},t.prototype.replaceNewUBB=function(e){return e=e.replace(/\[face\]([^\]]+):([^\]]+)\[\/face\]/gi,'表情包')},t.prototype.replaceUrl=function(e){var t=/(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#\/%?=~_|!:,.;]+[-A-Za-z0-9+&@#\/%=~_|]/g,o=/\[code=([\w#\.]+)\]([\s\S]*?)\[\/code\]/gi,n=[];if(e.replace(o,function(e){n.push(e)}),n.length)for(var i=e.replace(o,function(e){return"[csdnCommentCode]"}),a=i.replace(t,function(e){return' 网页链接'}),s=0;s 网页链接'});return a},t.prototype.replaceQuote=function(e){return e=e.replace(/\[quote\]([\s\S]*?)\[\/quote\]/gi,"")},t.prototype.getQuote=function(e){var t="";return e.replace(/\[quote\]([\s\S]*?)\[\/quote\]/gi,function(e){t=e}),t=t.replace("[quote]","").replace("[/quote]","")},t.prototype.replayComment=function(e){var t=e.Id,o=e.User;this.txtComment.attr("placeholder","回复:"+e.text).data("replayUser",o),this.commentTxt.val(t)},t.prototype.commentCode=function(){var e=this;e.commtCode.find("a").click(function(t){var o="[code="+$(this).data("code")+"]\n\n[/code]",n=e.txtComment.val();(o+n).length<=e.commentFontLimit?(e.txtComment.val(n+o),"comment_content"==e.txtComment[0].id&&$("#comment-content").val(n+o),e.commtCode.parents(".comment-code-box").fadeOut()):showToast({text:"您输入的字数已经超过限定了",bottom:"10%",zindex:9e3,speed:500,time:1500});var i=t||window.event;i.stopPropagation?i.stopPropagation():i.cancelBubble=!0})},t.prototype.comment=function(){function e(e){if(!getCookie("UserName"))return t.setStorage();window.localStorage.removeItem("AM_comment_data");var o=$(e).find(":submit"),n={commentId:t.commentTxt.val(),content:t.txtComment.val(),articleId:articleId};if("block"===g.formRewardBox.css("display")&&Object.assign(n,g.rewardInfo),n.replyId&&$.trim(n.content)&&(n.content="[reply]"+t.txtComment.data("replayUser")+"[/reply]"+n.content),$(e).find("#comment_content").length&&$("#commentQuote").length&&""!==$("#commentQuote").text()&&(n.content="[quote]"+$("#commentQuote").text().substr(0,50)+"[/quote]"+n.content),""===$.trim(n.content)||""===t.txtComment.val())showToast({text:"请填写评论内容",bottom:"10%",zindex:9e3,speed:500,time:1500});else{var i=blogUrl+"phoenix/web/v1/comment/submit";o.prop("disabled",!0).val("提交中"),$.ajax({url:i,type:"post",dataType:"json",data:n,xhrFields:{withCredentials:!0},beforeSend:function(){},success:function(e){if(200===e.code){if(t.isCommentFold)t.commentFold.pageIndex=1,$("#pcFlodCommentSideBox .comment-fold-content").html(""),t.getFoldList(t.commentFold);else{t.commentForm.trigger("reset"),t.commentTxt.val(""),t.txtComment.data("replayUser","").attr("placeholder","想对作者说点什么"),t.cancelBtnToggle(!1),m=e.data,t.init(),t.removeStorage();var o=$("#commentQuote");o.length&&o.animate({height:0},300,function(){o.remove()}),t.commentUnFold.pageIndex=1,$("#pcCommentSideBox .comment-list-box").html("")}"block"===g.formRewardBox.css("display")&&g.formRewardBox.find(".btn-remove-reward").trigger("click"),showToast({text:"评论成功,审核后显示",bottom:"10%",zindex:9e3,speed:500,time:2e3})}else showToast({text:e.message,bottom:"10%",zindex:9e3,speed:500,time:2e3})},complete:function(){o.prop("disabled",!1).val("评论")}})}return!1}var t=this;t.commentForm.submit(function(t){t.preventDefault();var o=this;try{window.csdn.loginBox.key({biz:"blog",subBiz:"other_service",cb:function(){e(o)}})}catch(n){e(o)}})},t.prototype.insertRightCommnetPrompt=function(){if(window.localStorage.getItem("AM_comment_Prompt_show"))return!1;window.localStorage.setItem("AM_comment_Prompt_show",!0);var e=$(".right_recommend_comment"),t=$(".right_recommend_comment_Prompt");t.length>0?t.fadeIn(300):e.prepend('
    新的评论在这里
    '),setTimeout(function(){$(".right_recommend_comment_Prompt").fadeOut(500)},4e3)},t.prototype.setStorage=function(){return window.localStorage.setItem("AM_comment_data",this.txtComment.val()),window.localStorage.setItem("AM_comment_replyId",this.commentTxt.val()),window.localStorage.setItem("AM_comment_id",articleId),!!getCookie("UserName")||(window.csdn.loginBox.show(),!1)},t.prototype.removeStorage=function(){window.localStorage.removeItem("AM_comment_data"),window.localStorage.removeItem("AM_comment_replyId"),window.localStorage.removeItem("AM_comment_id")},t.prototype.bindLikedClick=a,t.prototype.bindRedRewardClick=i,t.prototype.cancelBtnToggle=function(e){e?this.cancelBtn.removeClass("d-none"):this.cancelBtn.addClass("d-none")},t.prototype.cancelBtnBindEvent=function(){var e=this;this.cancelBtn.on("click",function(){e.txtComment.attr("placeholder","想对作者说点什么").data("replayUser","").val(""),e.commentTxt.val(""),e.cancelBtnToggle(!1)})},t.prototype.commentIsBlack=function(e,t,o){var n=this,i="https://mp-action.csdn.net/interact/wrapper/pc/black/"+(o?"cancel":"save"),a=o?{username:e,usernameList:[t],bizNo:"blog"}:{username:e,blackUsername:t,bizNo:"blog"};$.ajax({url:i,type:"post",data:JSON.stringify(a),contentType:"application/json",dataType:"json",xhrFields:{withCredentials:!0},success:function(e){200===e.code?(setTimeout(function(){n.isCommentFold?(n.commentFold.pageIndex=1,$("#pcFlodCommentSideBox .comment-fold-content").html(""),n.getFoldList(n.commentFold)):(n.commentUnFold.pageIndex=1,$("#pcCommentSideBox .comment-list-box").html(""),n.getPagination(n.commentUnFold.pageIndex))},100),showToast({text:o?"取消屏蔽成功!":"屏蔽用户成功!",bottom:"10%",zindex:9e3,speed:500,time:1500})):showToast({text:o?"取消屏蔽失败,请刷新页面重新操作!":"屏蔽用户失败,请刷新页面重新操作!",bottom:"10%",zindex:9e3,speed:500,time:1500})}})},t.prototype.commentIsTop=function(e,t){var o=this,n=blogUrl+"phoenix/web/v1/comment/top",i={commentId:e,articleId:articleId,action:t?0:1};$.ajax({url:n,type:"post",dataType:"json",data:i,xhrFields:{withCredentials:!0},success:function(e){200===e.code?(setTimeout(function(){o.isCommentFold?(o.commentFold.pageIndex=1,$("#pcFlodCommentSideBox .comment-fold-content").html(""),o.getFoldList(o.commentFold)):(o.commentUnFold.pageIndex=1,$("#pcCommentSideBox .comment-list-box").html(""),o.getPagination(o.commentUnFold.pageIndex))},100),showToast({text:t?"取消置顶成功!":"置顶评论成功!",bottom:"10%",zindex:9e3,speed:500,time:1500})):showToast({text:t?"取消置顶失败,请重新操作!":"置顶评论失败,请重新操作!",bottom:"10%",zindex:9e3,speed:500,time:1500})}})},t.prototype.commentIsDelete=function(e){var t=this,o=$("#article_id").val(),n=blogUrl+"phoenix/web/v1/comment/delete",i={commentId:e,articleId:o};$.ajax({url:n,type:"post",dataType:"json",data:i,xhrFields:{withCredentials:!0},success:function(e){200===e.code?(setTimeout(function(){t.isCommentFold?(t.commentFold.pageIndex=1,$("#pcFlodCommentSideBox .comment-fold-content").html(""),t.getFoldList(t.commentFold)):(t.commentUnFold.pageIndex=1,$("#pcCommentSideBox .comment-list-box").html(""),t.getPagination(t.commentUnFold.pageIndex))},100),showToast({text:"删除成功!",bottom:"10%",zindex:9e3,speed:500,time:1500})):showToast({text:"删除失败,请重新操作!",bottom:"10%",zindex:9e3,speed:500,time:1500})}})},$(document).on("keydown",".comment-content",function(e){var t=e||event;(t.ctrlKey&&13==t.which||13==t.which&&t.metaKey)&&("comment_content"==$(this).attr("id")?$("#commentform .btn-comment").trigger("click"):$("#commentformNew .btn-comment").trigger("click"))}),$(document).on("click",".second-look-more",function(e){$(this).hide(),$(this).siblings(".comment-line-box-hide").show()}),$(document).on("click",".comment-operate-item",function(e){if(getCookie("UserName")){if($(".comment-operate-isshow").fadeOut(),$(this).hasClass("comment-emoticon")){""==$(".comment-emoticon-img-box").html()&&$(".comment-emoticon-img-box").html(c()),$(this).find(".comment-emoticonNew").length&&$(this).find(".comment-operate-isshow").html($("#commentform .comment-emoticon-box").html());var t=$(this).find(".comment-emoticon-box");"block"===t.css("display")?t.fadeOut():($("#comment_content").one("focus",function(){t.fadeOut()}),t.fadeIn())}else if($(this).hasClass("comment-code")){var o=$(this).find(".comment-code-box");"block"===o.css("display")?o.fadeOut():($("#comment_content").one("focus",function(){o.fadeOut()}),o.fadeIn()),!$(this).hasClass("comment-codeNew")}else $(this).hasClass("comment-reward")&&g.showRewardForm();var n=e||window.event;n.stopPropagation?n.stopPropagation():n.cancelBubble=!0}else csdn.loginBox.show()}),$(document).on("click",".emoticon-monkey-img",function(e){var t=$(this).data("emoticon");if($(this).parents(".comment-emoticon-box").is(".comment-emoticonNew")){var o=$("#comment_contentNew").val()+t;o.length<=1e3?textareaPointLocation.insertAtCaret($("#comment_contentNew")[0],t):showToast({text:"您输入的字数已经超过限定了",bottom:"10%",zindex:9e3,speed:500,time:1500})}else{var o=$("#comment_content").val()+t;o.length<=1e3?textareaPointLocation.insertAtCaret($("#comment_content")[0],t):showToast({text:"您输入的字数已经超过限定了",bottom:"10%",zindex:9e3,speed:500,time:1500})}$(this).parents(".comment-emoticon-box").fadeOut();var n=e||window.event;n.stopPropagation?n.stopPropagation():n.cancelBubble=!0}),$(document).on("mouseenter",".comment-like",function(){$(this).hasClass("liked")?($(this).find(".clickedImg").css("display","none"),$(this).find(".comment-like-img-hover").css("display","block")):($(this).find(".unclickImg").css("display","none"),$(this).find(".comment-like-img-hover").css("display","block"))}),$(document).on("mouseleave",".comment-like",function(){$(this).hasClass("liked")?($(this).find(".clickedImg").css("display","block"),$(this).find(".comment-like-img-hover").css("display","none")):($(this).find(".unclickImg").css("display","block"),$(this).find(".comment-like-img-hover").css("display","none"))}),$(document).on("click",".unlogin-comment-box-new .unlogin-comment-bt",function(){window.csdn.report&&"function"==typeof window.csdn.report.reportClick&&window.csdn.report.reportClick({spm:"1001.2101.3001.6916"}),getCookie("UserName")||window.csdn.loginBox.show({spm:"1001.2101.3001.8611"})});var m=r("#comments_");if(m&&!getCookie("UserName")){$("#pcCommentBox").show();var p=$(document).scrollTop(),u=$("#csdn-toolbar").height(),h=2*$("#pcCommentBox").height();p<52&&(u=2*u);var f=$("#pcCommentBox").offset().top-u-h;return setTimeout(function(){$("html,body").animate({scrollTop:f},200)},850),!1}var g=new e;window.csdn.comments?window.csdn.comments:{},window.csdn.Comments=t,window.csdn.comments=new window.csdn.Comments}),$(function(){if(1===articleType){var e=$("main .blog-content-box")[0],t=document.querySelector(".creativecommons span a");t=t?t.innerText:"CC 4.0 BY-SA";var o="\r\n————————————————\r\n版权声明:本文为CSDN博主「"+nickName+"」的原创文章,遵循"+t+"版权协议,转载请附上原文出处链接及本声明。\r\n原文链接:"+curentUrl;csdn.copyright.init(e,o)}}),$(function(){function e(e,o){if(!(o.length<2)){var n="";n+="
      ";for(var i=0,a=0,s=0,c=0,r=0,l=0;li?(n+='
      1. ',a++):d0&&(n+="
    1. ",a--),1==d)for(;a>0;)n+="
    ",a--;i=d;var m=o.eq(l).text();if(m=/^[\s]+$/.test(m)?m:m.replace(/^[\s]+/g,""),m=t(m),m.length>0)switch(d){case 1:++s,c=0,r=0;var p="";1===s&&(p="active"),n+="
  • '+m+"
  • ";break;case 2:++c,r=0,n+='
  • '+m+"
  • ";break;case 3:++r,n+='
  • '+m+"
  • "}}for(;a>0;)n+="",a--;return n}}function t(e){return e.replace(/[<>&"]/g,function(e){return{"<":"<",">":">","&":"&",'"':"""}[e]})}function o(e){function t(e){return $(e).each(function(e,n){n.children&&t(n.children),++o}),o}var o=0;return t(e)}function n(e,t,o){var n=$("div.groupfile"),i=n.find("div.toc-box"),a=n.find("div.opt-box");if(t<=2&&$("#liTocBox").remove(),t>2&&"0"==d&&$("#liTocBox").css("display","block"),t<=2&&"1"==d?($(".groupfile").remove(),$("#rightAsideConcision").remove()):isShowConcision?(isCookieConcision&&$(".recommend-right1").addClass("show-directory"),isHasDirectoryModel=!0):$("#rightAsideConcision").remove(),t<=2&&($("#blog_artical_directory").hide(),$(".left_menu .menu_con").hide()),!$(".first_li")[0]){i.html(o(e,m)),s(t,a,i);var c=!1;$("#liTocBox").hover(function(){$("#liTocBox .toc-container").finish().fadeIn(500),$(this).find("button.btn-toc").addClass("active"),c=!1},function(e){c=!0;var t=$(this);setTimeout(function(){c&&($("#liTocBox .toc-container").finish().fadeOut(500),t.find("button.btn-toc").removeClass("active"))},300)})}}function i(){var e=document.documentElement.scrollTop||window.pageYOffset||document.body.scrollTop;e+=10;for(var t=0;t=180?($("#recommend-right").css({position:"fixed",top:e}),$("#recommend-right-concision").css({position:"fixed",top:e})):($("#recommend-right").removeAttr("style"),$("#recommend-right-concision").removeAttr("style")),0==$(document).scrollTop()&&($("#recommend-right").removeAttr("style"),$("#recommend-right-concision").removeAttr("style"))}function s(e,t,o){if(e>9){var n=25*$("div.toc-box").find("li:not(.sub-box)").length,i=225,a=n-i,s=0;t.find("button.btn-opt").click(function(){$(this).hasClass("nomore")||($(this).hasClass("prev")?(s-=25,o.scrollTop(s),s<=0&&$(this).addClass("nomore")):(s+=25,s>=25*(e-17)&&(s=25*(e-17)),o.scrollTop(s),s>=a&&$(this).addClass("nomore")),$(this).siblings().removeClass("nomore"))})}else t.remove()}function c(){function e(t){$(".openvippay")[0]||window.csdn.clearReadMoreBtn(),o.off("click",e)}function t(){var e=window.location.href,t=document.title;setTimeout(function(){history.pushState(null,t,e)},0)}var o=$(".toc-container .toc-box ol li a");return 0!==o.length&&(o.click(e),void o.click(t))}function r(e){var t="
      ";return $(e).each(function(e,o){t+=l(o,e)}),t+"
    "}function l(e,t){return e.children.length?"
  • "+e.title+'
  • '+r(e.children)+"
  • ":"
  • "+e.title+"
  • "}for(var d=1,m=$("#article_content").find("h1,h2,h3"),p=0;p'+m.eq(p).html());$(".vip_article")[0]?($.ajax({type:"GET",url:blogUrl+"/phoenix/web/v1/get-article-catalog?articleId="+articleId,dataType:"json",xhrFields:{withCredentials:!0},success:function(e){200==e.code&&(n(e.data,o(e.data),r),c(),$("#groupfile .toc-box ol li a").each(function(e,t){t.href="#t"+e}),$("#directory .toc-box ol li a").each(function(e,t){t.href="#t"+e}),""===String($(".groupfile .toc-box").text()).replace(/(^\s*)|(\s*$)/g,"")?($("#asidedirectory").remove(),$("#groupfile").remove(),$("#rightAsideConcision").remove(),isHasDirectoryModel=!1):$("#groupfile").show())}}),$("#downloadEduApp").click(function(){getCookie("UserName")?window.open("https://vip.csdn.net/studyvip?utm_source=zhuanlan"):window.csdn.loginBox.show()})):(n("",m.length,e),c(),""===String($(".groupfile .toc-box").text()).replace(/(^\s*)|(\s*$)/g,"")?($("#asidedirectory").remove(),$("#groupfile").remove(),$("#rightAsideConcision").remove(),isHasDirectoryModel=!1):$("#groupfile").show()),$(document).on("toolbarHeightChange",function(e){var t=$("#csdn-toolbar").height()+8;$("#recommend-right").css("position")&&$("#recommend-right").css({top:t})});var u=$("#content_views").find("h1,h2,h3"),h=[],f=$("#content_views").offset().top,g=$("#content_views").height(),v=$("#csdn-toolbar").height();$(u).each(function(e,t){h.push($(t)[0].offsetTop+f-2*v)}),h.push(g+f),$(window).resize(function(){h=[],f=$("#content_views").offset().top,g=$("#content_views").height(),v=$("#csdn-toolbar").height(),$(u).each(function(e,t){h.push($(t)[0].offsetTop+f-2*v)}),h.push(g+f)}),$(window).scroll(function(){$(".groupfile .toc-box li").removeClass("active"),i()}),i(),$(document).on("click",".groupfile .toc-box li a",function(e){$(".groupfile .toc-box li").removeClass("active"),$(this).parent().addClass("active")}),$(window).resize(function(){});var w=document.body.clientHeight||document.documentElement.clientHeight;if($("#groupfile").css("max-height",w/2+"px"),$(".groupfile-div").css("max-height",w/2+"px"),$(".groupfile-div1").css("max-height",w-48+"px"),$(document).scroll(function(){a()}),a(),$(document).on("click",".csdn-side-toolbar .option-box",function(e){isShowConcision&&setTimeout(function(){a()},100)}),$(".hide-article-box").length&&"none"!==$(".hide-article-box").css("display")){for(var b=$(".hide-article-box").offset().top,x=0,y=0;yx){var t=$("#getVipUrl").attr("href");t.indexOf("vip")>-1?window.open(t+"?utm_source=brv&sale_source=BgsN7mSaYF"):window.open(t)}}),$(".btn-readmore")[0]&&C.each(function(e,t){$(".groupfile .toc-box ol").find('a[href="#'+$(C[e]).find("a")[0].name+'"]').click(function(){$(".btn-readmore").trigger("click"),$(".btn-readmore").hasClass("no-login")?window.open("https://passport.csdn.net/account/login"):$("#btnAttent").trigger("click")})})}$(document).ready(function(){var e=$(".htmledit_views #main-toc").prevAll("h1,h2,h3"),t=e.length,o=$('.htmledit_views p[id*="-toc"]').slice(1).filter(function(e,t){return $(t).find("a").length||$(t).css({margin:"0"}),$(t).find("a").length});o.each(function(e,o){$(o).attr("id","");var n=$(o).css("margin-left").replace("px","")/40,i=0==n?0:48*n;$(o).css({"padding-left":"24px",margin:"0","margin-left":i+"px","margin-bottom":"2px"}),t>0?($(o).find("a").attr("href","#t"+t),t++):$(o).find("a").attr("href","#t"+e)});var n=$(".markdown_views .toc a");n.length&&n.each(function(e,t){var o=$(t).attr("href");o&&$(t).attr("href",o.replace(/%/g,"_"))});var i=$(".markdown_views").find("h1 a,h2 a,h3 a");i.length&&i.each(function(e,t){var o=$(t).attr("id");o&&$(t).attr("id",o.replace(/%/g,"_"))}),$(document).on("click","#content_views a[href*=#],div.toc-box a[href*=#],li.tool-item-comment a[href*=#]",function(){var e=$("#csdn-toolbar").height(),t=$(document).scrollTop();if(t<52&&(e=2*e),location.pathname.replace(/^\//,"")==this.pathname.replace(/^\//,"")&&location.hostname==this.hostname){var o=$(this.hash);if(o=o.length&&o||$("[name="+this.hash.slice(1)+"]"),o.length){var n=o.offset().top;return $("html,body").animate({scrollTop:n-e},500),!1}}}),setTimeout(function(){if(window.location.href.indexOf("#comments")>-1){var e=$("#csdn-toolbar").height();$("html,body").animate({scrollTop:$("#commentBox").offset().top-e-48},500)}},1e3)})}),$(function(){var e=$('#article_content a[href^="#"]');e.each(function(e){$(this).attr("target","_self")})}),function(){function e(e){var t="";i&&(t="active");var o='';n.innerHTML=o}function t(){$.ajax({url:"https://devpress-api.csdn.net/api/internal/blog/nsInfo/blog/"+articleId,type:"GET",xhrFields:{withCredentials:!0},success:function(t){200==t.code&&t.data?e(t.data):n.remove()}})}function o(e,t){$.ajax({type:"POST",url:"https://devpress-api.csdn.net/v1/user/follow",contentType:"application/json; charset=utf-8",data:JSON.stringify({followTarget:e,type:1}),xhrFields:{withCredentials:!0},success:function(e){window.open(t)},error:function(e){window.open(t)}})}var n=document.getElementById("blogHuaweiyunAdvert"),i=document.getElementById("blogColumnPayAdvert");n&&(t(),$(document).on("click","#blogHuaweiyunAdvert .column-group",function(){if(getCookie("UserName")){var e=$(this).data("id"),t=$(this).data("url");o(e,t)}else window.csdn.loginBox.show()}))}(),$(".comment-box textarea.comment-content").on("select",function(){textareaPointLocation.setCaret(this)}).on("click",function(){textareaPointLocation.setCaret(this)}).on("keyup",function(){textareaPointLocation.setCaret(this)});var textareaPointLocation={setCaret:function(e){e.createTextRange&&(e.caretPos=document.selection.createRange().duplicate())},insertAtCaret:function(e,t){if(document.all)if(e.createTextRange&&e.caretPos){var o=e.caretPos;o.text=" "==o.text.charAt(o.text.length-1)?t+" ":t}else e.value=t;else if(e.setSelectionRange){var n=e.selectionStart,i=e.selectionEnd,a=e.value.substring(0,n),s=e.value.substring(i); e.value=a+t+s}else showToast({text:"This version of Mozilla based browser does not support setSelectionRange",bottom:"10%",zindex:9e3,speed:500,time:1500})}};$(function(){var e=$("#asideNewNps"),t=$("#asideNewNps .newnps-item"),o=$("#asideNewNps .newnps-form-box");getCookie("blog_details_nps")?e.remove():(e.fadeIn(),t.on("click",function(){$(this).siblings().removeClass("active"),$(this).siblings().find("img.default").show(),$(this).siblings().find("img.active").hide(),$(this).addClass("active"),$(this).find("img.default").hide(),$(this).find("img.active").show(),o.slideDown()}),o.on("click",".newnps-btn",function(t){if(getCookie("UserName")){o.removeClass("active"),showToast({text:"感谢您的意见,我们尽快改进",bottom:"10%",zindex:9002,speed:500,time:1500});var n={spm:"1001.2101.3001.6242",extend1:"博客详情页满意度调查",extra:JSON.stringify({radio:e.find(".newnps-item.active").data("type"),input:o.find(".newnps-input").val()})};setCookieBaseHour("blog_details_nps",(new Date).getTime(),720),window.csdn&&window.csdn.report&&window.csdn.report.reportClick(n),e.slideUp(600,function(){e.remove()})}else window.csdn.loginBox.show()}),o.on("focus",".newnps-input",function(){o.addClass("active")}))}),$(function(){function e(){function e(){$("#publicPrompt").remove(),$(document).off("click",".publicPrompt-close",e),$(document).off("click",".publicPrompt-mask",e)}var t={success:''};this.data={},this.data.status="success",this.data.titleStr="收藏成功",this.data.textStr='已收藏至 个人中心',this.data.imgUrl="",this.init=function(e){return $.extend(this.data,e),this.addStyle(),this.bindDom(),this},this.show=function(e){$.extend(this.data,e),this.insetStructure(this.data)},this.bindDom=function(){$(document).on("click",".publicPrompt-close",e),$(document).on("click",".publicPrompt-mask",e)},this.insetStructure=function(e){var o='

    '+t[e.status]+e.titleStr+'

    '+e.textStr+'
    ';$("body").append(o)},this.addStyle=function(){var e=document.createElement("style");e.type="text/css",e.innerHTML=["#publicPrompt{","position: fixed;z-index: 99999;top: 0;left: 0;width: 100%;height: 100%;","}","#publicPrompt .publicPrompt-mask{","position: absolute;top: 0;left: 0;width: 100%;height: 100%;","background-color: rgba(0,0,0,0.5);","}","#publicPrompt .publicPrompt-content{","position: absolute;z-index: 2;top: 30%;left: 50%;margin-left: -175px;","background-color: #fff;width: 350px;padding: 16px;","}","#publicPrompt .publicPrompt-content .publicPrompt-title{","font-size: 16px;color: #3D3D3D;","}","#publicPrompt .publicPrompt-title svg{margin-right:4px;}","#publicPrompt .publicPrompt-title .success{fill:#89cb62;width: 20px;height: 20px;vertical-align: sub;}","#publicPrompt .publicPrompt-close{","position: absolute;top: 16px;right: 16px;cursor: pointer;","}","#publicPrompt .publicPrompt-text{","text-align: center;margin-top: 16px;margin-bottom: 16px;font-size: 14px;","}","#publicPrompt .publicPrompt-text a{","color: #3399EA;text-decoration: underline;","}","#publicPrompt .publicPrompt-qr{","display: block;width: 116px;height: 116px;padding: 8px;margin: 0 auto;border: 1px solid #EBEBEB;","}",".publicPrompt-footer-text{","font-size: 14px;color: #4D4D4D;margin-top:8px;text-align: center;","}"].join(""),document.getElementsByTagName("head")[0].appendChild(e)}}window.csdn?window.csdn:{},window.csdn.publicPrompt=e}),$(function(){var e=$("#recommendNps"),t=$("#recommendNps .newnps-item"),o=$("#recommendNps .newnps-form-box");getCookie("blog_details_recommend_nps")?e.remove():(e.fadeIn(),t.on("click",function(){$(this).siblings().removeClass("active"),$(this).siblings().find("img.default").show(),$(this).siblings().find("img.active").hide(),$(this).addClass("active"),$(this).find("img.default").hide(),$(this).find("img.active").show(),o.slideDown()}),o.on("click",".newnps-btn",function(t){if(getCookie("UserName")){o.removeClass("active"),showToast({text:"感谢您的意见,我们尽快改进",bottom:"10%",zindex:9002,speed:500,time:1500});var n={spm:"1001.2101.3001.7836",extend1:"博客详情页相关推荐满意度调查",extra:JSON.stringify({radio:e.find(".newnps-item.active").data("type"),input:o.find(".newnps-input").val()})};setCookieBaseHour("blog_details_recommend_nps",(new Date).getTime(),720),window.csdn&&window.csdn.report&&window.csdn.report.reportClick(n),e.slideUp(600,function(){e.remove()})}else window.csdn.loginBox.show()}),o.on("focus",".newnps-input",function(){o.addClass("active")}))}),$(function(){function e(e,t){l.hide(),m=e,m?c.text("您举报的评论来自文章:"):c.text("举报内容:"),r.css({"z-index":9999}).show(),s.css({"z-index":1e4}).show()}function t(){s.find("#frmReport").trigger("reset"),r.css({"z-index":150}).hide(),s.hide(),$(".ipt-textarea").val(""),$(".box-botoom ul li").removeClass("box-active"),$(".box-content-bottom ul li").removeClass("box-active"),$(".box-content").eq(0).show().siblings().hide(),$("#cllcont").hide(),$(".content-input").val(""),flag=!1,i="",a=""}function o(e){showToast({text:e,bottom:"10%",zindex:9999,speed:500,time:1500})}var n='

    举报

    选择你想要举报的内容(必选)
    • 内容涉黄
    • 政治相关
    • 内容抄袭
    • 涉嫌广告
    • 内容侵权
    • 侮辱谩骂
    • 样式问题
    • 其他
    ';$("body").append(n);var i="",a="";$(".box-botoom ul li").on("click",function(){flag=!1,$(this).addClass("box-active").siblings().removeClass("box-active"),i=$(this).attr("data"),$(".content-input").val(""),$(".box-content").eq($(this).index()).show().siblings().hide(),"6"==$(this).attr("data")?$("#cllcont").hide():$("#cllcont").show(),"8"==$(this).attr("data")?$("#cllcont").hide():$("#cllcont").show(),$(".ipt-textarea")[0].value="",$(".box-content-bottom ul li").removeClass("box-active"),"7"==$(this).attr("data")?$(".box-content-span").html("补充说明(必填)"):$(".box-content-span").html("补充说明(选填)"),a=""}),$(".box-content-bottom ul li").on("click",function(){$(this).addClass("box-active").siblings().removeClass("box-active"),a=$(this).attr("sub_type"),flag=!0});var s=$("div.report-box"),c=s.find("#reptTit"),r=$("div.mask-dark"),l=$("#rptOriginalurl"),d=s.find('textarea[name="description"]'),m=!1,p=0;s.find(".btn-close").click(t),r.click(t);var u="";$(".box-active").on("click",function(){if(!i)return o("请选择你想要举报的内容!"),!1;switch(i){case"3":if(u=$("#originalurl").val(),""==u||"http://"==u)return o("举报抄袭必须提供原创文章地址!"),$("#originalurl").focus(),!1;break;case"7":if(u=d.val(),!u)return o("请填写补充说明!"),d.focus(),!1;break;case"5":if(!flag)return o("请选择具体原因"),!1;break;case"6":if(!flag)return o("请选择具体原因"),!1;break;case"8":if(!flag)return o("请选择具体原因"),!1}var e={articleId:articleId,commentId:m?p:"",subType:a,type:i,originalUrl:u,description:d.val()},n=m?"report-comment":"report-article";$.ajax({url:blogUrl+"/phoenix/web/v1/"+n,type:"post",dataType:"json",data:e,xhrFields:{withCredentials:!0},success:function(e){200==e.code?(t(),sessionStorage.removeItem("usename"),sessionStorage.removeItem("articleId"),o("感谢您的举报,我们会尽快审核!"),$(".ipt-textarea").val(""),$(".box-botoom ul li").removeClass("box-active"),$(".box-content-bottom ul li").removeClass("box-active"),$(".box-content").eq(0).show().siblings().hide(),$("#cllcont").hide(),$(".content-input").val(""),flag=!1,i="",a="",u="",t()):o("举报失败")}})}),$("div.comment-box").on("click","a.btn-report",function(){p=$(this).parents("li.comment-line-box").data("commentid")}),window.showReport=e}),$(function(){}),$(function(){function e(){$("code.has-numbering").each(function(e,t){$(t).css("position","absolute"),$(t).parent("pre.prettyprint").css({position:"relative",height:$(t).outerHeight()+20+"px"})})}window.csdn=window.csdn?window.csdn:{},window.csdn.setSafariCodestyle=e}),$(function(){0==$(".btn-readmore").length&&($("#content_views").find("pre").each(function(e,t){t=$(t),t.height()>340&&(t.addClass("set-code-hide"),t.append('
    '))}),$(window).resize().scroll(),$(document).on("click",".hide-preCode-bt",function(){return $(this).parents("pre").removeClass("set-code-hide"),$(this).parents(".hide-preCode-box").hide().remove(),$(window).resize().scroll(),window.csdn.report&&"function"==typeof window.csdn.report.reportClick&&window.csdn.report.reportClick({spm:"1001.2101.3001.7365"}),!1}))}),$(function(){function e(e,t,n){var i=new Date,a=(i.getTime(),o(i,n)),s=new Date;s.setTime(a),document.cookie=e+"="+t+";expires="+s.toGMTString()+";domain=.csdn.net;path=/"}function t(e){return document.cookie.length>0&&(c_start=document.cookie.indexOf(e+"="),c_start!=-1)?(c_start=c_start+e.length+1,c_end=document.cookie.indexOf(";",c_start),c_end==-1&&(c_end=document.cookie.length),unescape(document.cookie.substring(c_start,c_end))):null}function o(e,t){var o=t.split(":"),n=parseInt(o[0]),i=parseInt(o[1]),a=parseInt(o[2]);e.setHours(n),e.setMinutes(i),e.setSeconds(a);var s=Date.parse(e);return s}var n=$("#overTheScreen"),i=$(".over-the-screen-close");!currentUserName&&showPcWindowAd&&(t("over_the_screen")||(n.fadeIn(),setTimeout(function(){i.fadeIn()},500),e("over_the_screen",(new Date).getTime(),"24:00:00"))),$(".over-the-screen-close").on("click",function(){n.fadeOut()}),document.addEventListener("visibilitychange",function(){n.fadeOut()},!1)}),window.csdn.insertcallbackBlock=computePos,$(function(){function e(){var e=document.referrer;if(e&&!isShowToQuestion&&e.indexOf("so.csdn.net")>-1){var o=' 搜索 ';$(".csdn-side-toolbar").prepend(o);var n='