코드 복사'); 🎜> }
function loadEncoderJs() {
var 인코더Js = document.createElement('script')
encoderJs.type = 'text/javascript'
encoderJs.src = ' http: //common.cnblogs.com/script/encoder.js';
var node = document.getElementsByTagName('script')[0]
node.parentNode.insertBefore(encoderJs, node); 🎜> }
function copyCnblogsCode(element) {
var codeContainer = getCnblogsCodeContainer(element);
var cbCode = getCnblogsCodeText(codeContainer)
var textarea = document.createElement('textarea' );
$(textarea).val(cbCode).select();
$(textarea).css("width", $(codeContainer).css("width")); (textarea ).css("height", $(codeContainer).css("height"));
$(textarea).css("font-family", "Courier New")
$( textarea) .css("font-size", "12px");
$(textarea).css("line-height", "1.5")
$(codeContainer).parent().html (textarea );
$(textarea).select();
$("
코드를 복사하려면 Ctrl C를 누르세요
").insertAfter($(textarea)); >}
function getCnblogsCodeContainer(element) {
var codeContainer = $(element).parent().parent().parent().find("pre")
if (codeContainer) .length = = 0) {
codeContainer = $(element).parent().parent().parent().find("div").first()
}
return codeContainer;
}
function getCnblogsCodeText(codeContainer) {
var cbCode = 'n' $(codeContainer).html()
.replace(/ /g, ' ')
. 교체(/
/ig, 'n')
.replace(/<[^>]*>/g, ''); (/n (s*d )/ig, 'n');
cbCode = cbCode.replace(/n/g, 'rn')
if (typeof Encoder != 정의되지 않음) {
cbCode = Encoder .htmlDecode(cbCode);
}
cbCode = $.trim(cbCode);
return cbCode;
}
function showRunCode(element) {
var codeCopyDiv = $(element).find("div.cnblogs_code_toolbar")
if (codeCopyDiv.length) {
$(codeCopyDiv).append('< a href= "javascript:void(0);" onclick="runJsCode(this)">코드 실행')
}
}
function runJsCode (요소) {
var codeContainer = getCnblogsCodeContainer(element);
var cbCode = getCnblogsCodeText(codeContainer);
var newwin = window.open('', "_blank", ''); 🎜> newwin.document.open('text/html', 'replace');
newwin.opener = null
newwin.document.write(cbCode)
newwin.document.close() ;
}
//#endregion
패키지 다운로드