Skip to content

Commit

Permalink
implemented web search feature
Browse files Browse the repository at this point in the history
  • Loading branch information
SandeepKrSuman committed Apr 2, 2022
1 parent fc041f3 commit 5211e7c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
6 changes: 5 additions & 1 deletion popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ let wordef,
pos,
defin,
example,
sourceurl,
index = 0,
indlimit;

Expand All @@ -38,6 +39,7 @@ async function dictionary(query) {
indlimit = wordef[0].meanings.length;
word = wordef[0].word;
phonetic = wordef[0].phonetic ? wordef[0].phonetic : "";
sourceurl = `https://en.wiktionary.org/wiki/${word}`;
index = 0;

setValues();
Expand Down Expand Up @@ -74,7 +76,9 @@ function setValues() {
? wordef[0].meanings[index].definitions[0].example
: null;

document.getElementById("word").innerHTML = word;
document.getElementById(
"word"
).innerHTML = `${word} <a href=${sourceurl} class="searchanchor" target="_blank"><img class="searchsvg" title="read more" src = "../assets/searchonweb.svg" alt="read more"/><a>`;
document.getElementById("phonetic").innerHTML = `${phonetic} (${pos})`;
document.getElementById("definition").innerHTML = defin;
if (example) {
Expand Down
21 changes: 21 additions & 0 deletions popup/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,24 @@ div {
background-color: #f1f1f1;
color: black;
}

.searchsvg {
width: 17px;
user-drag: none;
-webkit-user-drag: none;
user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
}

.searchanchor {
text-decoration: none;
outline: none;
}

.searchanchor:hover {
text-decoration: none;
outline: none;
border: none;
}

0 comments on commit 5211e7c

Please sign in to comment.