forked from TaylorNBurrows/shot_caller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathurban.js
79 lines (64 loc) · 2.18 KB
/
urban.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
function renderRandomDefinition(){
var alcohol = document.querySelector("#drink-name div").textContent
var apiCall = {
"async": true,
"crossDomain": true,
"url": "https://mashape-community-urban-dictionary.p.rapidapi.com/define?term=" + alcohol,
"method": "GET",
"headers": {
"x-rapidapi-host": "mashape-community-urban-dictionary.p.rapidapi.com",
"x-rapidapi-key": "3b9ee90aaemsh39b75ecb88d5d4dp16a0edjsnee4dbbff852f"
}
}
$.ajax(apiCall).then(function(response) {
console.log(response.list.length);
var results = response.list
var targetDiv = document.querySelector('#def-drink')
for (let i = 0; i < 1; i++) {
console.log(results)
var defDiv = document.createElement("div")
$(targetDiv).empty();
var titleDiv = document.createElement("div")
var titleEl = document.createElement("h3")
defDiv.classList.add("card-panel","grey","lighten-3")
defDiv.setAttribute("style", "color:black")
titleEl.textContent="Did you Know?"
defDiv.innerHTML = response.list[i].definition
targetDiv.appendChild(titleDiv)
titleDiv.appendChild(titleEl)
targetDiv.appendChild(defDiv)
}
});
}
function renderBYODefinition(cardName) {
var alcohol = cardName
var apiCall = {
"async": true,
"crossDomain": true,
"url": "https://mashape-community-urban-dictionary.p.rapidapi.com/define?term=" + alcohol,
"method": "GET",
"headers": {
"x-rapidapi-host": "mashape-community-urban-dictionary.p.rapidapi.com",
"x-rapidapi-key": "3b9ee90aaemsh39b75ecb88d5d4dp16a0edjsnee4dbbff852f"
}
}
$.ajax(apiCall).then(function(response) {
console.log(response.list.length);
var results = response.list
var targetDiv = document.querySelector('#def-drink')
for (let i = 0; i < 1; i++) {
console.log(results)
var defDiv = document.createElement("div")
$(targetDiv).empty();
var titleDiv = document.createElement("div")
var titleEl = document.createElement("h3")
defDiv.classList.add("card-panel","grey","lighten-3")
defDiv.setAttribute("style", "color:black")
titleEl.textContent="Did you Know?"
defDiv.innerHTML = response.list[i].definition
targetDiv.appendChild(titleDiv)
titleDiv.appendChild(titleEl)
targetDiv.appendChild(defDiv)
}
});
}