-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheo-wikiquote.js
18 lines (14 loc) · 896 Bytes
/
eo-wikiquote.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
let url = 'https://eo.wikiquote.org/w/api.php?format=json&origin=*&action=parse&page=Vikicitaro:Citaĵo_de_la_tago/CDLT';
let wqQuoteHtml = "";
let wqAuthorHtml = "";
fetch(url)
.then(response => response.json())
.then(data => fecthData(data))
.catch(error => console.log(error))
const fecthData = (data) => {
let body = `${data.parse.text['*']}`
bodyHtml = body.replace(/\n*/gm, "").replace(/\/wiki\//gm, "https://eo.wikiquote.org/wiki/");
wqQuoteHtml = bodyHtml.replace(/.+<blockquote/gm, "<blockquote").replace(/<\/blockquote.+/gm, "</blockquote");
wqAuthorHtml = bodyHtml.replace(/\n*/gm, "").replace(/.+<big id="Aŭtoro_CDLT"/gm, '<big id="Aŭtoro_CDLT"').replace(/<\/big><br\/>.+/gm, "</big>");
document.getElementById('eoWikiquote').innerHTML = `<figure id="figEoWikiquote">${wqQuoteHtml} + <figcaption>—${wqAuthorHtml}</figcaption></figure>`
}