-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogic.js
24 lines (21 loc) · 817 Bytes
/
logic.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
const quoteText =document.querySelector(".quote"),
authorName=document.querySelector(".writter")
soundBtn = document.querySelector(".sound")
copydBtn = document.querySelector(".copy")
quoteBtn=document.querySelector("button");
function randomQuote()
{
fetch("https://api.quotable.io/random").then(res => res.json()).then(result =>{
// console.log(result)
quoteText.innerText=result.content;
authorName.innerText="---"+result.author;
});
}
soundBtn.addEventListener("click",()=>{
let uttrance= new SpeechSynthesisUtterance(`${quoteText.innerText}`);
speechSynthesis.speak(uttrance)
});
copydBtn.addEventListener("click",()=>{
navigator.clipboard.writeText(quoteText.innerText);
});
quoteBtn.addEventListener("click",randomQuote);