-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtranscripts.js
61 lines (51 loc) · 1.49 KB
/
transcripts.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
var spacedata;
var surowy;
var tytul;
var firstvariable = '<blockquote class="book">';
var secondvariable = '</blockquote>';
var calosc;
var wikialink;
var wikia = 'http://tibia.wikia.com/api.php?format=json&prop=text&action=parse&pageid=';
// create title, url and txt from book
var teksty = [];
var tekstyfail = [];
function gotData(data) {
spacedata = data;
console.log(spacedata);
surowy = spacedata.parse.text["*"];
someText = surowy;
var regex = RegExp(/(?<=blockquote class="book".)(.*)(?=<.blockquote)/gus);
testRE = someText.match(regex);
calosc = testRE[0];
tytul = spacedata.parse.title;
tytuly = 'http://tibia.wikia.com/wiki/' + tytul;
wikialink = tytuly.replace(/\s/g, "_");
teksty.push({
title: tytul,
url: wikialink,
txt: calosc,
});
}
// loop through all books
function allBook() {
for (var i = 0; i <= url2.length; i++) {
loadJSON(url2[i], gotData, 'jsonp', );
}
}
// create link to api for each book while using id
var url2 = [];
function setup() {
noCanvas();
for (var i = 0; i < spacedata2.items.length; i++) {
url2.push(wikia + spacedata2.items[i].id);
}
}
// below helper for data
function gotData2(data2) {
spacedata2 = data2;
}
// load book ids
var allbooksurl = 'https://cors-anywhere.herokuapp.com/https://tibia.fandom.com/api/v1/Articles/List?expand=0&format=json&category=Transcripts&limit=90000';
function preload() {
txt = loadJSON(allbooksurl, gotData2);
}