-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
175 lines (169 loc) · 7.84 KB
/
script.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
document.addEventListener('DOMContentLoaded', function () {
var urls = [
"http://api.giphy.com/v1/gifs/14aUO0Mf7dWDXW",
"http://api.giphy.com/v1/gifs/pOeuPPvO3Lbxu ",
"http://api.giphy.com/v1/gifs/26tnjOKyxetqJx196",
"http://api.giphy.com/v1/gifs/l3vRiLydJmh7X0Yx2",
"http://api.giphy.com/v1/gifs/GIFbrFpayHUwo",
"http://api.giphy.com/v1/gifs/l4Jzi0z1TUWsvy0Sc",
"http://api.giphy.com/v1/gifs/l3vR4VfkKdHUvv7Us",
"http://api.giphy.com/v1/gifs/26FKVMPd6UFZoBuve",
"http://api.giphy.com/v1/gifs/lcVSsTpx2s5t6",
"http://api.giphy.com/v1/gifs/sKpOy3SV4FcJi",
"http://api.giphy.com/v1/gifs/ToMjGpBmDyMmBrMmbf2",
"http://api.giphy.com/v1/gifs/TObbUke0z8Mo",
"http://api.giphy.com/v1/gifs/xkhn6Ry4taRtC",
"http://api.giphy.com/v1/gifs/l3vR4JrVZMzugEMuY",
"http://api.giphy.com/v1/gifs/12Y8uwQsnpizCw",
"http://api.giphy.com/v1/gifs/detDESm0bahoc",
"http://api.giphy.com/v1/gifs/VANjjepUKvXos",
"http://api.giphy.com/v1/gifs/3oz8xxRUPIMXsfgUms",
"http://api.giphy.com/v1/gifs/l3vR33TV0vszF7rWg",
"http://api.giphy.com/v1/gifs/3oz8xGDSz9q3PwRRyU",
"http://api.giphy.com/v1/gifs/3oz8xEGM20jA34Ak5W",
"http://api.giphy.com/v1/gifs/l3vRbgCJxtSXS9jFe",
"http://api.giphy.com/v1/gifs/26ybvMeJmCaPtcNDW",
"http://api.giphy.com/v1/gifs/l3vQYcZ7QlnHiUuWY",
"http://api.giphy.com/v1/gifs/l3vQXKKENvuCjz5vi",
"http://api.giphy.com/v1/gifs/l41Yej9C6OGpcwKSk",
"http://api.giphy.com/v1/gifs/bEqrzkLVWC3bW",
"http://api.giphy.com/v1/gifs/DD2NmqYhvLiP6",
"http://api.giphy.com/v1/gifs/huBkkFR80SqmQ",
"http://api.giphy.com/v1/gifs/pDe2oPAuBpzWw",
"http://api.giphy.com/v1/gifs/NEfZfV5frVND2",
"http://api.giphy.com/v1/gifs/ZeB4HcMpsyDo4",
"http://api.giphy.com/v1/gifs/tcAykk8j17GIU",
"http://api.giphy.com/v1/gifs/bRJRe4SUFyp2w",
"http://api.giphy.com/v1/gifs/xTk9ZRJytbejZGlzqg",
"http://api.giphy.com/v1/gifs/uSYQsJQWEv6O4",
"http://api.giphy.com/v1/gifs/Wa5JDuv6kzoTC",
"http://api.giphy.com/v1/gifs/Xu3FmS0zWUeu4",
"http://api.giphy.com/v1/gifs/zndolLCgmIgrS",
"http://api.giphy.com/v1/gifs/ysF2pR5F9xC12",
"http://api.giphy.com/v1/gifs/OXYZqYu3wnt4I",
"http://api.giphy.com/v1/gifs/PLwpHQmiqoeI0",
"http://api.giphy.com/v1/gifs/SP6nsoM3MgLFS",
"http://api.giphy.com/v1/gifs/mm7kVzakCIz84",
"http://api.giphy.com/v1/gifs/MwVhxOu3ZucV2",
"http://api.giphy.com/v1/gifs/K43gf9QRjbLeE",
"http://api.giphy.com/v1/gifs/LcQEVgl0HMHIY",
"http://api.giphy.com/v1/gifs/j4GX2oX1rGRK8",
"http://api.giphy.com/v1/gifs/IUkTZ70JRHVdu",
"http://api.giphy.com/v1/gifs/IqDx8Fe5CKIx2",
"http://api.giphy.com/v1/gifs/fezvdhQOWyoEw",
"http://api.giphy.com/v1/gifs/aTHb91YXHGw8g",
"http://api.giphy.com/v1/gifs/9rYAlBv4PnP44",
"http://api.giphy.com/v1/gifs/a5aoG9lfaKtqM",
"http://api.giphy.com/v1/gifs/AZ9E5rrNWsacg",
"http://api.giphy.com/v1/gifs/elxoYTTkgpur6",
"http://api.giphy.com/v1/gifs/13kcCFShpeVUoo",
"http://api.giphy.com/v1/gifs/7vQfoBITd6omc",
"http://api.giphy.com/v1/gifs/5M7C95yZ0TQiI",
"http://api.giphy.com/v1/gifs/Rt5SYFNtu09IQ",
"http://api.giphy.com/v1/gifs/2rJSj83iGYN8c",
"http://api.giphy.com/v1/gifs/66wnpo0hMj7HO",
"http://api.giphy.com/v1/gifs/MEGcFyjn4D9sI",
"http://api.giphy.com/v1/gifs/hMtf0t0g3UP9m",
"http://api.giphy.com/v1/gifs/gB5o7HVgpkCYM",
"http://api.giphy.com/v1/gifs/nntN4XMNwTzZ6",
"http://api.giphy.com/v1/gifs/CEJGxn0ukYPBu",
"http://api.giphy.com/v1/gifs/Ex1vQYjPP3fhK",
"http://api.giphy.com/v1/gifs/JxbCxr9E7D38c",
"http://api.giphy.com/v1/gifs/AVqtlKDqWwAX6",
"http://api.giphy.com/v1/gifs/4bxUqi6ATTXTa",
"http://api.giphy.com/v1/gifs/lrw5HXVKYozeg",
"http://api.giphy.com/v1/gifs/QoCoLo2opwUW4",
"http://api.giphy.com/v1/gifs/GrnubHYtJ0ogg",
"http://api.giphy.com/v1/gifs/N6funLtVsHW0g",
"http://api.giphy.com/v1/gifs/5lwFdRA563PNK",
"http://api.giphy.com/v1/gifs/Ai6pliUjWGOu4",
"http://api.giphy.com/v1/gifs/jc7wfEtdNuxMs",
"http://api.giphy.com/v1/gifs/4Wx3y8GKho2Ri",
"http://api.giphy.com/v1/gifs/EEaWn6O9lR2gg",
"http://api.giphy.com/v1/gifs/otyk3n3dXb8AM",
"http://api.giphy.com/v1/gifs/iyDXvr5Weat20",
"http://api.giphy.com/v1/gifs/w6KILRt0tqZ5m",
"http://api.giphy.com/v1/gifs/sq1kD9dEzJDEI",
"http://api.giphy.com/v1/gifs/qGZQme1rCwj60",
"http://api.giphy.com/v1/gifs/gqDbzvWihXOtW",
"http://api.giphy.com/v1/gifs/SZWVMQz6gRmdG",
"http://api.giphy.com/v1/gifs/FLal1vWiyQIJG",
"http://api.giphy.com/v1/gifs/H0Qi5W2KzU5UI",
"http://api.giphy.com/v1/gifs/CXTcNfdzbL25G",
"http://api.giphy.com/v1/gifs/26xBwFcBGPLNfGbkY",
"http://api.giphy.com/v1/gifs/bOKc5QXWlgRAA",
"http://api.giphy.com/v1/gifs/YMGFnbPoy1IRy",
"http://api.giphy.com/v1/gifs/rviHZFFo433xe",
"http://api.giphy.com/v1/gifs/xmFNzRdsaa8dG",
"http://api.giphy.com/v1/gifs/qYJJ6sCXD9IFq",
"http://api.giphy.com/v1/gifs/qrf1y0LUZ5y8w",
"http://api.giphy.com/v1/gifs/6FOWtV5TBMhkQ",
"http://api.giphy.com/v1/gifs/r4lsLsqeIpcBy",
"http://api.giphy.com/v1/gifs/o8weDZLHeCQaQ",
"http://api.giphy.com/v1/gifs/rvmge3zNyfIDm",
"http://api.giphy.com/v1/gifs/p8AsqNWMRcLT2",
"http://api.giphy.com/v1/gifs/26FKTjNuyE3KGKFxK",
"http://api.giphy.com/v1/gifs/l4Jz1Wh9oRPAdas5q",
"http://api.giphy.com/v1/gifs/26FKTSd72bgky8Ke4",
"http://api.giphy.com/v1/gifs/26FL8IrP4I4KsB8RO",
"http://api.giphy.com/v1/gifs/l4JyTpXHZ7Z9crCZq",
"http://api.giphy.com/v1/gifs/l0HlFMnvXv4F0uvxm",
"http://api.giphy.com/v1/gifs/26FLc6DCJcqYfYcrS",
"http://api.giphy.com/v1/gifs/l0HlRhn3b5pCme2Jy",
"http://api.giphy.com/v1/gifs/26FLhDEQzSmf1I9Y4",
"http://api.giphy.com/v1/gifs/l4Jz5wxjp8MZn9yow",
"http://api.giphy.com/v1/gifs/26FLc6DCJcqYfYcrS",
"http://api.giphy.com/v1/gifs/mfl23Zigc80iA",
"http://api.giphy.com/v1/gifs/VJ8Cx542KlykE",
"http://api.giphy.com/v1/gifs/QRN3Awd0mC6ac",
"http://api.giphy.com/v1/gifs/l4JyXzZmGC59YLRnO",
"http://api.giphy.com/v1/gifs/l4JyJSHgv7qMPJe48",
"http://api.giphy.com/v1/gifs/l4JyNtfY71DI0bZzG",
"http://api.giphy.com/v1/gifs/d4aUhirySgWNm0og",
"http://api.giphy.com/v1/gifs/26ybvMeJmCaPtcNDW",
"http://api.giphy.com/v1/gifs/l3vQYcZ7QlnHiUuWY",
"http://api.giphy.com/v1/gifs/l41Yy2vHvj4kZs7F6",
"http://api.giphy.com/v1/gifs/p8AsqNWMRcLT2",
"http://api.giphy.com/v1/gifs/Z89W40XJ3O1dm",
"http://api.giphy.com/v1/gifs/ywEsI8CpIjVaE",
"http://api.giphy.com/v1/gifs/iMeRr7molZ5XW",
"http://api.giphy.com/v1/gifs/4sLyMfds3Z5e0",
"http://api.giphy.com/v1/gifs/ECpRBo08Cz7Yk",
"http://api.giphy.com/v1/gifs/BAiLboJ1pC45W",
"http://api.giphy.com/v1/gifs/NrdIQbvKO4Eww",
"http://api.giphy.com/v1/gifs/KudWq0YKBehna",
"http://api.giphy.com/v1/gifs/27PVoc4qSMODC",
"http://api.giphy.com/v1/gifs/T2MZn1X1XJqBW",
"http://api.giphy.com/v1/gifs/Zu3IHLRMxPvX2",
"http://api.giphy.com/v1/gifs/3t82HXDa2hlxm",
"http://api.giphy.com/v1/gifs/oFnr0c2nbftE4",
"http://api.giphy.com/v1/gifs/QEJPkYu5a1qJW",
"http://api.giphy.com/v1/gifs/MAlNFmtnvZDJm",
"http://api.giphy.com/v1/gifs/7DAniGSCMc86c",
"http://api.giphy.com/v1/gifs/DOcUtFr07MGd2",
"http://api.giphy.com/v1/gifs/C2egRipVALU9a"
]
var pandaUrl = urls[Math.floor(Math.random()*urls.length)];
// console.log('http://api.giphy.com/v1/gifs/' + pandaUrl + '?api_key=dc6zaTOxFJmzC');
console.log(pandaUrl + '?api_key=dc6zaTOxFJmzC');
request = new XMLHttpRequest;
request.open('GET', pandaUrl + '?api_key=dc6zaTOxFJmzC', true);
request.onload = function() {
if (request.status >= 200 && request.status < 400){
data = JSON.parse(request.responseText).data.images.downsized.url;
console.log(data);
document.getElementsByClassName("gif")[0].innerHTML = '<img src = "'+data+'" title="Panda GIF via Giphy">';
document.getElementsByClassName("spinner")[0].style.display = "none";
} else {
document.getElementsByClassName("error")[0].style.display = "inline";
document.getElementsByClassName("spinner")[0].style.display = "none";
console.log('reached giphy, but API returned an error');
}
};
request.onerror = function() {
document.getElementsByClassName("error")[0].style.display = "inline";
document.getElementsByClassName("spinner")[0].style.display = "none";
console.log('connection error');
};
request.send();
});