Web Syntax Highlight 적용
페이지 정보
작성자 Admin쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 0건 조회 775회 작성일 24-04-30 17:30본문
extend, plugin 형태가 아닌 board skin 형태로 적용.
view.skin.php 에 아래 코드 적용 가능하나 view.tail.skin 별도 파일로 적용.
<link rel=stylesheet href=//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/a11y-dark.min.css>
<script src=//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/highlight.min.js></script>
<style>
pre { position:relative; -ms-overflow-style:none; }
pre::-webkit-scrollbar { display:none; }
.copyButton { position:absolute; cursor:pointer; top:10px; right:10px; }
</style>
<script>
copyImage = "<?php echo G5_URL.'/copy_hand.png'?>";
copyMp3 = "<?php echo G5_URL.'/copy_sound.mp3'?>";
document.write("<div class=cmt_contents style=display:none></div>");
commentZone = document.getElementsByClassName("cmt_contents");
cmtLimit = commentZone.length;
for (cmt = 0; cmt < cmtLimit; cmt++) commentZone[cmt].id = "cmt_num_" + (Number(cmt) + 1);
editorName = "<?php echo $board['bo_use_dhtml_editor'] ? $config['cf_editor'] : "none"; ?>";
function codeCopy() {
copyText.style.display = "block";
copyText.value = arguments[0].innerText.trim();
copyText.select();
document.execCommand("copy");
copyText.style.display = "none";
copySound.play();
alert("COPY CODE!!!");
}
function hlMode() {
this[arguments[0]].innerHTML = this[arguments[0]].innerHTML.replace(/[code]/gi, "<div name=code_" + arguments[0] + ">").replace([code]/gi, "</div>");
nameN = document.getElementsByName("code_" + arguments[0]);
for (n = 0; n < nameN.length; n++) {
if (arguments[0] == "bo_v_con") {
if (editorName == "smarteditor2") changeCode = (nameN[n].innerHTML.replace(/<p>/gi, "").replace(/</p>/gi, "<br>") + "<br>").replace(/<br><br>/gi, "<br>");
else if (editorName == "cheditor5") changeCode = nameN[n].innerHTML.replace(/<(/p|p)([^>]*)>/gi, "") + "<br>";
else if (editorName == "none") changeCode = nameN[n].innerHTML.replace(/<br><br>/gi, "*br*").replace(/<br>/gi, "").replace(/*br*/gi, "<br>") + "<br>";
}
else changeCode = nameN[n].innerHTML.replace(/<br><br>/gi, "*br*").replace(/<br>/gi, "").replace(/*br*/gi, "<br>") + "<br>";
nameN[n].innerHTML = "<pre><code>" + changeCode + "<img class=copyButton src=" + copyImage + " onclick=codeCopy(parentElement)></code></pre>";
}
}
hlGroup = ["bo_v_con"];
for (cmtPlus = 0; cmtPlus < cmtLimit; cmtPlus++) hlGroup.push(commentZone[cmtPlus].id);
for (hl in hlGroup) hlMode(hlGroup[hl]);
hljs.initHighlighting();
document.write("<textarea id=copyText style=display:none></textarea>");
document.write("<audio id=copySound src=" + copyMp3 + " ></audio>");
codeZone = document.getElementsByTagName("code");
for (cz = 0; cz < codeZone.length; cz++) {
codeZone[cz].style.fontSize = "1rem";
codeZone[cz].style.fontFamily = "times";
codeZone[cz].style.padding = "20px";
codeZone[cz].style.borderRadius = "15px";
codeZone[cz].style.backgroundColor = "#000000";
}
첨부파일
- copy_hand.png (854byte) 1회 다운로드 | DATE : 2024-05-04 13:24:02
- copy_sound.mp3 (19.6K) 1회 다운로드 | DATE : 2024-05-04 13:24:02
댓글목록
등록된 댓글이 없습니다.