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.

1 line
7.3 KiB
JavaScript

2 years ago
!function(e){"use strict";function t(e){var t=e.target||e.srcElement,n=document.documentElement.scrollTop;if(t.className.indexOf(d)>-1){e.preventDefault();var i=document.getElementById("hljs-copy-el");i||(i=document.createElement("textarea"),i.style.position="absolute",i.style.left="-9999px",i.style.top=n+"px",i.id="hljs-copy-el",document.body.appendChild(i)),i.textContent=e.currentTarget.innerText,o("#hljs-copy-el");try{var r=document.execCommand("copy");t.dataset.title=r?p:u,r&&setTimeout(function(){t.dataset.title=c},1e3)}catch(a){t.dataset.title=u}}}function n(e){var t=e.target||e.srcElement,n=document.documentElement.scrollTop;if(t.className.indexOf(d)>-1){e.preventDefault();var i=document.getElementById("hljs-copy-el");i||(i=document.createElement("textarea"),i.style.position="absolute",i.style.left="-9999px",i.style.top=n+"px",i.id="hljs-copy-el",document.body.appendChild(i)),i.textContent=e.currentTarget.parentNode.innerText,o("#hljs-copy-el");try{var r=document.execCommand("copy");t.dataset.title=r?p:u,r&&setTimeout(function(){t.dataset.title=c},1e3)}catch(a){t.dataset.title=u}}}function o(e){if(e="string"==typeof e?document.querySelector(e):e,navigator.userAgent.match(/ipad|ipod|iphone/i)){var t=e.contentEditable,n=e.readOnly;e.contentEditable=!0,e.readOnly=!0;var o=document.createRange();o.selectNodeContents(e);var i=window.getSelection();i.removeAllRanges(),i.addRange(o),e.setSelectionRange(0,999999),e.contentEditable=t,e.readOnly=n}else e.select()}function i(){var e=document.createElement("style");e.type="text/css",e.innerHTML=["pre{position: relative}","pre:hover .{0}{display: block}",".{0}{","display: none;","position: absolute;","right: 4px;","top: 4px;","font-size: 12px;","color: #4d4d4d;","background-color: white;","padding: 2px 8px;","margin: 8px;","border-radius: 4px;","cursor: pointer;"," box-shadow: 0 2px 4px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.05);","}",".{0}:after{","content: attr(data-title)","}","code .{0}{","margin: 2px 8px;","}"].join("").format(d),document.getElementsByTagName("head")[0].appendChild(e)}function r(){"complete"===document.readyState?a():e.addEventListener("DOMContentLoaded",a)}function a(){try{var e;if("ckeditor"==h){e=document.querySelectorAll("code.hljs");for(var t in e)e.hasOwnProperty(t)&&s(e[t].parentNode)}else{e=j;for(var t in e)e.hasOwnProperty(t)&&s(e[t])}}catch(n){console.error("CopyButton error: ",n)}}function l(e){var t=e.target||e.srcElement;t.className.indexOf(d)>-1&&(navigator.userAgent.match(/AppleWebKit.*Mobile.*/)?window.location.href="https://passport.csdn.net/account/login?ref=codecopy":getCookie("UserName")||window.csdn.loginBox.show())}function s(e){var t="1001.2101.3001.4259";if("object"==typeof e&&null!==e){var n=".signin(event)",o="hljs",i=".copyCode(event)";"mdeditor"===h&&(o="mdcp"),i=o+i,w&&(i=o+n),e.innerHTML=e.innerHTML+('<div class="{0} {2}" data-title="{1}" data-report-click=\'{"spm":"'+t+"\"}'></div>").format(d,c,m),"hljs"===o?e.querySelector(".hljs-button").setAttribute("onclick",i):(e.setAttribute("onclick",i),e.style.position="unset")}}if(window.ActiveXObject||"ActiveXObject"in window)return!1;for(var d="hljs-button",c="复制",u="复制失败",p="复制成功",h=void 0,m="",f=navigator.userAgent.toLowerCase(),g=["android","iphone","symbianos","windows phone","ipad","ipod"],v=!1,y=0;y<g.length;y++)if(f.indexOf(g[y])>=0){v=!0;break}var w=!v&&("string"==typeof currentUserName&&0===currentUserName.length);w&&(c="登录后复制",m="signin"),String.prototype.format=String.prototype.f=function(){var e=arguments;return!!this&&this.replace(/\{(\d+)\}/g,function(t,n){return e[n]?e[n]:t})};var j=document.querySelectorAll("pre code");document.querySelectorAll("div.htmledit_views").length>0?(e.hljs.initCopyButtonOnLoad=r,e.hljs.addCopyButton=s,e.hljs.copyCode=n,e.hljs.signin=l,i(),h="ckeditor"):j.length>0&&(window.mdcp?window.mdcp:window.mdcp={},window.mdcp.copyCode=t,window.mdcp.signin=l,r(),i(),h="mdeditor")}(window),function(e,t){"use strict";function n(){var e=t.createElement("style");e.type="text/css",e.innerHTML=p(".{0}{border-collapse:collap