PageSourceSearch

https://www.icex.es/etc.clientlibs/icex-elena/components/content/m…ibs.min.b77d6872428c1f0c5be2f0b03b2a91b0.js

js icex.es collected 2026-10-01 08:34:51 UTC 26,478 bytes, 899 lines download raw bytes

1const Notifications = {
2	// * -------------------------------------------
3	// * VARIABLES Y CONSTANTES
4	// * -------------------------------------------
5
6	notifications: [],
7	checkedBoxes: [],
8	itemsPerPage: 20,
9	isLoading: false,
10	hasMoreItems: null,
11	userData: null,
12	lastNotificationID: null,
13
14	// * -------------------------------------------
15	// * INICIALIZACIÓN Y CONFIGURACIÓN DE LISTENERS
16	// * -------------------------------------------
17
18	init() {
19		const containerPopUp =
20			document.querySelector('.container-general-pop-up') ||
21			document.querySelector('.container-general-notifications')
22
23		// Si no hay ningún contenedor, retornamos
24		if (!containerPopUp) return
25
26		// Comprobar si estamos en una URL que contiene "area-privada/notificaciones"
27		if (window.location.pathname.includes('area-privada/notificaciones')) {
28			// Si estamos en "area-privada/notificaciones", eliminamos el pop-up si existe
29			const popupElement = document.querySelector('.container-general-pop-up')
30			if (popupElement) {
31				popupElement.remove() // Eliminar el componente pop-up
32			}
33		}
34
35		// Continuamos con la lógica normal
36		Notifications.getCookie()
37		Notifications.setupDeleteAllListener()
38		Notifications.setupScrollListener()
39		Notifications.setupVerTodasListener()
40
41		//Notifications.handlePopupScroll()
42	},
43
44	async getCookie() {
45		try {
46			let userData = await cookieUtils.cookieUser
47
48			if (userData) {
49				Notifications.userData = userData
50				Notifications.lastNotificationID = null
51				MyNotificationsTags.setInitialTag()
52				Notifications.getNotifications()
53				return
54			} else console.error('No se obtuvieron datos')
55		} catch (error) {
56			console.error('Error al obtener la cookie', error)
57		}
58	},
59
60	setupDeleteAllListener() {
61		const deleteAllButton = document.querySelector('.js-delete-all')
62		if (deleteAllButton) {
63			deleteAllButton.addEventListener('click', () =>
64				Notifications.handleDeleteAll()
65			)
66		}
67	},
68
69	setupVerTodasListener(){
70
71			document.addEventListener("click", function(event){
72
73			if(event.target.matches(".my-notifications .page-title a")){
74				AnalyticsNotifications.pushToDataLayerClick("Notificaciones", "Ver todas", null)
75			}
76		})
77	
78
79	},
80
81	setupDeleteButton(notificationElement, idNotification) {
82		const buttonDelete = notificationElement.querySelector('.button-delete')
83		if (buttonDelete) {
84			buttonDelete.addEventListener('click', () =>{
85					AnalyticsNotifications.pushToDataLayerClick( null,  "Eliminar notificación", null)
86					Notifications.deleteNotification(idNotification, notificationElement)
87				}
88			)
89		}
90	},
91
92	setupScrollListener() {
93		window.addEventListener('scroll', () => {
94			if (Notifications.isPopup()) return
95
96			if (Notifications.isLoading || !Notifications.hasMoreItems) return
97
98			const scrollPosition = window.scrollY + window.innerHeight
99			const lastSection = document.querySelector('.js-previous .results')
100
101			if (!lastSection) return
102
103			const lastSectionBottomPosition =
104				lastSection.offsetTop + lastSection.offsetHeight
105
106			if (scrollPosition >= lastSectionBottomPosition - 100) {
107				Notifications.getNotifications()
108			}
109		})
110	},
111
112	handlePopupScroll() {
113		const isPopupVisible = Notifications.isPopup()
114		if (isPopupVisible) {
115			document.body.style.overflow = 'hidden'
116		} else {
117			document.body.style.overflow = ''
118		}
119	},
120
121	// * -------------------------------------------
122	// * MANEJO DE NOTIFICACIONES
123	// * -------------------------------------------
124
125	setupSeenLinks() {
126		const notificationsLinks = document.querySelectorAll('.js-link-result')
127
128		Array.from(notificationsLinks).forEach((link) => {
129			const listItem = link.closest('.result')
130			const isPopupVisible = Notifications.isPopup()
131			let notificationId;
132			if(isPopupVisible){
133				notificationId = listItem
134					.querySelector('.js-notification-id')
135					.getAttribute('id')
136				 
137			}else{
138				 notificationId = listItem
139						.querySelector('.js-checkbox')
140						.getAttribute('id')
141			}
142			
143			link.addEventListener('click', () => {
144				let titulo = link.closest(".result-container, .result").querySelector(".type-container p, .delete-container p").textContent
145				let texto = link.textContent.trim()
146				AnalyticsNotifications.pushToDataLayerClick(titulo, texto, document.querySelector(".tags button.tag--gray").textContent.trim().split(" (")[0], "notificación")
147				Notifications.updateNotification(notificationId, listItem)
148			})
149		})
150	},
151
152	updateNotification(idNotification, element) {
153		const xhr = new XMLHttpRequest()
154		xhr.withCredentials = true
155
156		const url = `/bin/icex/notifications?Operation=put`
157
158		xhr.open('POST', url)
159
160		xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8')
161
162		xhr.onload = function () {
163			if (xhr.readyState == 4 && xhr.status == 200) {
164				if (element) {
165					element.classList.remove('result--unseen')
166					element.classList.add('result--seen')
167				}
168
169				const updatedNotifications = Notifications.notifications.map(
170					(notification) => {
171						if (notification.idNotification == idNotification) {
172							return {
173								...notification,
174								estado: 'seen',
175							}
176						}
177						return notification
178					}
179				)
180
181				Notifications.notifications = updatedNotifications
182
183				Notifications.updateReadCounts()
184			} else {
185				console.error(`Error: ${xhr.status}`, error)
186			}
187		}
188
189		const body = JSON.stringify({
190			idNotification: idNotification,
191			estado: 'seen',
192		})
193
194		xhr.send(body)
195	},
196
197	handleDeleteAll() {
198		const isAllChecked = document.getElementById('allNotify').checked
199
200		if (isAllChecked) {
201			Notifications.deleteSelectedNotifications(
202				document.getElementsByClassName('js-checkbox')
203			)
204		} else {
205			Notifications.deleteSelectedNotifications(
206				Notifications.checkedBoxes.map((id) => document.getElementById(id))
207			)
208			Notifications.checkedBoxes = []
209		}
210	},
211
212	deleteSelectedNotifications(checkboxes) {
213		Array.from(checkboxes).forEach((box) => {
214			if (box && box.checked) {
215				const listItem = box.closest('.result')
216				Notifications.deleteNotification(box.id, listItem)
217			}
218		})
219	},
220
221	deleteNotification(idNotification, element) {
222		var xhr = new XMLHttpRequest()
223		xhr.withCredentials = true
224
225		const url = `/bin/icex/notifications?IdNotification=${idNotification}&IdUsuario=${Notifications.userData.userId}&Operation=delete`
226
227		xhr.open('POST', url)
228
229		xhr.onload = function () {
230			if (xhr.readyState == 4 && xhr.status == 200) {
231				if (element) {
232					element.remove()
233					Notifications.updateReadCounts()
234				} else {
235					console.error('Failed to delete notification')
236				}
237			} else {
238				console.error(`Error: ${xhr.status}`, error)
239			}
240		}
241
242		xhr.send()
243	},
244
245	// * -------------------------------------------
246	// * CARGA Y RENDERIZADO DE NOTIFICACIONES
247	// * -------------------------------------------
248
249	getNotifications(scroll = false) {
250		const { type: typeTag, state: stateTag } = Notifications.checkActualTag()
251
252		let url = `/bin/icex/notifications?IdUsuario=${Notifications.userData.userId}&items=${Notifications.itemsPerPage}`
253
254		if (typeTag !== 'all') {
255			url += `&tipo_notificacion=${typeTag}`
256		}
257
258		if (stateTag !== 'all') {
259			url += `&estado=${stateTag}`
260		}
261
262		if (Notifications.lastNotificationID != null) {
263			url += `&lastNotificationID=${Notifications.lastNotificationID}`
264		}
265
266		if (scroll && (Notifications.isLoading || !Notifications.hasMoreItems))
267			return
268
269		Notifications.toggleSpinner(false)
270		Notifications.isLoading = true
271		fetch(url)
272			.then((response) => response.json())
273			.then((data) => {
274				if (data.notifications.length > 0) {
275					this.hasMoreItems = true
276					Notifications.lastNotificationID =
277						data.notifications[data.notifications.length - 1].idNotification
278					Notifications.notifications = [
279						...Notifications.notifications,
280						...data.notifications,
281					]
282					Notifications.renderNotifications(data.notifications)
283				} else {
284					Notifications.renderNotifications(data.notifications)
285					Notifications.hasMoreItems = false
286				}
287
288				Notifications.toggleSpinner(true)
289				Notifications.isLoading = false
290			})
291			.catch(() => {
292				this.hasMoreItems = false
293				Notifications.toggleSpinner(true)
294				Notifications.isLoading = false
295			})
296	},
297
298	toggleSpinner(isHidden) {
299		if (Notifications.isPopup()) {
300			return
301		}
302		const spinner = document.querySelector('.js-spinner')
303		spinner.style.display = isHidden ? 'none' : 'block'
304	},
305
306	renderNotifications(notifications) {
307		const todayTable = Notifications.createResultsList('js-today')
308		const yesterdayTable = Notifications.createResultsList('js-yesterday')
309		const previousTable = Notifications.createResultsList('js-previous')
310
311		notifications.forEach((notification) => {
312			const notificationElement =
313				Notifications.createNotificationElement(notification)
314			Notifications.appendNotificationToTable(
315				notification,
316				notificationElement,
317				todayTable,
318				yesterdayTable,
319				previousTable
320			)
321		})
322
323		Notifications.updateTablesVisibility(
324			todayTable,
325			yesterdayTable,
326			previousTable
327		)
328		Notifications.updateReadCounts()
329
330		MyNotificationsCheckBox.setLinkNotifications()
331		MyNotificationsCheckBox.selectAllCheckBoxes()
332
333		Notifications.applyClickToAllCheckboxes()
334		Notifications.setupSeenLinks()
335	},
336
337	createResultsList(className) {
338		let container = document.querySelector(`.${className}`)
339		if (!container) {
340			container = document.createElement('div')
341			container.classList.add(className)
342			document.body.appendChild(container)
343		}
344
345		let resultsList = container.querySelector('.results')
346		if (!resultsList) {
347			resultsList = document.createElement('ul')
348			resultsList.classList.add('results')
349			container.appendChild(resultsList)
350		}
351
352		return resultsList
353	},
354
355	createNotificationElement(notification) {
356		const template = document.querySelector(
357			Notifications.isPopup()
358				? '.js-notification-template-popup'
359				: '.js-notification-template'
360		);
361		const element = template.cloneNode(true);
362		element.style.display = 'block';
363	
364		let notificationHtml = element.innerHTML
365			.replace('{{typeText}}', notification.tipo_notificacion)
366			.replace(
367				'{{type}}',
368				Notifications.mapNotificationType(notification.tipo_notificacion)
369			)
370			.replace(
371				'{{type2}}',
372				Notifications.mapNotificationType(notification.tipo_notificacion)
373			)
374			.replace('{{alreadyRead}}', notification.estado)
375			.replace('{{index}}', notification.idNotification)
376			.replace('{{index2}}', notification.idNotification)
377			.replace('{{title}}', notification.texto)
378			.replace('{{title2}}', notification.texto);
379	
380		if (notification.url) {
381			notificationHtml = notificationHtml.replace('#{{url}}', notification.url);
382		} else {
383			notificationHtml = notificationHtml.replace('<a', '<a class="no-hover"');
384			notificationHtml = notificationHtml.replace(/href="#{{url}}"/g, '');
385		}
386	
387		const wrapper = document.createElement('div');
388		wrapper.innerHTML = notificationHtml;
389	
390		const notificationElement = wrapper.firstElementChild;
391	
392		Notifications.setupDeleteButton(
393			notificationElement,
394			notification.idNotification
395		);
396		return notificationElement;
397	},
398	
399	
400
401	appendNotificationToTable(
402		notification,
403		notificationElement,
404		todayTable,
405		yesterdayTable,
406		previousTable
407	) {
408		const notificationDate = Notifications.getNotificationDate(
409			notification.timestamp
410		)
411		const [today, yesterday] = [new Date(), new Date()]
412		yesterday.setDate(today.getDate() - 1)
413
414		if (Notifications.isSameDay(notificationDate, today)) {
415			todayTable.appendChild(notificationElement)
416		} else if (Notifications.isSameDay(notificationDate, yesterday)) {
417			yesterdayTable.appendChild(notificationElement)
418		} else {
419			previousTable.appendChild(notificationElement)
420		}
421	},
422
423	appendNotificationElement(
424		notificationDate,
425		element,
426		todayTable,
427		yesterdayTable,
428		previousTable
429	) {
430		const [today, yesterday] = [new Date(), new Date()]
431		yesterday.setDate(today.getDate() - 1)
432
433		if (Notifications.isSameDay(notificationDate, today)) {
434			todayTable.querySelector('.results').appendChild(element)
435		} else if (Notifications.isSameDay(notificationDate, yesterday)) {
436			yesterdayTable.querySelector('.results').appendChild(element)
437		} else if (previousTable) {
438			previousTable.querySelector('.results').appendChild(element)
439		}
440	},
441
442	// * -------------------------------------------
443	// * UTILIDADES PARA FECHAS Y TABLAS
444	// * -------------------------------------------
445
446	isSameDay(date1, date2) {
447		return (
448			date1.getFullYear() === date2.getFullYear() &&
449			date1.getMonth() === date2.getMonth() &&
450			date1.getDate() === date2.getDate()
451		)
452	},
453
454	getNotificationDate(timestamp) {
455		return new Date(parseInt(timestamp, 10))
456	},
457
458	updateTablesVisibility(todayTable, yesterdayTable, previousTable) {
459		if (todayTable.children.length > 0)
460			todayTable.closest('.table').querySelector('.no-results-notification').style.display = 'none'
461		else todayTable.closest('.table').querySelector('.no-results-notification').style.display = 'block'
462		if (yesterdayTable.children.length > 0)
463			yesterdayTable
464				.closest('.table')
465				.querySelector('.no-results-notification').style.display = 'none'
466		else yesterdayTable
467			.closest('.table')
468			.querySelector('.no-results-notification').style.display = 'block'
469		if (previousTable.children.length > 0)
470			previousTable
471			.closest('.table')
472			.querySelector('.no-results-notification').style.display = 'none'
473		else previousTable
474			.closest('.table')
475			.querySelector('.no-results-notification').style.display = 'block'
476	},
477
478	clearTables() {
479		const todayTable = document.querySelector('.js-today .results')
480		const yesterdayTable = document.querySelector('.js-yesterday .results')
481		const previousTable = document.querySelector('.js-previous .results')
482
483		todayTable.innerHTML = ''
484		yesterdayTable.innerHTML = ''
485		previousTable.innerHTML = ''
486		Notifications.notifications = []
487
488		Notifications.isLoading = false
489		Notifications.hasMoreItems = true
490		Notifications.lastNotificationID = null
491
492		Notifications.updateTablesVisibility(
493			todayTable,
494			yesterdayTable,
495			previousTable
496		)
497		Notifications.updateReadCounts()
498		Notifications.getNotifications()
499	},
500
501	// * -------------------------------------------
502	// * ACTUALIZACIÓN DE CONTADORES Y ESTADOS
503	// * -------------------------------------------
504
505	updateReadCounts() {
506		const readCountElement = document.querySelector(
507			"button[data-type='read'] .js-num"
508		);
509		const noReadCountElement = document.querySelector(
510			"button[data-type='no-read'] .js-num"
511		);
512	
513		// Obtener el tag actual usando la función checkActualTag
514		const actualTag = this.checkActualTag();
515		if (!actualTag) {
516			console.error("No se pudo determinar el tag actual.");
517			return;
518		}
519
520		
521
522		fetch(`/bin/icex/notifications?IdUsuario=${Notifications.userData.userId}&total`)
523		.then((response) => {
524			if (!response.ok) {
525				throw new Error('Network response was not ok');
526			}
527			return response.json();
528		})
529		.then((data) => {
530			const { total } = data;
531	
532			// Actualizar los contadores de leídos y no leídos
533			const readCount = total.seen;
534			const noReadCount = total.unseen;
535
536			readCountElement.textContent = `(${readCount})`;
537			noReadCountElement.textContent = `(${noReadCount})`;
538			Header.setNotificationNumber();
539		})
540		.catch((error) => {
541			console.error(
542				'There has been a problem with your fetch operation:',
543				error
544			);
545		});
546
547		let url = `/bin/icex/notifications?IdUsuario=${Notifications.userData.userId}&total`;
548		if (actualTag.type !== 'all') {
549			url += `&tipo_notificacion=${actualTag.type}`;
550		}if (actualTag.state !== 'all'){
551			url += `&estado=${actualTag.state}`
552		}
553	
554		fetch(url)
555			.then((response) => {
556				if (!response.ok) {
557					throw new Error('Network response was not ok');
558				}
559				return response.json();
560			})
561			.then((data) => {
562	
563				Notifications.updateTableTitles(data);
564	
565			})
566			.catch((error) => {
567				console.error(
568					'There has been a problem with your fetch operation:',
569					error
570				);
571			});
572	},
573	
574
575	updateTableTitles(data) {
576		const tables = document.querySelectorAll('.tables-container .table');
577	
578		tables.forEach((table) => {
579			// Obtener el nombre de la tabla (hoy, ayer, anteriores) desde la clase
580			const tableClass = Array.from(table.classList).find((cls) =>
581				cls.startsWith('js-')
582			);
583			if (!tableClass) return;
584	
585			const key = tableClass.replace('js-', ''); // Extraer el nombre: today, yesterday, previous
586	
587			// Determinar el texto base según la clave
588			let baseText;
589			if (key === 'today') {
590				baseText = 'Hoy';
591			} else if (key === 'yesterday') {
592				baseText = 'Ayer';
593			} else if (key === 'previous') {
594				baseText = 'Anteriores';
595			} else {
596				return; // Si no coincide con ninguna tabla esperada, no hacer nada
597			}
598	
599			// Buscar las notificaciones en los datos usando la clave
600			const notifications = data[key];
601			if (notifications) {
602				const count = notifications.seen + notifications.unseen;
603				if (count != 0){
604					const titleElement = table.querySelector('.title .when');
605					if (titleElement) {
606						titleElement.textContent = `${baseText} (${count})`;
607					}
608				}else{
609					const titleElement = table.querySelector('.title .when');
610					if (titleElement) {
611						titleElement.textContent = `${baseText}`;
612					}
613				}
614				
615
616				
617			}
618		});
619	},
620	
621
622
623	applyClickToAllCheckboxes() {
624		document.querySelectorAll('.js-checkbox').forEach((box) => {
625			if (box.classList.contains('js-checkbox-all')) return
626
627			const boxId = box.getAttribute('id')
628			if (box.checked && !Notifications.checkedBoxes.includes(boxId)) {
629				Notifications.checkedBoxes.push(boxId)
630			}
631
632			box.addEventListener('click', () =>
633				Notifications.toggleCheckbox(box, boxId)
634			)
635		})
636	},
637
638	toggleCheckbox(box, boxId) {
639		if (box.checked) {
640			if (!Notifications.checkedBoxes.includes(boxId)) {
641				Notifications.checkedBoxes.push(boxId)
642			}
643		} else {
644			Notifications.checkedBoxes = Notifications.checkedBoxes.filter(
645				(id) => id !== boxId
646			)
647		}
648	},
649
650	// * -------------------------------------------
651	// * MAPEO Y AYUDA PARA TIPOS DE NOTIFICACIONES
652	// * -------------------------------------------
653
654	mapNotificationType(tipo_notificacion) {
655		const types = {
656			Aviso: 'warning',
657			Error: 'error',
658			Información: 'informative',
659			Confirmación: 'confirmation',
660		}
661		return types[tipo_notificacion] || 'unknown'
662	},
663
664	isPopup() {
665		const parentElement =
666			document.querySelector('.container-general-pop-up') ||
667			document.querySelector('.container-general')
668		return (
669			parentElement &&
670			parentElement.classList.contains('container-general-pop-up')
671		)
672	},
673
674	checkActualTag() {
675		const actualTag = MyNotificationsTags.actualTag.getAttribute('data-type')
676		if (actualTag) {
677			if (actualTag === 'all') return { type: 'all', state: 'all' }
678			if (actualTag === 'read') return { type: 'all', state: 'seen' }
679			if (actualTag === 'no-read') return { type: 'all', state: 'unseen' }
680			if (actualTag === 'warning') return { type: 'Aviso', state: 'all' }
681			if (actualTag === 'error') return { type: 'Error', state: 'all' }
682			if (actualTag === 'informative')
683				return { type: 'Información', state: 'all' }
684			if (actualTag === 'confirmation')
685				return { type: 'Confirmación', state: 'all' }
686		}
687	},
688}
689
690document.addEventListener('DOMContentLoaded', () => Notifications.init())
691
692
693
694
695const MyNotificationsCheckBox = {
696
697    checkboxList: '',
698    checkboxSelectAll: '',
699
700    init () {
701        this.setLinkNotifications()
702    //    this.setClickCheckBox()
703        this.selectAllCheckBoxes()
704        this.notificationsTypeComponent()
705	},
706
707    /* NOT NECESSARY BECAUSE THEY ARE CHECKBOX INPUTS */
708     /*setClickCheckBox () {
709        const notifications = document.querySelectorAll('.my-notifications');
710        const lastNotification = notifications[notifications.length - 1];
711    
712        // Verificar si lastNotification contiene .container-general
713        const containerGeneral = lastNotification.querySelector('.container-general');
714       if (containerGeneral) {
715            const checkboxList = containerGeneral.querySelectorAll('.js-checkbox');
716            
717            checkboxList.forEach(box => {             
718                box.addEventListener('click', () => {
719                    const isChecked = box.checked;
720                    box.checked = !isChecked;
721
722                    // box.classList.toggle('checkbox--checked')
723    
724                     if (box.dataset.checked === 'false') {
725                        box.dataset.checked = 'true';
726                    } else {
727                        box.dataset.checked = 'false';
728                    }     
729                });
730            });
731        }
732    },*/ 
733
734    selectAllCheckBoxes() {
735        const notifications = document.querySelectorAll('.my-notifications');
736        const lastNotification = notifications[notifications.length - 1];
737    
738        // Verificar si lastNotification contiene .container-general
739        const containerGeneral = lastNotification.querySelector('.container-general');
740        if (containerGeneral) {
741            // Verificar si containerGeneral contiene .js-checkbox-all
742            const checkboxSelectAll = containerGeneral.querySelector('.js-checkbox-all');
743            if (checkboxSelectAll) {
744                const checkboxList = containerGeneral.querySelectorAll('.js-checkbox');
745    
746                checkboxSelectAll.addEventListener('click', () => {
747                    const isChecked = checkboxSelectAll.checked;
748                    checkboxSelectAll.checked = isChecked;
749                    checkboxList.forEach(box => {
750                        box.checked = isChecked;
751                    });
752                    
753
754                    /* NOW THEY ARE USED AS CHECKBOX INPUTS */
755                    /* if (checkboxSelectAll.dataset.checked === 'true') {
756                        checkboxList.forEach(box => {
757                            box.classList.add('checkbox--checked');
758                        });
759                    } else {
760                        checkboxList.forEach(box => {
761                            box.classList.remove('checkbox--checked');
762                        });
763                    } */
764                });
765            }
766        }
767    },
768
769    setLinkNotifications() {
770        let link = document.querySelector('.my-notifications .container-general-pop-up .top-page .page-title a');
771        let notificationsButton = document.querySelector('.notifications-link');
772    
773        if (window.screen.width > 768 && notificationsButton !== null) {
774            const hrefAttributeValue = link && link.getAttribute('href');
775     
776            if (hrefAttributeValue) {
777                notificationsButton.href = hrefAttributeValue;
778            }
779        }
780    
781        window.addEventListener('resize', function() {
782            if (window.innerWidth > 768 && notificationsButton !== null) {
783                const hrefAttributeValue = link && link.getAttribute('href');
784                if (hrefAttributeValue) {
785                    notificationsButton.href = hrefAttributeValue;
786                }
787            } else if (notificationsButton !== null) {
788                notificationsButton.href = '#';
789            }
790        });
791    },
792
793    notificationsTypeComponent() {
794        let tipoComponente = document.querySelector('.container-general').getAttribute('data-type-component')
795
796        if (tipoComponente == 'events;') {
797            let menuEvento = document.querySelector('.menu-user');
798            let notificacionesEvento = document.querySelector('.notifications');
799
800            if (menuEvento !== null && notificacionesEvento !== null) {
801                notificacionesEvento.classList.add('notificationsEvent');
802                menuEvento.classList.add('menu-user-evento');
803            }
804        }
805    }
806}
807
808
809document.addEventListener('DOMContentLoaded', () => {
810    MyNotificationsCheckBox.init()    
811})
812  
813
814document.addEventListener('DOMContentLoaded', () => {
815    MyNotificationsTags.init();
816});
817
818const MyNotificationsTags = {
819    actualTag: null,
820    init() {
821        this.setClickTags();
822    },
823
824    setInitialTag() {
825        const initialTag = document.querySelector('.js-tag-all');
826
827        if (initialTag) {
828            MyNotificationsTags.actualTag = initialTag
829        }
830    },
831
832    setClickTags() {
833        document.querySelectorAll('.tag').forEach(tag => {
834            tag.addEventListener('click', event => {
835                const notification = event.target.closest('.my-notifications');
836                if (notification) {
837                    this.tagAll = notification.querySelector('.js-tag-all');
838                    this.tagList = notification.querySelectorAll('.tag');
839                    this.resultRows = notification.querySelectorAll('.result');
840
841                    if (MyNotificationsTags.actualTag === tag) {
842                        return;
843                    }
844
845                    AnalyticsNotifications.pushToDataLayerClick( "Notificaciones" ,null, tag.textContent.trim().split(" (")[0], "filtro")
846                    MyNotificationsTags.actualTag = tag;
847                    Notifications.clearTables();
848                    this.toggleTag(tag);
849                    this.filterTagType(tag);
850                }
851            });
852        });
853    },
854
855
856    toggleTag(tag) {
857        if (tag.classList.contains('tag--gray')) {
858            this.disableTag(tag);
859        } else {
860            this.tagList.forEach(othertag => {
861                this.disableTag(othertag);
862            });
863            this.activateTag(tag);
864        }
865    },
866
867    activateTag(tag) {
868        tag.classList.remove('tag--white');
869        tag.classList.add('tag--gray');
870    },
871
872    disableTag(tag) {
873        tag.classList.remove('tag--gray');
874        tag.classList.add('tag--white');
875    },
876
877    filterTagType(tag) {
878        this.resetFilters();
879
880        this.resultRows.forEach(row => {
881            if (tag.classList.contains('tag--gray')) {
882                if (
883                    (tag.dataset.type !== 'read' && tag.dataset.type !== 'no-read' && tag.dataset.type !== row.dataset.type) ||
884                    (tag.dataset.type === 'read' && row.classList.contains('result--unseen')) ||
885                    (tag.dataset.type === 'no-read' && row.classList.contains('result--seen'))
886                ) {
887                    row.classList.add('result-hidden');
888                }
889            }
890        });
891    },
892
893    resetFilters() {
894        this.resultRows.forEach(row => {
895            row.classList.remove('result-hidden');
896        });
897    }
898};
899

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.