-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.js
36 lines (30 loc) · 1.04 KB
/
app.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
addEventListener('load', () => {
function callApi() {
fetch('https://api.quotable.io/random')
.then((res) => {
return res.json();
})
.then((data) => {
document.getElementById('quote').innerHTML = data.content;
document.getElementById('author').innerHTML = data.author;
})
.catch((err) => console.log(err));
}
callApi();
});
function setbackground() {
window.setTimeout('setbackground()', 5000); // milliseconds delay
var index = Math.round(Math.random() * 9);
var ColorValue = 'FFFFFF'; // default color - white (index = 0)
if (index == 1) ColorValue = '66FF33';
if (index == 2) ColorValue = 'FF0000';
if (index == 3) ColorValue = 'FF00FF';
if (index == 4) ColorValue = '0000FF';
if (index == 5) ColorValue = '00FFFF';
if (index == 6) ColorValue = 'FFFF00';
if (index == 7) ColorValue = 'CC66FF';
if (index == 8) ColorValue = '3366FF';
if (index == 9) ColorValue = 'CCCCCC';
document.getElementsByTagName('body')[0].style.backgroundColor =
'#' + ColorValue;
}