This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
event-details.html
184 lines (154 loc) · 7.47 KB
/
event-details.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Detalles del Evento</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css"/>
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
<link rel="stylesheet" href="css/event-details.css">
</head>
<body>
<div class="nav-header">
<div class="header-links">
<ul>
<li data-menuanchor="thirdPage"><a href="index.html" style="color: black">HOME</a></li>
<li data-menuanchor="thirdPage"><a href="index.html#portfolio" style="color: black">CONTACT</a></li>
<li data-menuanchor="secondPage"><a href="index.html#about" style="color: black">ABOUT US</a></li>
</ul>
</div>
</div>
<div id="event-details-container">
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
const urlParams = new URLSearchParams(window.location.search);
const eventName = urlParams.get('name');
const eventDate = urlParams.get('date');
const eventDescription = decodeURIComponent(urlParams.get('description'));
const eventPrice = decodeURIComponent(urlParams.get('price'));
const eventImageUrl = decodeURIComponent(urlParams.get('image_url'));
const eventLocation = decodeURIComponent(urlParams.get('location'));
const eventMaxParticipants = decodeURIComponent(urlParams.get('max_participants'));
const eventId = decodeURIComponent(urlParams.get('eventid'))
const [latitude, longitude] = eventLocation.split(', ');
const formattedLatitude = formatCoordinate(latitude);
const formattedLongitude = formatCoordinate(longitude);
// Convert DMS to decimal
const lat = dmsToDecimal(formattedLatitude);
const lng = dmsToDecimal(formattedLongitude);
const eventDetailsContainer = document.getElementById('event-details-container');
eventDetailsContainer.innerHTML = `
<div id="event-details-container">
<h2 class="event-title">${eventName}</h2>
<div class="event-image-container" style="
background-image: url('${eventImageUrl}/img1.png');
background-size: cover;
background-position: center;
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
width: 100%;
height: 30em;
position: relative;
border-radius: 10px;
">
/*
<img src="${eventImageUrl}/img1.png" alt="Event Image" style="width: 20em; height: 15em; display: none">
*/
<button class="prev">❮</button>
<button class="next">❯</button>
</div>
<div class="event-info">
<p class="event-date"><strong>Date:</strong> ${new Date(eventDate).toLocaleDateString('es-ES')}</p>
<p class="event-description"><strong>Description:</strong> ${eventDescription}</p>
<p class="event-price"><strong>Price:</strong> ${eventPrice} €</p>
<p class="event-participants"><strong>Max Participants:</strong> ${eventMaxParticipants}</p>
<!--FALTA AÑADIR QUE SE VEAN Nº DE PLAZAS LIBRES PONIENDO POR EJEMPLO ->
<p class="event-vacants><strong>Vacants:</strong> (aqui iria dollar){eventMaxParticipants - eventParticipants}</p>
-->
<p class="event-location" style="border-bottom: none"><strong>Location:</strong></p>
</div>
<button id="joinEventButton">Join Event</button>
<div class="event-map">
<div id="mapid" style="height: 180px;"></div>
</div>
</div>
`;
// Initialize the map and place a marker
const map = L.map('mapid').setView([lat, lng], 13);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
L.marker([lat, lng]).addTo(map)
.bindPopup(`${eventName}<br>${formattedLatitude}, ${formattedLongitude}`).openPopup();
// Agregar event listeners a los botones para cambiar imágenes
const prevButton = eventDetailsContainer.querySelector('.prev');
const nextButton = eventDetailsContainer.querySelector('.next');
prevButton.addEventListener('click', function () {
changeImage(-1);
});
nextButton.addEventListener('click', function () {
changeImage(1);
});
// Función para cambiar la imagen
function changeImage(direction) {
const imageContainer = eventDetailsContainer.querySelector('.event-image-container');
const img = imageContainer.querySelector('img');
const imgName = img.src.split('/').pop();
let imgNumber = parseInt(imgName.match(/\d+/)[0], 10);
imgNumber += direction;
if (imgNumber < 1) imgNumber = 3;
if (imgNumber > 3) imgNumber = 1;
const newSrc = `${eventImageUrl}/img${imgNumber}.png`;
img.src = newSrc; // Actualiza la fuente de la etiqueta <img>
// También actualiza el fondo del contenedor
imageContainer.style.backgroundImage = `url('${newSrc}')`;
}
function formatCoordinate(coord) {
let [value, direction] = coord.split('º '); // Divide el valor de la dirección.
value = parseFloat(value);
const degrees = Math.floor(value);
const minutesNotTruncated = (value - degrees) * 100;
const minutes = Math.floor(minutesNotTruncated);
const seconds = ((minutesNotTruncated - minutes) * 100).toFixed(1);
return `${degrees}°${String(minutes).padStart(2, '0')}'${seconds}"${direction}`;
}
function dmsToDecimal(coord) {
const parts = coord.match(/(\d+)°(\d+)'([\d.]+)"(\w)/);
const degrees = parseFloat(parts[1]);
const minutes = parseFloat(parts[2]);
const seconds = parseFloat(parts[3]);
const direction = parts[4];
let decimal = degrees + (minutes / 60) + (seconds / 3600);
if (direction === 'S' || direction === 'W') {
decimal = decimal * -1;
}
return decimal;
}
const joinButton = document.getElementById('joinEventButton');
joinButton.addEventListener('click', function() {
window.location.href = `paymentGateway.html?eventid=${eventId}&price=${eventPrice}`
});
});
function loadHTMLAndExecuteScripts(selector, sourceFile) {
fetch(sourceFile)
.then(response => response.text())
.then(html => {
const container = document.querySelector(selector);
container.innerHTML = html;
executeScripts(container);
})
.catch(error => console.error('Error loading ' + sourceFile + ':', error));
}
function executeScripts(container) {
const scripts = container.querySelectorAll('script');
scripts.forEach(script => {
const scriptTag = document.createElement('script');
scriptTag.src = script.src || '';
scriptTag.textContent = script.textContent;
document.head.appendChild(scriptTag).parentNode.removeChild(scriptTag);
});
}
</script>
</body>
</html>