์ž์œ ๊ฒŒ์‹œํŒ

  • ์‹œ๋กค๋กœ์ง€ ๋‚˜์Šค ๊ทธ๋ˆ„๋ณด๋“œ ์ฝ”๋“œ ํ•˜์ด๋ผ์ดํŠธ์™€ copy ๋ฒ„ํŠผ ๋งŒ๋“ค๊ธฐ

    ํŽ˜์ด์ง€ ์ •๋ณด

    profile_image
    ์ž‘์„ฑ์ž์ฒœ์‚ฌ ์กฐํšŒ 8,308ํšŒ ์ž‘์„ฑ์ผ 2021-09-25 01:52:05 ๋Œ“๊ธ€ 0

    ๋ณธ๋ฌธ

    ์•„๋ž˜ ๋‚ด์šฉ์€ highlight.php ๋“ฑ ์ ๋‹นํ•œ ์ด๋ฆ„์œผ๋กœ ๊ทธ๋ˆ„๋ณด๋“œ extend ํด๋”์— ๋„ฃ๊ธฐ

    ย 

    HighlightJs Copy Code Badge Component

    ย 

    ๋Š” ์ฒจ๋ถ€ ํŒŒ์ผ ์ฐธ๊ณ (์ถœ์ฒ˜:ย https://github.com/RickStrahl/highlightjs-badge)

    ย 

    [code]

    <?
    ย  function hh_tail_sub()
    ย  {
    ย  ย  global $wr_id;

    ย  ย  // ๊ฒŒ์‹œํŒ์—์„œ view.php ํ˜ธ์ถœํ• ๋•Œ ์ ์šฉํ•˜๋„๋ก
    ย  ย  if($_SERVER['SCRIPT_NAME'] != '/bbs/board.php' ย || !$wr_id) return;
    ย  ?>

    <!--
    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/agate.min.css">
    <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/highlight.min.js"></script>
    -->

    ย  ย  <style>
    ย  ย  ย  ย  /* optionally override badge styling */
    ย  ย  ย  ย  .code-badge {
    ย  ย  ย  ย  ย  ย  ย background: #555 !important;
    ย  ย  ย  ย  ย  ย  ย padding: 8px !important;
    ย  ย  ย  ย  }
    ย  ย  ย  ย  .code-badge-copy-icon {
    ย  ย  ย  ย  ย  ย  font-size: 1.3em !important;
    ย  ย  ย  ย  }
    ย  ย  </style>

    ย ย  ย <style>
    ย ย  ย pre {
    ย ย  ย ย ย  ย overflow: auto;
    ย ย  ย }
    ย ย  ย </style>

    <!-- end customization template -->

    <link rel="stylesheet" href="/highlight/vs2015.css">
    <script src="/highlight/highlight.min.js"></script>

    <!-- then add this badge component -->
    <script src="/highlight/highlightjs-badge.min.js"></script>

    <script>
    function sh(id) {
    ย  var $id = $("#" + id);
    ย  if ($id.length > 0) {
    ย  ย  var html = $id.html();
    ย  ย  html = html.split("[code]").join("<pre><code>");
    ย  ย  html = html.split("[/code]").join("</pre></code>");
    ย  ย  $id.html(html);
    ย  ย  $id.find("pre>code").each(function() {
    ย  ย  ย  var text = $.trim($(this).text());
    ย  ย  ย  $(this).text(text);
    ย  ย  });
    ย  }
    }

    $(function() {ย 
    ย  sh("bo_v_con");ย 

    ย  hljs.initHighlighting();
    });
    </script>

    <script>
    ย  ย  setTimeout(function () {
    ย  ย  ย  ย  var pres = document.querySelectorAll("pre>code");
    ย  ย  ย  ย  for (var i = 0; i < pres.length; i++) {
    ย  ย  ย  ย  ย  ย  hljs.highlightBlock(pres[i]);
    ย  ย  ย  ย  }
    ย  ย  ย  ย  var options = {
    ย  ย  ย  ย  ย  ย  // Delay in ms used for `setTimeout` before badging is applied
    ย  ย  ย  ย  ย  ย  // Use if you need to time highlighting and badge application
    ย  ย  ย  ย  ย  ย  // since the badges need to be applied afterwards.
    ย  ย  ย  ย  ย  ย  // 0 - direct execution (ie. you handle timing
    ย  ย  ย  ย  ย  ย  loadDelay:0,

    ย  ย  // CSS class(es) used to render the copy icon.
    ย  ย  copyIconClass: "fa fa-copy", ย  ย ย 
    ย  ย  // optional content for icons class (<i class="fa fa-copy"></i> or <i class="material-icons">file_copy</i>)
    ย  ย ย 

    ย  ย  // CSS class(es) used to render the done icon.
    ย  ย  checkIconClass: "fa fa-check text-success",

    ย  ย  ย  ย  ย  ย  // hook to allow modifying the text before it's pasted
    ย  ย  ย  ย  ย  ย  onBeforeTextCopied: function(text, codeElement) {
    ย  ย  ย  ย  ย  ย  ย  return text; ย  // ย you can fix up the text here
    ย  ย  ย  ย  ย  ย  }
    ย  ย  ย  ย  };
    ย  ย  ย  ย  window.highlightJsBadge(options);
    ย  ย  },10);
    </script>

    ย  <?
    ย  }
    ย  add_event('tail_sub', 'hh_tail_sub', G5_HOOK_DEFAULT_PRIORITY);
    ?>

    [/code]

    ์ฒจ๋ถ€ํŒŒ์ผ

    ๋Œ“๊ธ€๋ชฉ๋ก

    ๋“ฑ๋ก๋œ ๋Œ“๊ธ€์ด ์—†์Šต๋‹ˆ๋‹ค.