1var isUserLogged = false; 2var auxNotifications = null; 3var lang = 'es'; 4 5function togglesidenavMenuWithId(id) { 6 var sidenavMenu = document.getElementById(id); 7 var sidenav = document.querySelector('#' + id + ' .sidenav'); 8 if (sidenavMenu.classList.contains('opened')) { 9 document.getElementsByTagName('body')[0].style.overflow = 'auto'; 10 sidenav.classList.remove('opened'); 11 setTimeout(function () { 12 sidenavMenu.classList.remove('opened'); 13 }, 150); 14 } else { 15 document.getElementsByTagName('body')[0].style.overflow = 'hidden'; 16 sidenavMenu.classList.add('opened'); 17 setTimeout(function () { 18 sidenav.classList.add('opened'); 19 }, 150); 20 }; 21} 22function toggleFooterMenu() { 23 var body = document.querySelector('body'); 24 var footerMenu = document.getElementById('footerMenu'); 25 if (footerMenu.classList.contains('opened')) { 26 footerMenu.classList.remove('opened'); 27 } else { 28 footerMenu.classList.add('opened'); 29 setTimeout(() => { 30 window.scrollTo(0, body.scrollHeight); 31 }, 250); 32 }; 33} 34function toggleSubmenu(event) { 35 const parent = event.parentElement; 36 if (parent.classList.contains('active')) { 37 parent.classList.remove('active'); 38 } else { 39 parent.classList.add('active'); 40 } 41} 42function closePanelFromOverlay(event, item) { 43 const id = item.id; 44 if (id == "notificationPanel") { 45 tagging_seur("header", "close", "", "campana_notificaciones"); 46 } 47 if (event.target.id === id) { 48 togglesidenavMenuWithId(id); 49 } 50} 51 52function toggleElementById(id) { 53 var id = document.getElementById(id); 54 if (id.classList.contains('opened')) { 55 id.classList.remove('opened'); 56 } else { 57 id.classList.add('opened'); 58 } 59} 60 61// ---- 62function getDate(date) { 63 const fecha = new Date(date); 64 const dia = fecha.getDate(); 65 const mes = fecha.getMonth() + 1; // Los meses comienzan desde 0 66 const anio = fecha.getFullYear(); 67 return `${dia}/${mes}/${anio}`; 68} 69function getHour(date) { 70 const fecha = new Date(date); 71 const horas = fecha.getHours(); 72 const minutos = fecha.getMinutes().toString().padStart(2, '0'); 73 return `${horas}:${minutos}`; 74} 75function getAllIds() { 76 const elems = []; 77 auxNotifications.forEach((notif) => { 78 if (!notif.fromCMS) { 79 elems.push(notif.id_notificacion); 80 } 81 }); 82 return elems; 83} 84 85function deleteNotif(id) { 86 const newNotifications = []; 87 auxNotifications.forEach((item) => { 88 if (item.id_notificacion !== id) { 89 newNotifications.push(item); 90 } 91 }); 92 if (isUserLogged) { 93 changeNotifStatusApi([id], 'BORRADA'); 94 } 95 setCookieMiSeur('seur_push', JSON.stringify(newNotifications)); 96 setNotifications(newNotifications); 97} 98function deleteAllNotif() { 99 if (isUserLogged) { 100 changeNotifStatusApi(getAllIds(), 'BORRADA'); 101 } 102 deleteCookieMiSeur('seur_push'); 103 document.getElementById('NotificationsList').innerHTML = ''; 104} 105function markAsReadNotif() { 106 setTimeout(() => { 107 document.querySelector('#notificationsBtn .badge').classList.add('hidden'); 108 }, 200); 109} 110function openNotifPanel() { 111 togglesidenavMenuWithId('notificationPanel'); 112 markAsReadNotif(); 113 changeNotifStatusApi(getAllIds(), 'LEIDA'); 114} 115 116function changeNotifStatusApi(ids, status) { 117 const body = { 118 ids_notificacion: ids, 119 estado: status, 120 } 121 const url = `/miseur-contratacion/backend`; 122 const requestOptions = { 123 method: 'POST', 124 headers: new Headers({ 125 'Content-Type': 'application/json', 126 'Access-Control-Allow-Origin': '*' //url, 127 }), 128 body: JSON.stringify(body) 129 }; 130 fetch(url + '/modificarEstadoNotificacion', requestOptions) 131 .then(function (response) { 132 if (response.ok) { 133 return response.json(); 134 } else { 135 throw new Error('Error en la respuesta de la API'); 136 } 137 }) 138 .catch(function (error) { 139 console.log("Error catch"); 140 }); 141} 142function setNotifications(notifications) { 143 auxNotifications = []; 144 const ul = document.getElementById('NotificationsList'); 145 let html = ''; 146 let count = 0; 147 notifications.forEach((item, id) => { 148 if (item.estado !== 'LEIDA') { 149 count++; 150 } 151 const newItem = !item.id_notificacion ? { 152 ...item, 153 estado: 'NUEVA', 154 fecha_notificacion: item.fecha_inicio, 155 id_notificacion: `cms_${id}`, 156 fromCMS: true, 157 } : item; 158 auxNotifications.push(newItem); 159 if (newItem.fromCMS) { 160 html += '<li class="shadow">'; 161 } else { 162 html += '<li>'; 163 } 164 const fecha = getDate(item.fecha_notificacion ?? item.fecha_inicio); 165 if (id === 0 || fecha !== getDate(notifications[id - 1].fecha_notificacion)) { 166 html += `<div class="date">${fecha}</div>`; 167 } 168 const deleteButton = `<button onclick="deleteNotif(${item.id_notificacion ?? id})" title="Eliminar de mi lista"><img src="/images/svg/icon-close.svg"></button>`; 169 html += `<div class="hour">${getHour(item.fecha_notificacion ?? item.fecha_inicio)}</div>`; 170 html += `<div class="info-header"><img src="/images/svg/icon-${item.tipo === 'Incidencia' ? 'warn' : 'circle'}.svg"><h4 class="info-name">${item.titulo}</h4>${newItem.fromCMS ? '' : deleteButton}</div>`; 171 html += `<div class="cms-text">${item.descripcion}</div>`; 172 html += '</li>' 173 }); 174 ul.innerHTML = html; 175 176 if (count === 0) { 177 markAsReadNotif(); 178 } 179} 180function getNotificationsFromCMS(isLogged) { 181 const url = `/miseur/backend`; 182 const requestOptions = { 183 method: 'GET', 184 headers: new Headers({ 185 'Content-Type': 'application/json', 186 'Access-Control-Allow-Origin': '*' //url, 187 }), 188 }; 189 fetch(`${url}/contenidos?seccion=ms_notificaciones&logado=${isLogged}&idioma=${lang}`, requestOptions) 190 .then(function (response) { 191 if (response.ok) { 192 return response.json(); 193 } else { 194 throw new Error('Error en la respuesta de la API'); 195 } 196 }) 197 .then(function (data) { 198 setNotifications(data); 199 }) 200 .catch(function (error) { 201 console.log(error); 202 }); 203} 204 205function checkSessionData() { 206 var userName = getCookieMiSeur('seur_user_name'); 207 var siglas = getCookieMiSeur('seur_user_siglas'); 208 if (!userName) { 209 getNotificationsFromCMS(0); 210 return; 211 } 212 userName = decodeURI(userName).replace(/"/g, ''); 213 siglas = decodeURI(siglas).replace(/"/g, ''); 214 isUserLogged = true; 215 setUserData(userName, siglas);
216 const notifications = getCookieMiSeur('seur_push'); 217 if (!!notifications) { 218 const decodedJSONString = decodeURIComponent(notifications); 219 setNotifications(JSON.parse(decodedJSONString)); 220 } else { 221 getNotificationsFromCMS(1); 222 } 223 document.getElementById('sidenavNotLogged').classList.add('hidden'); 224 document.getElementById('btnDoLogin').classList.add('hidden'); 225 if (!document.getElementById('menuLogin').classList.contains('opened')) { 226 document.getElementById('menuLogin').classList.remove('opened'); 227 } 228 document.getElementById('showConfigNotifications').classList.remove('hidden'); 229} 230 231function getCookieMiSeur(nombre) { 232 const cookies = document.cookie.split(';'); 233 for (let i = 0; i < cookies.length; i++) { 234 const cookie = cookies[i].trim(); 235 if (cookie.startsWith(nombre + '=')) { 236 var result = cookie.substring(nombre.length + 1); 237 return result; 238 } 239 } 240 return null; 241} 242function setCookieMiSeur(nombre, valor, diasParaExpirar) { 243 const fechaExpiracion = new Date(); 244 fechaExpiracion.setDate(fechaExpiracion.getDate() + diasParaExpirar); 245 246 const valorCodificado = encodeURIComponent(valor); 247 const cookie = `${nombre}=${valorCodificado}; expires=${fechaExpiracion.toUTCString()}; path=/; domain=.seur.com`; 248 249 document.cookie = cookie; 250} 251function deleteCookieMiSeur(nombre) { 252 document.cookie = `${nombre}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`; 253} 254 255function setUserData(username, siglas) { 256 document.getElementById('userData').innerHTML = `<button class="btn-user-menu d-none d-xl-flex" title="Abrir menú usuario" onclick="toggleElementById('userMenu')"><p class="user-name">${username}</p><img src="/images/svg/icon-arrowBottom.svg" /></button><a href="https://www.seur.com/miseur/mis-datos/editar" class="user-siglas d-xl-none" title="Datos personales"><p>${siglas}</p></a>`; 257 document.getElementById('sidenavLogged').innerHTML = `<a href="https://www.seur.com/miseur/mis-datos/editar" title="Datos usuario"><div class="icon-user user-siglas"><p>${siglas}</p></div><p class="user-name">${username}</p></a>`; 258 259 incluir_elementos_miseur(); 260 setTimeout(() => calculateSearchPosition(), 200); 261 262} 263 264function calculateSearchPosition() { 265 var pos = document.getElementsByClassName('notifications-btn').length ? document.getElementsByClassName('notifications-btn')[0].offsetLeft : null; 266 const sw = document.getElementById('searchWrapper'); 267 if (!!pos && !!sw) { 268 const parentWidth = sw.parentElement.offsetWidth; 269 const value = parentWidth - pos; 270 sw.style.right = value + 'px'; 271 sw.style.maxWidth = 'calc(100% - ' + (value + 160) + 'px)'; 272 } 273} 274function sendSearchData(ev) { 275 if (ev.keyCode === 13) { 276 const palabras = document.getElementById('searchInput').value; 277 if (idioma == "en") { 278 window.location = "https://www.seur.com/en/results/?l=en&txtPalabra=" + encodeURI(palabras); 279 } else { 280 window.location = "https://www.seur.com/es/resultados/?l=es&txtPalabra=" + encodeURI(palabras); 281 } 282 } 283} 284 285window.addEventListener("DOMContentLoaded", () => { 286 lang = getCookieMiSeur('lang') ?? 'es'; 287 checkSessionData(); 288 setTimeout(() => calculateSearchPosition(), 200); 289}); 290window.addEventListener("resize", () => { 291 setTimeout(() => calculateSearchPosition(), 200); 292});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.