Skip to content

Commit

Permalink
fixed eslint errors and squashed commits
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenix7139 committed Mar 2, 2019
1 parent f17ce0f commit f56b51c
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 115 deletions.
6 changes: 5 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"no-var": "off",
"indent": ["error", 4],
"quotes": ["error", "double"],
"linebreak-style": "off"
"linebreak-style": "off",
"max-len": ["error", { "code": 80 }],
"no-restricted-globals": "warn",
"no-unused-vars": "warn",
"no-shadow":"warn"
}
}
84 changes: 36 additions & 48 deletions options/js/options.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,52 @@
var recentSearchQueries=[];
var recentSearchQueryUrls=[];
var toggle = document.getElementById('theme');

if(!localStorage.getItem('theme'))
localStorage.setItem('theme', 'light');

if(localStorage.getItem('theme') == 'light')
{
console.log("light");
toggle.checked = false;
}
else
{
console.log("dark");
toggle.checked = true;
/* eslint-disable vars-on-top */
var recentSearchQueries = [];
var recentSearchQueryUrls = [];
var historyListElement;
var clearHistory;
var count;
var themeToggle = document.getElementById("theme");

if (!localStorage.getItem("theme")) localStorage.setItem("theme", "light");

if (localStorage.getItem("theme") === "light") {
themeToggle.checked = false;
} else {
themeToggle.checked = true;
}

function handleThemeChange(event) {
if (toggle.checked==false)
localStorage.setItem('theme', 'light');
else
localStorage.setItem('theme', 'dark');
if (themeToggle.checked === false) localStorage.setItem("theme", "light");
else localStorage.setItem("theme", "dark");
}

document.addEventListener("DOMContentLoaded", function () {
var toggle = document.getElementById('theme');
toggle.addEventListener('click', handleThemeChange);
themeToggle = document.getElementById("theme");
themeToggle.addEventListener("click", handleThemeChange);
});

var historyListElement = document.getElementById("historyList");
var clearHistory = document.querySelector("#clearButton");
historyListElement = document.getElementById("historyList");
clearHistory = document.querySelector("#clearButton");

recentSearchQueries=(JSON.parse(localStorage.getItem('search')));
recentSearchQueryUrls=(JSON.parse(localStorage.getItem('link')));
recentSearchQueries = (JSON.parse(localStorage.getItem("search")));
recentSearchQueryUrls = (JSON.parse(localStorage.getItem("link")));

historyListElement.textContent="";
var count=0;
recentSearchQueries.forEach(function(entr)
{


var aTag = document.createElement('a');
aTag.setAttribute('target','_blank')
aTag.setAttribute('href',recentSearchQueryUrls[count]);
historyListElement.textContent = "";
count = 0;
recentSearchQueries.forEach(function (entr) {
var aTag = document.createElement("a");
aTag.setAttribute("target", "_blank");
aTag.setAttribute("href", recentSearchQueryUrls[count]);
aTag.innerHTML = entr;
historyListElement.appendChild(aTag);
var mybr = document.createElement('br');
historyListElement.appendChild(mybr);
var myhr = document.createElement('hr');
historyListElement.appendChild(myhr);
count++;

})


var br = document.createElement("br");
historyListElement.appendChild(br);
var hr = document.createElement("hr");
historyListElement.appendChild(hr);
count += 1;
});


clearHistory.addEventListener("click",function()
{
clearHistory.addEventListener("click", function () {
localStorage.clear();
location.reload();

});
});
124 changes: 58 additions & 66 deletions popup/js/popup.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,46 @@
//Autofill Logic
var text=document.getElementById("query");
var suggestions=document.getElementsByClassName("suggestion");
/* eslint-disable func-names */
/* eslint-disable vars-on-top */
// Autofill Logic
var text = document.getElementById("query");
var suggestions = document.getElementsByClassName("suggestion");
function handleData(data) {
if(data[0]!="")
{
for(var i=0;i<(suggestions.length);i++)
{
if(data[1].length>0)
{
suggestions[i].classList.remove("off");
suggestions[i].innerHTML=data[1][i][0];
}
if (data[0] !== "") {
for (var i = 0; i < (suggestions.length); i += 1) {
if (data[1].length > 0) {
suggestions[i].classList.remove("off");
suggestions[i].innerHTML = data[1][i][0];
}
}
}
};
text.addEventListener("keyup",function(req,res){
if(text.value=="")
{
for(var i=0;i<(suggestions.length);i++)
{
suggestions[i].innerHTML="";
suggestions[i].classList.add("off");
}
}
text.addEventListener("keyup", function (req, res) {
if (text.value === "") {
for (var i = 0; i < (suggestions.length); i += 1) {
suggestions[i].innerHTML = "";
suggestions[i].classList.add("off");
}
}
for(var i=0;i<(suggestions.length);i++)
{
suggestions[i].addEventListener("click",function(req,res){
text.value=this.textContent;
for(var i=0;i<(suggestions.length);i++)
{
suggestions[i].classList.add("off");
for (var j = 0; j < (suggestions.length); j += 1) {
suggestions[j].addEventListener("click", function (req, res) {
text.value = this.textContent;
for (var k = 0; k < (suggestions.length); k += 1) {
suggestions[k].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='+text.value+'&xhr=t&callback=handleData');
var script = document.createElement("script");
// eslint-disable-next-line max-len
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<(suggestions.length);i++)
{
suggestions[i].classList.add("off");
}
// To make Suggestions Disapper when user clicks outside query field
document.body.addEventListener("click", function () {
for (var i = 0; i < (suggestions.length); i += 1) {
suggestions[i].classList.add("off");
}
});
text.addEventListener("click",function(event){
text.addEventListener("click", function (event) {
event.stopPropagation();
});

Expand Down Expand Up @@ -81,7 +76,9 @@ function keyboardShortCutListener(e) {
document.getElementById("books").checked = true;
}
} else if (e.ctrlKey && e.altKey && e.keyCode === 65) {
if ((document.getElementById("music").checked === true) && (document.getElementById("video").checked === true) && (document.getElementById("books").checked === true)) {
if ((document.getElementById("music").checked === true)
&& (document.getElementById("video").checked === true)
&& (document.getElementById("books").checked === true)) {
document.getElementById("music").checked = false;
document.getElementById("video").checked = false;
document.getElementById("books").checked = false;
Expand Down Expand Up @@ -201,56 +198,51 @@ function suggestion() {
document.getElementById("suggest-label").innerHTML = suggestions[random];
}

/* eslint-disable vars-on-top */
var theme;

function themeChange() {

theme = localStorage.getItem("theme");
if(theme == 'light' )
localStorage.setItem( "theme" , "dark" );
else
localStorage.setItem("theme", "light");
if (theme === "light") {
localStorage.setItem("theme", "dark");
} else { localStorage.setItem("theme", "light"); }

var bg = document.getElementById("content");
bg.classList.toggle("dark");

var labels = document.getElementsByTagName('label');
var labels = document.getElementsByTagName("label");
labels[0].classList.toggle("dark-label");
labels[1].classList.toggle("dark-label");
labels[2].classList.toggle("dark-label");

}

function recordSearchHistory()
{

var recentSearchQueries=[];
if(localStorage.getItem('search'))
recentSearchQueries=JSON.parse(localStorage.getItem('search'));
var x=text.value;
if(x!="" && recentSearchQueries.indexOf(x)==-1)
{
function recordSearchHistory() {
var recentSearchQueries = [];
if (localStorage.getItem("search")) {
recentSearchQueries = JSON.parse(localStorage.getItem("search"));
}
var x = text.value;
if (x !== "" && recentSearchQueries.indexOf(x) === -1) {
recentSearchQueries.push(x);
localStorage.setItem('search',JSON.stringify(recentSearchQueries));
}
localStorage.setItem("search", JSON.stringify(recentSearchQueries));
}
}


document.addEventListener("DOMContentLoaded", function () {
document.querySelector("button").addEventListener("click",function()
{
recordSearchHistory();
document.querySelector("button").addEventListener("click", function () {
recordSearchHistory();
register();
} );
});
document.addEventListener("keyup", keyboardShortCutListener, false);
suggestion();
suggestionAsValue();
if (!localStorage.getItem('theme'))
localStorage.setItem('theme', 'light');
if (!localStorage.getItem("theme")) {
localStorage.setItem("theme", "light");
}

if(localStorage.getItem("theme") == 'dark')
{
if (localStorage.getItem("theme") === "dark") {
themeChange();
localStorage.setItem( "theme" , "dark" );
localStorage.setItem("theme", "dark");
}
});
1 change: 1 addition & 0 deletions scripts/googleFearch.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// eslint-disable-next-line max-len
document.getElementById("hdtbSum").innerHTML = "<div style = 'padding: 13px; font-size: 200%; color: #6a6a6a;'>All the links below are FTP servers, containing your file, and similar content.<span style='color:#4285f4'> Total Enjoy!!</span></div>";

0 comments on commit f56b51c

Please sign in to comment.