diff --git a/popup/js/popup.js b/popup/js/popup.js index 4357f80..747ca9c 100644 --- a/popup/js/popup.js +++ b/popup/js/popup.js @@ -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(); }); @@ -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";