forked from K-Sakanoshita/community_mapmaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodal_wikipedia.js
executable file
·31 lines (28 loc) · 1.1 KB
/
modal_wikipedia.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
class modal_Wikipedia {
// make modal html for Wikipedia
// return elements(Before processing)
element() {
return `<h5>${glot.get("wikipedia")}</h5><div class="mb-3" id="modal_wikipedia"></div>`;
};
// make html(After processing)
make(tags) {
return new Promise((resolve, reject) => {
let wiki = tags.wikipedia.split(':');
let url = encodeURI(`https://${wiki[0]}.${Conf.osm.wikipedia.domain}/wiki/${wiki[1]}`);
basic.getWikipedia(wiki[0], wiki[1]).then(text => {
let html = `<span>${text}</span><a href="${url}" target="_blank">${glot.get("source_wikipedia")}</a>`;
resolve(html);
}).catch(e => reject(e));
});
};
// set dom from html(make result)
set_dom(html) {
let wikidom = document.getElementById("modal_wikipedia");
if (wikidom == undefined) {
setTimeout(() => modal_wikipedia.set_dom(html), 500);
} else {
wikidom.innerHTML = html;
};
};
}
var modal_wikipedia = new modal_Wikipedia();