-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathasoiaf.js
91 lines (74 loc) · 2.76 KB
/
asoiaf.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
var asoiaf = function() {
if (typeof require == 'function') {
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
var exports = module.exports = {};
var httpGet = function(url)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", url, false);
xmlHttp.send(null);
return JSON.parse(xmlHttp.responseText);
}
} else {
var exports = {};
var httpGet = $.get;
}
//Getters for book
exports.getBookByID = function(book_id) {
book_id = book_id.toString();
var url = 'http://www.anapioficeandfire.com/api/books/' + book_id;
return httpGet(url);
}
exports.getBookByName = function(book_name) {
var url = 'http://www.anapioficeandfire.com/api/books/?name=' + book_name;
return httpGet(url);
}
exports.getAllBooks = function() {
var url = 'http://www.anapioficeandfire.com/api/books';
return httpGet(url);
}
//Getters for Character
exports.getCharacterByID = function(char_id) {
char_id = char_id.toString();
var url = 'http://www.anapioficeandfire.com/api/characters/' + char_id;
return httpGet(url);
}
exports.getCharacterByName = function(char_name) {
var url = 'http://www.anapioficeandfire.com/api/characters/?name=' + char_name;
return httpGet(url);
}
exports.getAllCharacters = function() {
var url = 'http://www.anapioficeandfire.com/api/characters';
return httpGet(url);
}
exports.getCharactersByCulture = function(culture_name) {
var url = 'http://www.anapioficeandfire.com/api/characters/?culture=' + culture_name;
return httpGet(url);
}
exports.getCharactersByGender = function(gender) {
var url = 'http://www.anapioficeandfire.com/api/characters/?gender=' + gender;
return httpGet(url);
}
//Getters for House
exports.getAllHouses = function() {
var url = 'http://www.anapioficeandfire.com/api/houses';
return httpGet(url);
}
exports.getHouseByID = function(house_id) {
house_id = house_id.toString();
var url = 'http://www.anapioficeandfire.com/api/houses/' + house_id;
return httpGet(url);
}
exports.getHouseByName = function(house_name) {
var url = 'http://www.anapioficeandfire.com/api/houses/?name=' + house_name;
return httpGet(url);
}
exports.getHouseByRegion = function(region) {
var url = 'http://www.anapioficeandfire.com/api/houses/?region=' + region;
return httpGet(url);
}
exports.getHouseByWords = function(words) {
var url = 'http://www.anapioficeandfire.com/api/houses/?words=' + words;
return httpGet(url);
}
}();