forked from pranjay-poddar/Dev-Geeks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
code eng-dictionary pranjay-poddar#5038
- Loading branch information
1 parent
8b1dda2
commit 975e858
Showing
4 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |