-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWikivoyage-Cuba.js
152 lines (139 loc) · 4.17 KB
/
Wikivoyage-Cuba.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
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
const Viñales = document.querySelector('#PR');
const Havano = document.querySelector('#LH');
const Matanzas = document.querySelector('#MT');
const Cienfuegos = document.querySelector('#CF');
const SantaClara = document.querySelector('#VC');
const SanctiSpíritus = document.querySelector('#SS');
const Camagüey = document.querySelector('#CM');
const Holguín = document.querySelector('#HL');
const SantiagodeKubo = document.querySelector('#SC');
const Guantánamo = document.querySelector('#GT');
// Las Terrazas
// Trinidad
// Moa
// Baracoa
let urlTitle = "";
// PR - Viñales
Viñales.addEventListener('mouseenter', () => {
Viñales.style.fill = '#0ae453';
});
Viñales.addEventListener('mouseout', () => {
Viñales.style.fill = '';
})
Viñales.addEventListener('click', () => {
urlTitle = 'Viñales';
FetchData();
Viñales.style.fill = '#e40ab5';
});
// LH - Havano
Havano.addEventListener('mouseenter', () => {
Havano.style.fill = '#0ae453';
});
Havano.addEventListener('mouseout', () => {
Havano.style.fill = '';
});
Havano.addEventListener('click', () => {
urlTitle = 'Havano';
FetchData();
});
// MT - Matanzas
Matanzas.addEventListener('mouseenter', () => {
Matanzas.style.fill = '#0ae453';
});
Matanzas.addEventListener('mouseout', () => {
Matanzas.style.fill = '';
});
Matanzas.addEventListener('click', () => {
urlTitle = 'Matanzas';
FetchData();
});
// CF - Cienfuegos
Cienfuegos.addEventListener('mouseenter', () => {
Cienfuegos.style.fill = '#0ae453';
});
Cienfuegos.addEventListener('mouseout', () => {
Cienfuegos.style.fill = '';
});
Cienfuegos.addEventListener('click', () => {
urlTitle = 'Cienfuegos';
FetchData();
});
// VC - SantaClara
SantaClara.addEventListener('mouseenter', () => {
SantaClara.style.fill = '#0ae453';
});
SantaClara.addEventListener('mouseout', () => {
SantaClara.style.fill = '';
});
SantaClara.addEventListener('click', () => {
urlTitle = 'Santa_Clara_(Kubo)';
FetchData();
});
// SS - SanctiSpíritus
SanctiSpíritus.addEventListener('mouseenter', () => {
SanctiSpíritus.style.fill = '#0ae453';
});
SanctiSpíritus.addEventListener('mouseout', () => {
SanctiSpíritus.style.fill = '';
});
SanctiSpíritus.addEventListener('click', () => {
urlTitle = 'Sancti_Spíritus';
FetchData();
});
// CM - Camagüey
Camagüey.addEventListener('mouseenter', () => {
Camagüey.style.fill = '#0ae453';
});
Camagüey.addEventListener('mouseout', () => {
Camagüey.style.fill = '';
});
Camagüey.addEventListener('click', () => {
urlTitle = 'Camagüey';
FetchData();
});
// HL - Holguín
Holguín.addEventListener('mouseenter', () => {
Holguín.style.fill = '#0ae453';
});
Holguín.addEventListener('mouseout', () => {
Holguín.style.fill = '';
});
Holguín.addEventListener('click', () => {
urlTitle = 'Holguín';
FetchData();
});
// SC - SantiagodeKubo
SantiagodeKubo.addEventListener('mouseenter', () => {
SantiagodeKubo.style.fill = '#0ae453';
});
SantiagodeKubo.addEventListener('mouseout', () => {
SantiagodeKubo.style.fill = '';
});
SantiagodeKubo.addEventListener('click', () => {
urlTitle = 'Santiago_de_Kubo';
FetchData();
});
// GT - Guantánamo
Guantánamo.addEventListener('mouseenter', () => {
Guantánamo.style.fill = '#0ae453';
});
Guantánamo.addEventListener('mouseout', () => {
Guantánamo.style.fill = '';
});
Guantánamo.addEventListener('click', () => {
urlTitle = 'Guantánamo_(urbo)';
FetchData();
});
function FetchData() {
fetch(`https://eo.wikivoyage.org/w/api.php?format=json&origin=*&action=parse&page=${urlTitle}`)
.then(res => res.json())
.then(data => fecthData(data))
.catch(err => console.log(err));
const fecthData = (data) => {
let body = `${data.parse.text['*']}`
bodyHtml = body.replace(/\n*/gm, "").replace(/"\/wiki\//gm, "https://eo.wikivoyage.org/wiki/").replace(/\/\/upload.wikimedia.org/gm, "https://upload.wikimedia.org");
let pageTitle = `${data.parse.title}`
document.getElementById('wikivoyageCuba').innerHTML = `<hr><br><h1>${pageTitle}</h1> <br> ${bodyHtml} <br><br>
<a href="https://eo.wikivoyage.org/wiki/${urlTitle}" class="button button2">${pageTitle}</a>`
}
};