2026-01-06 11:58:52 +00:00
|
|
|
/**
|
2026-01-06 18:15:43 +00:00
|
|
|
* DOCLOUD - Custom JavaScript
|
|
|
|
|
* - Botón CTA "Acceso ICSManager"
|
|
|
|
|
* - Toggle modo oscuro/claro
|
|
|
|
|
* - Integración Zammad
|
2026-01-06 11:58:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', initCustomFeatures);
|
|
|
|
|
|
|
|
|
|
function initCustomFeatures() {
|
2026-01-06 18:15:43 +00:00
|
|
|
setDefaultDarkMode();
|
2026-01-06 11:58:52 +00:00
|
|
|
fixLogoLink();
|
2026-01-06 18:15:43 +00:00
|
|
|
addThemeToggle();
|
2026-01-06 11:58:52 +00:00
|
|
|
addLoginButton();
|
2026-01-06 18:15:43 +00:00
|
|
|
// Cargar Zammad de forma diferida
|
2026-01-06 11:58:52 +00:00
|
|
|
if ('requestIdleCallback' in window) {
|
|
|
|
|
requestIdleCallback(loadZammadForm);
|
|
|
|
|
} else {
|
|
|
|
|
setTimeout(loadZammadForm, 2000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-06 18:15:43 +00:00
|
|
|
/**
|
|
|
|
|
* Establece modo oscuro por defecto
|
|
|
|
|
*/
|
|
|
|
|
function setDefaultDarkMode() {
|
|
|
|
|
var savedTheme = localStorage.getItem('docloud-theme');
|
|
|
|
|
if (!savedTheme) {
|
|
|
|
|
document.documentElement.setAttribute('data-theme', 'dark');
|
|
|
|
|
localStorage.setItem('docloud-theme', 'dark');
|
|
|
|
|
} else {
|
|
|
|
|
document.documentElement.setAttribute('data-theme', savedTheme);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-06 11:58:52 +00:00
|
|
|
/**
|
|
|
|
|
* Asegura que el logo siempre enlace al home
|
|
|
|
|
*/
|
|
|
|
|
function fixLogoLink() {
|
|
|
|
|
var logoLink = document.querySelector('.logo-link');
|
|
|
|
|
if (logoLink) {
|
|
|
|
|
logoLink.href = '/';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2026-01-06 18:15:43 +00:00
|
|
|
* Añade el toggle de modo claro/oscuro
|
2026-01-06 11:58:52 +00:00
|
|
|
*/
|
2026-01-06 18:15:43 +00:00
|
|
|
function addThemeToggle() {
|
2026-01-06 11:58:52 +00:00
|
|
|
var header = document.querySelector('.sidebar-header');
|
|
|
|
|
if (!header) return;
|
|
|
|
|
|
2026-01-06 18:15:43 +00:00
|
|
|
var toggleBtn = document.createElement('button');
|
|
|
|
|
toggleBtn.className = 'theme-toggle-btn';
|
|
|
|
|
toggleBtn.setAttribute('aria-label', 'Cambiar tema');
|
|
|
|
|
toggleBtn.setAttribute('title', 'Alto contraste');
|
|
|
|
|
updateToggleIcon(toggleBtn);
|
|
|
|
|
|
|
|
|
|
toggleBtn.addEventListener('click', function() {
|
|
|
|
|
var currentTheme = document.documentElement.getAttribute('data-theme');
|
|
|
|
|
var newTheme = currentTheme === 'dark' ? 'light' : 'dark';
|
|
|
|
|
document.documentElement.setAttribute('data-theme', newTheme);
|
|
|
|
|
localStorage.setItem('docloud-theme', newTheme);
|
|
|
|
|
updateToggleIcon(toggleBtn);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Crear contenedor para los botones del header
|
|
|
|
|
var btnContainer = document.createElement('div');
|
|
|
|
|
btnContainer.style.cssText = 'display:flex;align-items:center;gap:12px;';
|
|
|
|
|
btnContainer.appendChild(toggleBtn);
|
|
|
|
|
header.appendChild(btnContainer);
|
|
|
|
|
|
|
|
|
|
return btnContainer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Actualiza el icono del toggle según el tema
|
|
|
|
|
*/
|
|
|
|
|
function updateToggleIcon(btn) {
|
|
|
|
|
var isDark = document.documentElement.getAttribute('data-theme') === 'dark';
|
|
|
|
|
btn.innerHTML = isDark ? '☀' : '☽';
|
|
|
|
|
btn.title = isDark ? 'Modo claro' : 'Modo oscuro';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Añade el botón CTA "Acceso ICSManager"
|
|
|
|
|
*/
|
|
|
|
|
function addLoginButton() {
|
|
|
|
|
var btnContainer = document.querySelector('.sidebar-header > div:last-child');
|
|
|
|
|
if (!btnContainer) {
|
|
|
|
|
var header = document.querySelector('.sidebar-header');
|
|
|
|
|
if (!header) return;
|
|
|
|
|
btnContainer = document.createElement('div');
|
|
|
|
|
btnContainer.style.cssText = 'display:flex;align-items:center;gap:12px;';
|
|
|
|
|
header.appendChild(btnContainer);
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-06 11:58:52 +00:00
|
|
|
var loginBtn = document.createElement('a');
|
|
|
|
|
loginBtn.href = 'https://icsmanager.docloud.es/ics1';
|
|
|
|
|
loginBtn.className = 'header-login-btn';
|
2026-01-06 18:15:43 +00:00
|
|
|
loginBtn.textContent = 'Acceso ICSManager';
|
2026-01-06 11:58:52 +00:00
|
|
|
loginBtn.setAttribute('rel', 'noopener');
|
2026-01-06 18:15:43 +00:00
|
|
|
loginBtn.setAttribute('title', 'Acceder al panel de gestión');
|
2026-01-06 11:58:52 +00:00
|
|
|
|
2026-01-06 18:15:43 +00:00
|
|
|
btnContainer.appendChild(loginBtn);
|
2026-01-06 11:58:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Carga jQuery y Zammad Form
|
|
|
|
|
*/
|
|
|
|
|
function loadZammadForm() {
|
|
|
|
|
var feedbackBtn = document.createElement('button');
|
|
|
|
|
feedbackBtn.id = 'zammad-feedback-form';
|
|
|
|
|
feedbackBtn.textContent = 'Contactar';
|
|
|
|
|
document.body.appendChild(feedbackBtn);
|
|
|
|
|
|
|
|
|
|
if (typeof jQuery === 'undefined') {
|
|
|
|
|
var jqueryScript = document.createElement('script');
|
|
|
|
|
jqueryScript.src = 'https://code.jquery.com/jquery-3.6.0.min.js';
|
|
|
|
|
jqueryScript.onload = loadZammadScript;
|
|
|
|
|
document.head.appendChild(jqueryScript);
|
|
|
|
|
} else {
|
|
|
|
|
loadZammadScript();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2026-01-06 18:15:43 +00:00
|
|
|
* Carga el script de Zammad
|
2026-01-06 11:58:52 +00:00
|
|
|
*/
|
|
|
|
|
function loadZammadScript() {
|
|
|
|
|
var zammadScript = document.createElement('script');
|
|
|
|
|
zammadScript.id = 'zammad_form_script';
|
|
|
|
|
zammadScript.src = 'https://soporte.tecnico.com.es/assets/form/form.js';
|
|
|
|
|
zammadScript.onload = initZammadForm;
|
|
|
|
|
document.head.appendChild(zammadScript);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Inicializa el formulario de Zammad
|
|
|
|
|
*/
|
|
|
|
|
function initZammadForm() {
|
|
|
|
|
if (typeof jQuery !== 'undefined' && jQuery.fn.ZammadForm) {
|
|
|
|
|
jQuery('#zammad-feedback-form').ZammadForm({
|
2026-01-06 18:15:43 +00:00
|
|
|
messageTitle: 'Contacto con Soporte Técnico',
|
2026-01-06 11:58:52 +00:00
|
|
|
messageSubmit: 'Enviar',
|
2026-01-06 18:15:43 +00:00
|
|
|
messageThankYou: 'Gracias por contactarnos (#%s). Responderemos a la brevedad.',
|
2026-01-06 11:58:52 +00:00
|
|
|
modal: true
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})();
|