Skip to content

Commit

Permalink
variable names changed
Browse files Browse the repository at this point in the history
  • Loading branch information
AvinashAgarwal14 authored and PaliwalSparsh committed Apr 2, 2018
1 parent b16def7 commit 5f26321
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions popup/js/popup.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
//Autofill Logic
var tex=document.getElementById("query");
var sug=document.getElementsByClassName("suggestion");
var text=document.getElementById("query");
var suggestions=document.getElementsByClassName("suggestion");
function handleData(data) {
if(data[0]!="")
{
for(var i=0;i<(sug.length);i++)
for(var i=0;i<(suggestions.length);i++)
{
if(data[1].length>0)
{
sug[i].classList.remove("off");
sug[i].innerHTML=data[1][i][0];
suggestions[i].classList.remove("off");
suggestions[i].innerHTML=data[1][i][0];
}
}
}
};
tex.addEventListener("keyup",function(req,res){
if(tex.value=="")
text.addEventListener("keyup",function(req,res){
if(text.value=="")
{
for(var i=0;i<(sug.length);i++)
for(var i=0;i<(suggestions.length);i++)
{
sug[i].innerHTML="";
sug[i].classList.add("off");
suggestions[i].innerHTML="";
suggestions[i].classList.add("off");
}
}
for(var i=0;i<(sug.length);i++)
for(var i=0;i<(suggestions.length);i++)
{
sug[i].addEventListener("click",function(req,res){
tex.value=this.textContent;
for(var i=0;i<(sug.length);i++)
suggestions[i].addEventListener("click",function(req,res){
text.value=this.textContent;
for(var i=0;i<(suggestions.length);i++)
{
sug[i].classList.add("off");
suggestions[i].classList.add("off");
}
});
}
var script = document.createElement('script');
script.setAttribute('src','https://www.google.com/complete/search?client=psy-ab&hl=en-IN&gs_rn=64&gs_ri=psy-ab&tok=_vqJWTsUOepGe_q9mSti0A&cp=0&gs_id=9&q='+tex.value+'&xhr=t&callback=handleData');
script.setAttribute('src','https://www.google.com/complete/search?client=psy-ab&hl=en-IN&gs_rn=64&gs_ri=psy-ab&tok=_vqJWTsUOepGe_q9mSti0A&cp=0&gs_id=9&q='+text.value+'&xhr=t&callback=handleData');
document.body.appendChild(script);
});

//To make Suggestions Disapper when user clicks outside query field
document.body.addEventListener("click", function(){
for(var i=0;i<(sug.length);i++)
for(var i=0;i<(suggestions.length);i++)
{
sug[i].classList.add("off");
suggestions[i].classList.add("off");
}
});
tex.addEventListener("click",function(event){
text.addEventListener("click",function(event){
event.stopPropagation();
});

Expand Down Expand Up @@ -107,7 +107,7 @@ function register(event) {
var dotCheck;
var uuid;

query = tex.value;
query = text.value;
query = encodeURIComponent(query);
// Note :- avoid hardcoded uuid.
uuid = "8fd531a3ba79466f8a80e5c71dea9723";
Expand Down

0 comments on commit 5f26321

Please sign in to comment.