Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code english-dictionary #5038 #5161

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Frontend-Projects/english dictionary/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# English-Dictionary

The English Dictionary is a simple and user-friendly web application that allows you to quickly look up the meaning of any English word and listen to its pronunciation. With just a few keystrokes, you can enhance your vocabulary and perfect your pronunciation.

https://github.com/Vyshnavi21504/English-Dictionary/assets/111994644/872b76f6-293d-49b6-9f58-7ef7aeaf7ad0
23 changes: 23 additions & 0 deletions Frontend-Projects/english dictionary/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>English Dictionary</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container" id="container">
<h1>English Dictionary</h1>
<input type="text" placeholder="Search a Word" class="input" id="input">
<p class="info-text" id="info-text">Type a word and press enter
</p>
<div class="meaning-container" id="meaning-container">
<p>Word Title : <span class ="title" id="title">__</span></p>
<p>Meaning : <span class="meaning" id="meaning">__</span></p>
<audio src="" class="audio" controls id="audio"></audio>
</div>
</div>
<script src="index.js"></script>
</body>
</html>
46 changes: 46 additions & 0 deletions Frontend-Projects/english dictionary/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const inputEL = document.getElementById("input");
const infotextEL = document.getElementById("info-text");
const meaningContainerEL =document.getElementById("meaning-container");
const titleEL = document.getElementById("title");
const meaningEL = document.getElementById("meaning");
const audioEL = document.getElementById("audio");

async function fetchAPI(word){

try {
infotextEL.style.display="block";
meaningContainerEL.style.display="none";
infotextEL.innerText = `Searching the meaning of ${word}`;
const URL =`https://api.dictionaryapi.dev/api/v2/entries/en/${word}`;
const result = await fetch(URL).then((res)=>res.json());


if(result.title){
meaningContainerEL.style.display="block";
infotextEL.style.display="none";
titleEL.innerText = word;
meaningEL.innerText="N/A";
audioEL.style.display="none";
}else{
infotextEL.style.display="none";
meaningContainerEL.style.display="block";
audioEL.style.display="inline-flex";
titleEL.innerText = result[0].word;
meaningEL.innerText=result[0].meanings[0].definitions[0].definition;
audioEL.src=result[0].phonetics[0].audio;
}

} catch (error) {
console.log(error);
infotextEL.innerText="an error occured , try again later"
}



}

inputEL.addEventListener("keyup",(e)=>{
if(e.target.value && e.key==="Enter"){
fetchAPI(e.target.value);
}
})
35 changes: 35 additions & 0 deletions Frontend-Projects/english dictionary/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
body{
margin: 0;
min-height: 100vh;
background: linear-gradient(to right, #00b09b, #96c93d);
display: flex;
justify-content: center;
text-align: center;
align-items: center;
}

.container{
background-color: rgba(225,225,225,.6);
padding: 20px;
width: 90%;
border-radius: 10px;
box-shadow: 0 10px 10px rgba(0 0 0 .3);
font-size: 18px;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;

}
.heading{
font-size: 28px;
}
.input{
height:53px ;
width: 300px;
background-color: rgba(225,225,225,.6);
border-color: rgba(225,225,225,.4);
font-size: 16px;
padding: 0 42px;
border-radius: 5px;
}
.meaning-container{
display: none;
}