PageSourceSearch

https://archivohistoricodelatlantico.com/statics/js/activities.js?…=b77c119e2304c9496524f14eea98bafcc17e4a4d

js archivohistoricodelatlantico.com collected 2026-10-02 20:53:28 UTC 6,168 bytes, 174 lines download raw bytes

1CustomNamespace.loader()
2window.addEventListener(pcsphpGlobals.events.configurationsAndWindowLoad, function (e) {
3	CustomNamespace.loader(null, false)
4
5	const isLH = pcsphpGlobals.frontConfigurationsFromBackend.isLH ?? null
6	const local = isLH !== null ? isLH : false
7	const apiDomain = local ? "http://localhost/clena-2025/src/" : "https://clena.org/"
8	const thisDomain = pcsphpGlobals.baseURL
9
10	const agendaURL = new URL('agenda-data/all', apiDomain)
11	agendaURL.searchParams.append('domain', 'archivohistoricodelatlantico.com')
12	agendaURL.searchParams.append('per_page', 1000)
13	const agendaSingleBaseURL = new URL('evento-agenda/SLUG', thisDomain).href
14
15	const mainContainer = $('[main-elements]')
16	const previousContainer = $('[previous-elements-section] [previous-elements]')
17	const templates = {
18		main: document.querySelector('template[main-element-template]').innerHTML,
19		previous: document.querySelector('template[previous-element-template]').innerHTML,
20	}
21
22	const currentDate = new Date()
23	//const currentDate = new Date('2026-12-01T00:00:00') //Fecha fija para pruebas
24	const currentMonth = currentDate.getMonth() + 1
25	const maxMonth = currentMonth + 1
26
27	let month = null
28	let dateForMonth = new Date(currentDate)
29	let isMaxMonth = false
30	const nextMonthButton = $('[next-month]')
31	const previousMonthButton = $('[previous-month]')
32	const updateMonth = function () {
33		month = !isNaN(month) && month >= currentMonth && month <= maxMonth ? month : currentMonth
34		dateForMonth.setMonth(month - 1)
35		isMaxMonth = month === maxMonth
36
37		if (isMaxMonth) {
38			nextMonthButton.hide()
39			previousMonthButton.show()
40		} else {
41			nextMonthButton.show()
42			previousMonthButton.hide()
43		}
44	}
45
46	updateMonth()
47	nextMonthButton.on('click', function (e) {
48		e.preventDefault()
49		if (!isMaxMonth) {
50			month += 1
51			updateMonth()
52			loadElements(month)
53			if (month === maxMonth) {
54				nextMonthButton.hide()
55			}
56		}
57	})
58	previousMonthButton.on('click', function (e) {
59		e.preventDefault()
60		if (isMaxMonth) {
61			month = currentMonth
62			dateForMonth.setFullYear(currentDate.getFullYear())
63			updateMonth()
64			loadElements(month)
65			if (month === maxMonth) {
66				nextMonthButton.hide()
67			}
68		}
69	})
70
71	loadElements(month)
72
73	function loadElements(month) {
74
75		CustomNamespace.loader()
76
77		agendaURL.searchParams.set('month', dateForMonth.getMonth() + 1)
78		agendaURL.searchParams.set('year', dateForMonth.getFullYear())
79		//Escribir el nombre del mes en el front
80		$('[month-name]').text(dateForMonth.toLocaleDateString('es-ES', { month: 'long' }).replace(/^./, c => c.toUpperCase()))
81
82		//Limpia los contenedores
83		mainContainer.html('')
84		previousContainer.html('')
85
86		getRequest(agendaURL).done(function (response) {
87
88			const elements = response.elements
89			let hasPrevious = false
90
91			for (const element of elements) {
92
93				const maxTitleLength = 16
94				let title = element.title
95				title = title.length > maxTitleLength ? title.substring(0, maxTitleLength - 3) + '...' : title
96				const singleURL = agendaSingleBaseURL.replace('SLUG', `${friendlyURL(element.title)}-${element.preferSlug}`)
97				const publicDate = new Date(element.publicDate)
98				const startDate = element.startDate !== null ? new Date(element.startDate) : null
99				const endDate = element.endDate !== null ? new Date(element.endDate) : null
100				let startEndText = ''
101				const now = new Date()
102
103				const isPrevious = (function () {
104					if (startDate !== null && endDate !== null) {
105						return endDate < now
106					} else if (startDate !== null) {
107						return startDate < now
108					} else if (endDate !== null) {
109						return endDate < now
110					} else {
111						return false
112					}
113				})()
114				hasPrevious = hasPrevious || isPrevious
115				const templateElement = isPrevious ? templates.previous : templates.main
116				let templateElementProcessed = templateElement
117					.replace(/\{\{IMAGE\}\}/gmi, new URL(element.mainImage, apiDomain).href)
118					.replace(/\{\{LINK\}\}/gmi, singleURL)
119					.replace(/\{\{TITULO\}\}/gmi, title)
120					.replace(/\{\{HORA\}\}/gmi, publicDate.toLocaleTimeString('es-ES', {
121						hour: 'numeric',
122						minute: '2-digit',
123						hour12: true // Usa AM/PM
124					}))
125					.replace(/\{\{LUGAR\}\}/gmi, element.place)
126					.replace(/\{\{DIRECCION\}\}/gmi, element.address)
127					.replace(/\{\{CATEGORIA\}\}/gmi, element.categoryName)
128				const parsedElement = $(templateElementProcessed)
129
130				//Procesa las fechas
131				let hasDates = startDate !== null || endDate !== null
132				if (hasDates) {
133					let fechaParteA = ''
134					let fechaParteB = ''
135					if (startDate !== null && endDate !== null) {
136						fechaParteA = `${formatDate(startDate, 'd')}`
137						fechaParteB = `Al ${formatDate(endDate, 'd')} de ${formatDate(endDate, 'M')}`
138					} else if (startDate !== null) {
139						fechaParteA = `${formatDate(startDate, 'd')}`
140						fechaParteB = `${formatDate(startDate, 'M')}`
141					} else if (endDate !== null) {
142						fechaParteA = `<span style="display: block; font-size: 15px; line-height: 1;">Hasta</span> ${formatDate(endDate, 'd')}`
143						fechaParteB = `${formatDate(endDate, 'M')}`
144					}
145					const fechaElementA = parsedElement.find('.fecha .text-date')
146					const fechaElementB = parsedElement.find('.fecha .text-12')
147					fechaParteA.length > 0 ? fechaElementA.html(fechaParteA) : fechaElementA.remove()
148					fechaParteB.length > 0 ? fechaElementB.html(fechaParteB) : fechaElementB.remove()
149				} else {
150					parsedElement.find('.fecha').remove()
151				}
152
153				if (isPrevious) {
154					previousContainer.append(parsedElement)
155				} else {
156					mainContainer.append(parsedElement)
157				}
158			}
159
160			if (!hasPrevious) {
161				previousContainer.closest('[previous-elements-section]').hide()
162			} else {
163				previousContainer.closest('[previous-elements-section]').show()
164			}
165
166			if (response.totalElements == 0) {
167				mainContainer.html('<h1 style="font-size: 24px; text-align: center;">No hay eventos para mostrar en este mes.</h1>')
168			}
169
170		}).always(function () {
171			CustomNamespace.loader(null, false)
172		})
173	}
174})

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.