Skip to content

Commit

Permalink
fixed the search problem
Browse files Browse the repository at this point in the history
  • Loading branch information
aswinisamantray committed Jun 12, 2023
1 parent 94a12a9 commit 4cc6967
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
4 changes: 0 additions & 4 deletions Public/word-count-calculator.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ <h2>Your text summary</h2>
<input class="form-control me-2" type="search" placeholder="Enter a word to know its frequency..." id="searchText" aria-label="Search"/>
<button id="searchButton" class="btn btn-primary my-2 mx-2" type="submit" >Search</button>
<div id="frequency"></div>
</div>

<div class="unique">

</div>
<script src="../assets/Js/word-count-calculator.js"></script>

Expand Down
13 changes: 4 additions & 9 deletions assets/Js/word-count-calculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ function search(val,search){
return count;
}

function copy(val){
return val;
}

var textContent = document.getElementById("textcontent");
var showWordCount = document.getElementById("countWord");
Expand All @@ -54,6 +51,7 @@ var frequency=document.getElementById("frequency");
var copy=document.getElementById("copyButton");
var paste=document.getElementById("pasteButton");
let f=0;

longestWord.innerHTML=("<br>There is no text.");
textContent.addEventListener("input", function(){

Expand All @@ -76,15 +74,12 @@ if(l.length===0){
else{
longestWord.innerHTML=("<br>Longest Word: "+l.bold());
}

longestWordlength.innerHTML=("<br>Length of "+l+" is: "+l.length);
let text=this.value;
searchText.addEventListener("input",function(){
let word=this.value;
f=search(text,word);
longestWordlength.innerHTML=("<br>Length of "+l+" is: "+l.length);
searchButton.addEventListener("click",function(){
let word=searchText.value;
f=search(text,word);
frequency.innerHTML=("<br>"+word.bold()+" occurs "+f+" times(s) in the text.");
},false);
},false);
}, false);

0 comments on commit 4cc6967

Please sign in to comment.