|
| 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> |
0 commit comments