forked from Webaddicted91/Visieum2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
35 lines (26 loc) · 1.02 KB
/
script.js
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
import { museums } from './data21.js';
// Select the path by its ID
//const path = document.getElementById('IN-AN');
const description = document.getElementById('desc');
const cardTitle = document.getElementById('cardTitle');
const cardImage = document.getElementById('museumImage');
const changeInfo = (regionName) => {
console.log(regionName);
museums.forEach(museum => {
if(regionName == museum.state){
cardTitle.innerText = museum.museumName;
description.innerText = museum.description;
cardImage.src = museum.img;
}
});
}
// Repeat for other paths or use a loop to attach event listeners to all paths
const paths = document.querySelectorAll('path');
paths.forEach(function(p) {
p.addEventListener('click', function(event) {
const regionName = event.target.getAttribute('data-name');
changeInfo(regionName);
//alert(`You clicked on: ${regionName}`);
// You can perform different actions based on the ID or data attributes
});
});