/
javascript.js
53 lines (30 loc) · 1.63 KB
/
javascript.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
var quotes = ['Engage the mind and soul with classic quotations featuring authors from the ages, with wit, \n wisdom, and words that inspire.',
'When you reach the end of your rope, tie a knot in it and hang on.', 'Let us sacrifice our today so that our children can have a better tomorrow.',
'Lord, make me an instrument of thy peace. Where there is hatred, let me sow love.']
//images in array
var images = ['\'https://wallpaperscraft.com/image/starry_sky_stars_space_glitter_120044_602x339.jpg\'',
'\'https://images.pexels.com/photos/8633/nature-tree-green-pine.jpg?h=350&auto=compress&cs=tinysrgb\'',
'\'https://wallpaperscraft.com/image/spruce_branches_needles_green_120002_602x339.jpg\''
]
function allQuote() {
var randomNumber = Math.floor(Math.random() * (quotes.length));
document.getElementById('quoteDisplay').innerHTML = quotes[randomNumber];
//image function
var randomImg = Math.floor(Math.random() * (images.length));
//document.body.style.backgroundImage = 'url(${images[randomImg]})';
document.getElementById('img').style.backgroundImage = "url(" + images[randomImg] + ")"
}
function entNewQuote() {
var newquotehere = document.getElementById('new_quote_here');
newquotehere.style.display = "block";
}
function addquote()
{
var newquotehere = document.getElementById('new_quote_here');
var quoteDisplay = document.getElementById('quoteDisplay');
var newQuote = document.getElementById('addquote');
quotes.push(newQuote.value);
quoteDisplay.innerHTML = newQuote.value;
newquotehere.style.display = "none";
//alert(quotes);
}