diff --git a/.eslintrc b/.eslintrc index b1f0e35..ee19b25 100644 --- a/.eslintrc +++ b/.eslintrc @@ -11,6 +11,11 @@ "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", + "vars-on-top":"warn" } } diff --git a/Gruntfile.js b/Gruntfile.js index a181651..cbdeb47 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -5,7 +5,7 @@ module.exports = function (grunt) { options: { fix: false }, - target: ["*.js"] + target: ["**/*.js", "!node_module/**/*.js"] } }); diff --git a/options/css/options.css b/options/css/options.css index 382a014..3f479f2 100644 --- a/options/css/options.css +++ b/options/css/options.css @@ -1,4 +1,149 @@ + .main { - width: 200px; - height: 200px; -} \ No newline at end of file + width: 360px; + height: 500px; +} +#backButton +{ + background-color: white +} +#backButton:hover +{ + padding: 0px; + background-color: white; + opacity: 1; +} + +#searchHistory +{ + text-align: center; + background: white; + border: none; + width: 340px; + margin-left: 10px; + padding-bottom: 10px; + padding-top: 2px; +} +#historyHead +{ + font-family: 'Titillium Web', sans-serif; + color: grey; + text-align: left; +} +#themeHead +{ + font-family: 'Titillium Web', sans-serif; + color: grey; + text-align: left; + margin-left: 10px; + +} +#historyList +{ + text-align: left; + list-style: none; + font-family: "sans-serif", Arial, Helvetica; +} + +#clearButton +{ + border-radius: 7px; + font-style: "sans-serif", Arial, Helvetica; + font-weight: 600; + color: grey; + background-color: white; + border: none; + padding-top: 3px; +} +#clearButton:hover +{ + box-shadow: 0px 0px 7px 0px grey; +} +#clearHist +{ + text-align: right; +} + +ul li +{ + margin: 5px; + border-bottom: 1px solid grey; + padding-left: 10px; + padding-top: 2px; + padding-bottom: 2px; + width: 245px; + color: #5e605b; +} +a +{ + color: grey; + text-decoration: none; + +} +a:hover +{ + color: white; + background-color: grey; + padding: 8px; + opacity: .8; +} + +.switch { + margin-left: 10px; + position: relative; + display: inline-block; + width: 60px; + height: 34px; +} + +.switch input { + opacity: 0; + width: 0; + height: 0; +} + +.slider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: grey; + -webkit-transition: .4s; + transition: .4s; +} + +.slider:before { + position: absolute; + content: ""; + height: 26px; + width: 26px; + left: 4px; + bottom: 4px; + background-color: white; + -webkit-transition: .4s; + transition: .4s; +} + +input:checked + .slider { + background-color: #102c7c; +} + +input:focus + .slider { + box-shadow: 0 0 1px #2196F3; +} + +input:checked + .slider:before { + -webkit-transform: translateX(26px); + -ms-transform: translateX(26px); + transform: translateX(26px); +} + +.slider.round { + border-radius: 34px; +} + +.slider.round:before { + border-radius: 50%; +} \ No newline at end of file diff --git a/options/images2/backbutton.jpg b/options/images2/backbutton.jpg new file mode 100644 index 0000000..46ed9d4 Binary files /dev/null and b/options/images2/backbutton.jpg differ diff --git a/options/js/options.js b/options/js/options.js index 27a46e9..7194e4a 100644 --- a/options/js/options.js +++ b/options/js/options.js @@ -1,29 +1,51 @@ +var recentSearchQueries = []; +var recentSearchQueryUrls = []; +var historyListElement; +var clearHistory; +var count; +var themeToggle = document.getElementById("theme"); -var radios = document.getElementsByName('theme'); +if (!localStorage.getItem("theme")) localStorage.setItem("theme", "light"); -if(!localStorage.getItem('theme')) - localStorage.setItem('theme', 'light'); - -if(localStorage.getItem('theme') == 'light') -{ - console.log("light"); - radios[0].checked = true; -} -else -{ - console.log("dark"); - radios[1].checked = true; +if (localStorage.getItem("theme") === "light") { + themeToggle.checked = false; +} else { + themeToggle.checked = true; } function handleThemeChange(event) { - if(event.target.value == 'light') - 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 radios = document.getElementsByName('theme'); - radios[0].addEventListener('click', handleThemeChange); - radios[1].addEventListener('click', handleThemeChange); + themeToggle = document.getElementById("theme"); + themeToggle.addEventListener("click", handleThemeChange); +}); + +historyListElement = document.getElementById("historyList"); +clearHistory = document.querySelector("#clearButton"); + +recentSearchQueries = (JSON.parse(localStorage.getItem("search"))); +recentSearchQueryUrls = (JSON.parse(localStorage.getItem("link"))); + +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 br = document.createElement("br"); + historyListElement.appendChild(br); + var hr = document.createElement("hr"); + historyListElement.appendChild(hr); + count += 1; +}); + + +clearHistory.addEventListener("click", function () { + localStorage.clear(); + location.reload(); }); diff --git a/options/options.html b/options/options.html index 2eff85c..a44044e 100644 --- a/options/options.html +++ b/options/options.html @@ -4,21 +4,36 @@ Fearch - Options + + -
+ + +
-
- diff --git a/popup/js/popup.js b/popup/js/popup.js index 747ca9c..10df8c1 100644 --- a/popup/js/popup.js +++ b/popup/js/popup.js @@ -1,51 +1,45 @@ -//Autofill Logic -var text=document.getElementById("query"); -var suggestions=document.getElementsByClassName("suggestion"); +/* eslint-disable func-names */ +// 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(); }); @@ -81,7 +75,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; @@ -107,6 +103,7 @@ function register(event) { var dotCheck; var uuid; + query = text.value; query = encodeURIComponent(query); // Note :- avoid hardcoded uuid. @@ -146,6 +143,17 @@ function register(event) { formats = formats + "|" + suggestedFormat; } /* eslint-disable */ + + var recentSearchQueryUrls=[]; + if(localStorage.getItem('link')) + recentSearchQueryUrls=JSON.parse(localStorage.getItem('link')); + var sPhrase="http://www.google.com/search?q="+query+" -"+uuid+" -inurl:(htm|html|php|pls|txt) intitle:index.of \"last modified\" ("+formats+")"; + if(sPhrase!="" && recentSearchQueryUrls.indexOf(sPhrase)==-1) + { + recentSearchQueryUrls.push(sPhrase); + localStorage.setItem('link',JSON.stringify(recentSearchQueryUrls)); + } + window.open("http://www.google.com/search?q="+query+" -"+uuid+" -inurl:(htm|html|php|pls|txt) intitle:index.of \"last modified\" ("+formats+")"); /* eslint-enable */ } else { @@ -192,35 +200,47 @@ function suggestion() { 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) { + recentSearchQueries.push(x); + localStorage.setItem("search", JSON.stringify(recentSearchQueries)); + } } document.addEventListener("DOMContentLoaded", function () { - document.querySelector("button").addEventListener("click", register); + 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"); } }); diff --git a/scripts/googleFearch.js b/scripts/googleFearch.js index ca6f6c3..742da96 100644 --- a/scripts/googleFearch.js +++ b/scripts/googleFearch.js @@ -1 +1,2 @@ +// eslint-disable-next-line max-len document.getElementById("hdtbSum").innerHTML = "
All the links below are FTP servers, containing your file, and similar content. Total Enjoy!!
";