403Webshell
Server IP : 62.72.47.131  /  Your IP : 216.73.217.34
Web Server : Apache/2.4.66 (Debian)
System : Linux 975cdb959a49 5.14.0-611.55.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 19 15:19:29 EDT 2026 x86_64
User :  ( 501)
PHP Version : 8.3.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/html/wp-content/themes/medicate/assets/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/wp-content/themes/medicate/assets/js/kc-article-toc.js
/**
 * Auto table of contents for long-form posts (h2 / h3), inspired by clinical education article layouts.
 */
(function () {
  'use strict';

  function slugify(text) {
    var s = String(text)
      .trim()
      .toLowerCase()
      .replace(/\s+/g, '-');
    /* Keep Thai letters for IDs (HTML5 allows Unicode IDs). */
    s = s.replace(/[^\u0E00-\u0E7Fa-z0-9\-]/g, '');
    s = s.replace(/-+/g, '-').replace(/^-|-$/g, '');
    return s;
  }

  function ensureId(el, used, index) {
    if (el.id) {
      return el.id;
    }
    var base = slugify(el.textContent) || 'kc-section-' + index;
    var id = base;
    var n = 0;
    while (used[id] || document.getElementById(id)) {
      n += 1;
      id = base + '-' + n;
    }
    used[id] = true;
    el.id = id;
    return id;
  }

  function buildToc(root) {
    var headings = root.querySelectorAll('h2, h3');
    if (headings.length < 2) {
      return null;
    }

    var used = {};
    var ol = document.createElement('ol');
    ol.className = 'kc-toc-list';

    for (var i = 0; i < headings.length; i++) {
      var h = headings[i];
      /* Skip headings inside aside / nav */
      if (h.closest('.kc-article-end-cta, .kc-toc, nav')) {
        continue;
      }
      var id = ensureId(h, used, i);
      var li = document.createElement('li');
      li.className = h.tagName === 'H2' ? 'kc-toc-item kc-toc-item--h2' : 'kc-toc-item kc-toc-item--h3';
      var a = document.createElement('a');
      a.href = '#' + id;
      a.textContent = h.textContent.replace(/\s+/g, ' ').trim();
      li.appendChild(a);
      ol.appendChild(li);
    }

    if (ol.children.length < 2) {
      return null;
    }

    var nav = document.createElement('nav');
    nav.className = 'kc-toc';
    nav.setAttribute('aria-label', 'สารบัญ');

    var toggle = document.createElement('button');
    toggle.type = 'button';
    toggle.className = 'kc-toc-toggle';
    toggle.setAttribute('aria-expanded', 'true');
    var panelId = 'kc-toc-panel-' + String(Date.now());
    toggle.setAttribute('aria-controls', panelId);
    toggle.innerHTML =
      '<span class="kc-toc-toggle__label">สารบัญ</span><span class="kc-toc-toggle__hint" aria-hidden="true">แสดง / ซ่อน</span>';

    var panel = document.createElement('div');
    panel.id = panelId;
    panel.className = 'kc-toc-panel';

    panel.appendChild(ol);
    nav.appendChild(toggle);
    nav.appendChild(panel);

    toggle.addEventListener('click', function () {
      var collapsed = nav.classList.toggle('kc-toc--collapsed');
      toggle.setAttribute('aria-expanded', collapsed ? 'false' : 'true');
      panel.hidden = collapsed;
    });

    return nav;
  }

  function init() {
    var root = document.querySelector('.single-post .kc-entry-prose');
    if (!root) {
      return;
    }
    if (root.querySelector('.kc-toc')) {
      return;
    }
    var toc = buildToc(root);
    if (!toc) {
      return;
    }
    root.insertBefore(toc, root.firstChild);
  }

  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', init);
  } else {
    init();
  }
})();

Youez - 2016 - github.com/yon3zu
LinuXploit