Skip to content

Commit cef1de0

Browse files
committed
build the synonyms generator using stands4 api
1 parent 3fa2eb5 commit cef1de0

File tree

2 files changed

+115
-0
lines changed

2 files changed

+115
-0
lines changed

Diff for: SynonymsGenerator/Vidhanvyrs/index.html

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Synonyms Generator</title>
7+
<link rel="stylesheet" href="style.css" />
8+
</head>
9+
<body>
10+
<h1 class="heading">Synonyms Generator</h1>
11+
<input
12+
class="inputword"
13+
type="text"
14+
id="wordInput"
15+
placeholder="Enter a word"
16+
/>
17+
<button class="btn" onclick="getSynonyms()">Generate Synonyms</button>
18+
<p class="para">Synonyms: <span id="synonyms"></span></p>
19+
<p id="loading" class="loading-message"></p>
20+
<script>
21+
function getSynonyms() {
22+
const uid = "12119";
23+
const tokenid = "XHHMiMr0MLSf4Co6";
24+
const wordInput = document.getElementById("wordInput").value;
25+
const synonymsElement = document.getElementById("synonyms");
26+
const loadingMessage = document.getElementById("loading");
27+
loadingMessage.textContent = "Loading...";
28+
loadingMessage.style.display = "block";
29+
fetch(
30+
`https://www.stands4.com/services/v2/syno.php?uid=${uid}&tokenid=${tokenid}&word=${wordInput}&format=json`,
31+
{
32+
method: "GET",
33+
}
34+
)
35+
.then((response) => response.json())
36+
.then((data) => {
37+
const results = data.result;
38+
if (results.length > 0) {
39+
const result = results[0];
40+
const synonyms = result.synonyms.split(", ");
41+
if (synonyms.length > 0) {
42+
synonymsElement.textContent = synonyms.join(", ");
43+
} else {
44+
synonymsElement.textContent = "No synonyms found.";
45+
}
46+
} else {
47+
synonymsElement.textContent = "No results found.";
48+
}
49+
loadingMessage.style.display = "none";
50+
})
51+
.catch((error) => {
52+
console.error("Error:", error);
53+
synonymsElement.textContent = "An error occurred: " + error.message;
54+
loadingMessage.style.display = "none";
55+
});
56+
}
57+
</script>
58+
</body>
59+
</html>

Diff for: SynonymsGenerator/Vidhanvyrs/style.css

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
body {
2+
display: flex;
3+
flex-direction: column;
4+
align-items: center;
5+
justify-content: center;
6+
height: 100vh;
7+
margin: 0;
8+
font-family: Arial, sans-serif;
9+
background-color: #f2f2f2;
10+
}
11+
12+
.heading {
13+
font-size: 24px;
14+
font-weight: bold;
15+
margin-bottom: 20px;
16+
color: #333;
17+
}
18+
19+
.inputword {
20+
padding: 10px;
21+
width: 30%;
22+
border: 1px solid #ccc;
23+
border-radius: 5px;
24+
margin-bottom: 10px;
25+
font-family: Arial, sans-serif;
26+
}
27+
28+
.btn {
29+
padding: 10px 20px;
30+
background-color: #007bff;
31+
color: #fff;
32+
border: none;
33+
border-radius: 5px;
34+
cursor: pointer;
35+
transition: background-color 0.3s ease;
36+
}
37+
38+
.btn:hover {
39+
background-color: #0056b3;
40+
}
41+
42+
.para {
43+
font-size: 18px;
44+
margin-top: 10px;
45+
color: #555;
46+
}
47+
48+
#synonyms {
49+
font-weight: bold;
50+
color: #333;
51+
}
52+
.loading-message {
53+
display: none;
54+
margin-top: 10px;
55+
color: #555;
56+
}

0 commit comments

Comments
 (0)