• File: admin-theme.js
  • Full Path: /home/daemondevin/public_html/blog/assets/admin/fa/admin-theme.js
  • Date Modified: 10/17/2026 7:00 PM
  • File size: 1005 B
  • MIME-type: application/javascript
  • Charset: utf-8
// Admin dark mode: follows the system setting until a choice is made. Loaded in the head to avoid a flash.
(function () {
  var d = document.documentElement, k = 'tsblog-theme', s = null;
  try { s = localStorage.getItem(k); } catch (e) {}
  if (s) d.setAttribute('data-theme', s);
  document.addEventListener('click', function (e) {
    var b = e.target.closest && e.target.closest('[data-theme-toggle]');
    if (!b) return;
    var dark = d.getAttribute('data-theme') ? d.getAttribute('data-theme') === 'dark' : matchMedia('(prefers-color-scheme: dark)').matches;
    var next = dark ? 'light' : 'dark';
    d.setAttribute('data-theme', next);
    d.classList.toggle('dark', next === 'dark');
    d.setAttribute('data-bs-theme', next);
    try { localStorage.setItem(k, next); } catch (e) {}
  });
  var t = d.getAttribute('data-theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
  d.classList.toggle('dark', t === 'dark');
  d.setAttribute('data-bs-theme', t);
})();