-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenque.js
More file actions
46 lines (31 loc) · 1.15 KB
/
genque.js
File metadata and controls
46 lines (31 loc) · 1.15 KB
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
let btn=document.querySelector('button')
let qutxt=document.querySelector('.txt')
let quaut=document.querySelector('.aname')
let soundbtn=document.querySelector('.sound')
let copybtn=document.querySelector('.copy')
let twwetbtn=document.querySelector('.twitter')
function randqou() {
btn.innerText= "Loading...";
btn.classList.add('loading');
fetch("https://api.quotable.io/random").then(res =>res.json()).then(result =>{
//for random quotes
console.log(result);
qutxt.innerText = result.content;
quaut.innerText = result.author;
btn.innerText = "NEW QUOTE";
btn.classList.remove('.loading')
})
}
soundbtn.addEventListener('click',()=>{
let snd=new SpeechSynthesisUtterance (`${qutxt.innerText} BY ${quaut.innerText}`)
speechSynthesis.speak(snd);
})
copybtn.addEventListener('click',()=>{
navigator.clipboard.writeText(`${qutxt.innerText} BY ${quaut.innerText}`)
})
twwetbtn.addEventListener('click',()=>{
let twwt = `https://twitter.com/intent/tweet?url=${qutxt.innerText} BY ${quaut.innerText}`;
//to open text in twiiter
window.open(twwt,"_blank")
})
btn.addEventListener('click',randqou)