HEX
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/8.0.30
System: Linux multiplicar 3.10.0-1160.102.1.el7.x86_64 #1 SMP Tue Oct 17 15:42:21 UTC 2023 x86_64
User: root (0)
PHP: 8.0.30
Disabled: NONE
Upload Files
File: /var/www/html/ucsuenolar.sumar.com.py/theme/moove/javascript/customlinks.js
/**
 * Inserta botones "Propósito" y "Valores" en la barra de navegación principal
 * de Moove, detectando también cuando el color/estructura cambia (como en cat. 9).
 */
(function() {
  document.addEventListener('DOMContentLoaded', function() {
    try {
      const url = new URL(window.location.href);
      const catid = url.searchParams.get("categoryid");
      if (!catid || !window.location.pathname.includes('/course/index.php')) return;

      // Enlaces por categoría
      const enlaces = {
        1: [
          {texto: 'Propósito', url: '/propositos1.php'},
          {texto: 'Valores', url: '/valores1.php'}
        ],
        2: [
          {texto: 'Propósito', url: '/propositos2.php'},
          {texto: 'Valores', url: '/valores2.php'}
        ],
        9: [
          {texto: 'Propósito', url: '/propositos9.php'},
          {texto: 'Valores', url: '/valores9.php'}
        ]
      };

      // Agregar clase al body para categoría 9 (para aplicar CSS azul)
      if (catid === '9') {
        document.body.classList.add('category-9');
      }

      // Esperar a que cargue la barra de navegación principal
      const observer = new MutationObserver(() => {
        // La barra roja (o azul en cat 9) se genera como .secondary-navigation .nav-tabs
        const barra = document.querySelector('.secondary-navigation .nav-tabs, .moremenu .nav-tabs');
        if (barra && enlaces[catid]) {
          enlaces[catid].forEach(link => {
            const li = document.createElement('li');
            li.className = 'nav-item';
            li.innerHTML = `
              <a class="nav-link" href="${link.url}" target="_blank" rel="noopener">
                ${link.texto}
              </a>`;
            barra.appendChild(li);
          });
          observer.disconnect();
        }
      });

      observer.observe(document.body, {childList: true, subtree: true});
    } catch (err) {
      console.error('Error insertando botones personalizados:', err);
    }
  });
})();