-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
78 lines (43 loc) · 1.46 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
const TYPED = document.querySelector(".typing");
// var SUBMIT = document.getElementById("sub");
// var SUBMIT2 = document.getElementById("sub");
// var placeholder = document.getElementById("key_search").placeholder;
// var search = document.getElementById("key_search").value;
// console.log(search);
// var searchResult;
// var search;
// function getValue() {
// search = document.getElementById("key_search").value;
// // searchResult = search;
// };
// console.log(search);
// SUBMIT.addEventListener("click", getValue, false);
var i = 0;
var txt = "Welcome to THE OFFICE!!";
var speed = 50;
window.onload = function typeWriter() {
if (i < txt.length) {
TYPED.innerHTML += txt.charAt(i);
i++;
setTimeout(typeWriter, speed);
}
}
var key = "the office";
console.log(key);
var request = new XMLHttpRequest();
request.open('GET', 'https://api.giphy.com/v1/gifs/search?api_key=79SnwtGlSNSyhNbAJxCldfoDGnZkkuXV&q=' + key +'&rating=pg&limit=50');
request.onload = function gifResult() {
var response = request.response;
var parsedResponse = JSON.parse(response);
console.log(parsedResponse)
var randomN = Math.floor(Math.random() * 50);
console.log(randomN);
var originalUrl = parsedResponse.data[randomN].images.original.url;
console.log(parsedResponse.data[randomN]);
console.log(originalUrl);
var gif = document.createElement('img');
gif.setAttribute('src', originalUrl);
document.body.appendChild(gif);
}
request.send();
//