aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKumar Priyansh <[email protected]>2020-08-31 00:40:54 +0530
committerKumar Priyansh <[email protected]>2020-08-31 00:40:54 +0530
commitc88c3a21fcb0cfb1aa3e24eb1d4b6d5556e29e3c (patch)
tree63ac888b26bd28d681cec7100a7b580745b5ed3a
parentc31d8ecdd682a33703cd1539b752210c99bd6f43 (diff)
downloaddictionary-c88c3a21fcb0cfb1aa3e24eb1d4b6d5556e29e3c.tar.xz
dictionary-c88c3a21fcb0cfb1aa3e24eb1d4b6d5556e29e3c.zip
basic search logic
-rw-r--r--app/css/style.css2
-rw-r--r--app/index.html3
-rw-r--r--app/scripts/search.js10
3 files changed, 13 insertions, 2 deletions
diff --git a/app/css/style.css b/app/css/style.css
index 9853773..3031eb2 100644
--- a/app/css/style.css
+++ b/app/css/style.css
@@ -19,7 +19,7 @@ body {
.search_box {
position: absolute;
- top: 40%;
+ top: 30%;
left: 10%;
width: 80%;
}
diff --git a/app/index.html b/app/index.html
index 8a15388..40896a0 100644
--- a/app/index.html
+++ b/app/index.html
@@ -10,8 +10,9 @@
<div class="dict_ui">
<div class="drag_region"></div>
<div class="search_box">
- <input type="text" class="search" placeholder="Search for words...">
+ <input type="text" class="search" placeholder="Search for words..." id="searchBox">
</div>
</div>
+ <script src="scripts/search.js"></script>
</body>
</html> \ No newline at end of file
diff --git a/app/scripts/search.js b/app/scripts/search.js
new file mode 100644
index 0000000..0b1f70f
--- /dev/null
+++ b/app/scripts/search.js
@@ -0,0 +1,10 @@
+const searchBox = document.getElementById('searchBox');
+const natural = require('natural');
+const wordnet = new natural.WordNet();
+
+searchBox.addEventListener('keyup', () => {
+ const word = searchBox.value;
+ wordnet.lookup(word, details => {
+ console.log(details);
+ });
+});