You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3 lines
96 KiB
JavaScript

3 years ago
function setCopyBtn(){$(".CopyToClipboard").each(function(){var t=new ZeroClipboard.Client;t.setHandCursor(!0),t.addEventListener("load",function(t){}),t.addEventListener("mouseOver",function(t){var e=t.movie.parentNode.parentNode.parentNode.parentNode.parentNode.nextSibling.innerHTML;e=e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"),t.setText(e)}),t.addEventListener("complete",function(t,e){alert("代码已经复制到你的剪贴板。")}),t.glue(this,this.parentNode)})}function computePos(){"object"==typeof toolBar&&(toolBar.setPosX(),toolBar.computePositon())}function getRecommendListUrl(){var t=[[],[]];return $(".recommend-box div.recommend-item-box").each(function(e,o){if($(o).data("url")){var i=$(o).data("url").toLowerCase().split("://"),n=$(o).data("url").toLowerCase().split("article/details/");t[0].push(2==i.length?i[1]:i[0]),t[1].push(2==n.length?"article/details/"+n[1]:n[0])}}),t}function baidudatatemp(t,e){var o=highlight.map(function(t){return t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")});o="("+o.join("|")+")";var i=new RegExp(o,"gi"),n=/<[^>]*>/g,a=t["abstract"].replace(n,"").replace(i,"<em>$1</em>"),s=t.dispTime.replace(/^(\d*)-/,""),c=t.linkUrl,r=t.title.replace(n,"").replace(i,"<em>$1</em>"),l='"extra":"{\\"utm_medium\\":\\"distribute.pc_relevant.none-task-blog-baidujs_'+baiduSearchType+"-"+e+'\\"}",',d='<div class="recommend-item-box baiduSearch clearfix" data-report-view=\'{"mod":"popu_387",'+l+'"spm":"1001.2101.3001.4242","dest":"'+c+'","strategy":"baidujs_'+baiduSearchType+'","ab":"new","index":"'+e+'"}\'>\t <div class="content-box">\t\t <div class="content-blog display-flex">\t\t\t <div class="title-box">\t\t\t\t <a href="'+c+'" target="_blank" data-report-click=\'{"mod":"popu_387",'+l+'"spm":"1001.2101.3001.4242","dest":"'+c+'","strategy":"baidujs_'+baiduSearchType+'","ab":"new","index":"'+e+'"}\' data-report-query="utm_medium=distribute.pc_relevant.none-task-blog-baidujs_'+baiduSearchType+"-"+e+'&spm=1001.2101.3001.4242">\t\t\t\t\t <div class="tit ellipsis-online ellipsis-online-1">'+r+'</div>\t\t\t\t </a>\t\t\t </div> <div class="info-box display-flex"> <div class="info display-flex"> <span class="info-block">'+s+'</span> </div> </div> </div> <div class="desc-box"> <a href="'+c+'" target="_blank" data-report-click=\'{"mod":"popu_387",'+l+'"spm":"1001.2101.3001.4242","dest":"'+c+'","strategy":"baidujs_'+baiduSearchType+'","ab":"new","index":"'+e+'"}\' data-report-query="utm_medium=distribute.pc_relevant.none-task-blog-baidujs_'+baiduSearchType+"-"+e+'&spm=1001.2101.3001.4242"> <div class="desc ellipsis-online ellipsis-online-1">'+a+"</div> </a> </div> </div> </div>";return d}function showResult(t){var e=[],o=recommendRegularDomainArr||["blog.csdn.net/.+/article/details/","download.csdn.net/download/","edu.csdn.net/course/detail/ "],i=new RegExp(o.join("|"));if(!t||t.length<=0)return!1;if(t&&t.length>0)for(var n=0;n<t.length;n++)if(t[n].linkUrl.split("?")[0].toLowerCase().indexOf(curentUrl.split("://")[1].toLowerCase())===-1&&i.test(t[n].linkUrl)&&""!==t[n].title){var a=t[n].linkUrl.split("?")[0].split("://"),s=2==a.length?a[1]:a[0],c=t[n].linkUrl.split("?")[0],r=t[n].title.split("_")[0].replace(/[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~@#¥%……&*()——\-+={}|《》?:“”【】、;‘',。、<em><\/em>&quot;]/g,"").replace(/\s/g,"").toLowerCase();2==s.split("article/details/").length&&(c="article/details/"+s.split("article/details/")[1]),$.inArray(s.toLowerCase(),getRecommendListUrl()[0])==-1&&$.inArray(c.toLowerCase(),getRecommendListUrl()[1])==-1&&n<10&&r!==articleTitleContent&&e.push(t[n])}var l=$(".insert-baidu-box").children().not("script").not("dl"),d="",m=0,p=0;(!baiduCount||baiduCount<=0)&&(baiduCount=2)
return g},t.prototype.getReplyInfo=function(t){var e=t.split(/\[reply]([\s\S]*?)\[\/reply\][\r\n]{0,1}/gi);return e},t.prototype.getQuoteInfo=function(t){var e=t.split(/\[quote=([\w#\.]+)\]([\s\S]*?)\[\/quote\][\r\n]{0,2}/gi);return e},t.prototype.getCodeInfo=function(t){var e=t.replace(/\[code=([\w#\.]+)\]([\s\S]*?)\[\/code\]/gi,function(t,e,o){return""==$.trim(o)?"":'<pre name="code2" class="code2 '+e+'"><code>'+i(o.trim())+"</code></pre>"});return e},t.prototype.replaceNewUBB=function(t){return t=t.replace(/\[face\]([^\]]+):([^\]]+)\[\/face\]/gi,'<img src="//g.csdnimg.cn/static/face/$1/$2" alt="表情包"/>')},t.prototype.replayComment=function(t){var e=t.Id,o=t.User;this.txtComment.attr("placeholder","回复:"+t.text).data("replayUser",o),this.commentTxt.val(e)},t.prototype.commentCode=function(){var t=this;this.commtCode.find("a").click(function(){var e="[code="+$(this).data("code")+"]\n\n[/code]",o=t.txtComment.val();t.txtComment.val(o+e)})},t.prototype.comment=function(){function t(t){if(!currentUserName)return e.setStorage();window.localStorage.removeItem("AM_comment_data");var o=$(t).find(":submit"),i={commentId:e.commentTxt.val(),content:e.txtComment.val(),articleId:articleId};if(i.replyId&&$.trim(i.content)&&(i.content="[reply]"+e.txtComment.data("replayUser")+"[/reply]"+i.content),""===$.trim(i.content))showToast({text:"请填写评论内容",bottom:"10%",zindex:9e3,speed:500,time:1500});else{var n=blogUrl+"phoenix/web/v1/comment/submit";$.ajax({url:n,type:"post",dataType:"json",data:i,xhrFields:{withCredentials:!0},beforeSend:function(){o.prop("disabled",!0).val("提交中")},success:function(t){200===t.code?(e.commentForm.trigger("reset"),e.commentTxt.val(""),e.txtComment.data("replayUser","").attr("placeholder","想对作者说点什么"),e.cancelBtnToggle(!1),l=t.data,e.init(),e.removeStorage(),showToast({text:"评论成功,审核后显示",bottom:"10%",zindex:9e3,speed:500,time:1500})):showToast({text:t.message,bottom:"10%",zindex:9e3,speed:500,time:1500})},complete:function(){o.prop("disabled",!1).val("发表评论")}})}return!1}var e=this;e.commentForm.submit(function(e){e.preventDefault();var o=this;try{window.csdn.userLogin.loadAjax(function(e){t(o)})}catch(i){t(o)}})},t.prototype.deleteComment=function(t){var e=this,o=$("#article_id").val();if(confirm("你确定要删除这篇评论吗?")){var i=blogUrl+"phoenix/web/v1/comment/delete",n={commentId:t,articleId:o};$.ajax({url:i,type:"post",dataType:"json",data:n,xhrFields:{withCredentials:!0},success:function(t){200===t.code?e.commentPageObj.go(e.pageIndex):showToast({text:"删除失败,请重新操作!",bottom:"10%",zindex:9e3,speed:500,time:1500})}})}},t.prototype.insertRightCommnetPrompt=function(){if(window.localStorage.getItem("AM_comment_Prompt_show"))return!1;window.localStorage.setItem("AM_comment_Prompt_show",!0);var t=$(".right_recommend_comment"),e=$(".right_recommend_comment_Prompt");e.length>0?e.fadeIn(300):t.prepend('<div class="right_recommend_comment_Prompt"><div class="text">新的评论在这里</div><div class="arrow"></div></div>'),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=o,t.prototype.cancelBtnToggle=function(t){t?this.cancelBtn.removeClass("d-none"):this.cancelBtn.addClass("d-none")},t.prototype.cancelBtnBindEvent=function(){var t=this;this.cancelBtn.on("click",function(){t.txtComment.attr("placeholder","想对作者说点什么").data("replayUser","").val(""),t.commentTxt.val(""),t.cancelBtnToggle(!1)})},$(document).on("keydown",".comment-content",function(t){var e=t||event;(e.ctrlK
$.each(c,function(t,e){o+='<div class="question-tip-txt"> <span class="time" >'+e.time+'</span> <span class="name">'+e.username+'</span> <span class="text">解决了问题:</span> <span class="question">'+e.question+"</span> </div>"}),$(".csdn-side-toolbar .question").append(e),$(".csdn-side-toolbar .question-tip-content").append(o),$(".question-tip-txt:first").siblings().hide(),setInterval(function(){$(".question-tip-txt:visible").slideUp("slow",function(){void 0===$(this).next(".question-tip-txt")[0]?$(".question-tip-txt:first").fadeIn("slow"):$(this).next(".question-tip-txt").fadeIn("slow")})},2e3);var n=document.documentElement.scrollTop||document.body.scrollTop;i(n,s)}}function i(t,e){a&&t>.5*e&&$(".csdn-side-toolbar .side-question-box").length>0&&$(".csdn-side-toolbar .side-question-box").fadeIn()}getSideToolbarTime=setInterval(function(){$(".csdn-side-toolbar").length>0&&(clearInterval(getSideToolbarTime),t(),o())},1e3);var n="此内容解决你搜索的问题?";"control"===showSearchText&&(n="此内容是您要找的内容?"),"secondText"===showSearchText&&(n="此内容解决你搜索的问题?");var a=!0,s=document.documentElement.clientHeight,c=[{time:"5分钟前",username:"java小白_李同学",question:"给数组扩容失败求解答"},{time:"7分钟前",username:"叮当猫的风筝",question:"SSD训练迭代过程突然停止"},{time:"8分钟前",username:"不取名字了吧",question:"python selenium库相关函数在哪里找"},{time:"10分钟前",username:"冉水",question:"Vue使用Axios通过post方式访问后台为什么后台获取不到传递过来的参数"},{time:"12分钟前",username:"一袖如何两青蛇",question:"求解为什么我的jupyter notebook无法运行代码"},{time:"13分钟前",username:"m0_53936501",question:"有关c++的一个问题不知哪里出错了求教?"},{time:"14分钟前",username:"zzzlj1",question:"利用指针编写程序对具有6个元素的整型数组找出其中最大值并计算出该数组的平均数。怎么写呀"},{time:"20分钟前",username:"见过自讼",question:"关于java实现对象型数组的一个问题"},{time:"22分钟前",username:"chaochaoyaya",question:"C++中存入的数据和实际输出流的数据不一致,请教各位大佬这个如何解决呢?"},{time:"27分钟前",username:"赶鸭子",question:"如何求集合之间的交集(重复元素)?"},{time:"32分钟前",username:"iamalarak",question:"pip装不了东西求教"},{time:"38分钟前",username:"nibiru0810",question:"PIP warning Ignoring Invalid distribution"},{time:"42分钟前",username:"godiegodieover",question:"PTA练习 C语言 删除行末空白字符"},{time:"50分钟前",username:"Playing with fire",question:"急救 vc代码应该怎样修改"},{time:"53分钟前",username:"weixin_39052466",question:"求教C#调用C++dll接口出现问题参数定义是否正确调用方式是否正确"},{time:"1小时前",username:"小肥宅子",question:"Integer.parseInt()转换String类型 抛异常"},{time:"1小时前",username:"超哥",question:"女程序员提问女程序员后台Java开发真的有描述的那么吃香么之前被拒就是不要女性"},{time:"2小时前",username:"悠然岁月",question:"原代码复制重写报以下错误我也很奇怪这个dict到底是谁怎么来的传什么参"},{time:"2小时前",username:"",question:"使用pip命令提示WARNING: Ignoring invalid distribution"}];window.onscroll=function(){var t=document.documentElement.scrollTop||document.body.scrollTop;i(t,s)},$(document).on("click",".csdn-side-toolbar .fade-question-box",function(){$(".csdn-side-toolbar .side-question-box").fadeOut(),a=!1}),$(document).on("mouseenter",".csdn-side-toolbar .question",function(t){$(".csdn-side-toolbar .side-question-box").fadeIn()}),$(document).on("click",".csdn-side-toolbar .question",function(t){window.open("https://ask.csdn.net/new?spm=1001.2101.3001.6040")}),$(document).on("click",".csdn-side-toolbar .side-question-box",function(t){t.stopPropag