Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 148 additions & 3 deletions options/css/options.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,149 @@

.main {
width: 200px;
height: 200px;
}
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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tabs vs spaces :P
Please can you format this.

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%;
}
Binary file added options/images2/backbutton.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 43 additions & 8 deletions options/js/options.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,64 @@

var radios = document.getElementsByName('theme');
var retrieveQuery=[];
var retrieveURL=[];
var toggle = document.getElementById('them');

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

if(localStorage.getItem('theme') == 'light')
{
console.log("light");
radios[0].checked = true;
toggle.checked = false;
}
else
{
console.log("dark");
radios[1].checked = true;
toggle.checked = true;
}

function handleThemeChange(event) {
if(event.target.value == 'light')
if (toggle.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);
var toggle = document.getElementById('them');
toggle.addEventListener('click', handleThemeChange);
});

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

retrieveQuery=(JSON.parse(localStorage.getItem('search')));
retrieveURL=(JSON.parse(localStorage.getItem('link')));

mydiv.textContent="";
var count=0;
retrieveQuery.forEach(function(entr)
{


var aTag = document.createElement('a');
aTag.setAttribute('target','_blank')
aTag.setAttribute('href',retrieveURL[count]);
aTag.innerHTML = entr;
mydiv.appendChild(aTag);
var mybr = document.createElement('br');
mydiv.appendChild(mybr);
var myhr = document.createElement('hr');
mydiv.appendChild(myhr);
count++;

})




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

});
29 changes: 22 additions & 7 deletions options/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,36 @@
<head>
<title>Fearch - Options</title>
<link href="css/options.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Staatliches" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Titillium+Web" rel="stylesheet">
<meta charset="utf-8">
</head>

<body>
<div class="main">
<a href="../popup/popup.html" id="backButton" >
<img src="images2/backbutton.jpg" height="24px" width="24px">
</a>
<form>
<label>
<b>Select theme</b>
<br />
<input type="radio" name="theme" value="light"> Light<br>
<input type="radio" name="theme" value="dark"> Dark<br>
<br/>
<h2 id="themeHead">THEME</h2>
<label class="switch">
<input type="checkbox" name="theme" id="them">
<span class="slider round"></span>
</label>
</form>
<br/>
<hr/>
<div id="searchHistory">
<h2 id="historyHead">HISTORY</h2>
<div id="historyList">

</div>
<br/>
<div id="clearHist">
<button id="clearButton">CLEAR HISTORY </button>
</div>
</div>
</div>
<script src="js/options.js"></script>
</body>

</html>
32 changes: 31 additions & 1 deletion popup/js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ function register(event) {
var dotCheck;
var uuid;


query = text.value;
query = encodeURIComponent(query);
// Note :- avoid hardcoded uuid.
Expand Down Expand Up @@ -146,6 +147,17 @@ function register(event) {
formats = formats + "|" + suggestedFormat;
}
/* eslint-disable */

var saveURL=[];
if(localStorage.getItem('link'))
saveURL=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+")";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sPhrase can have a better name.

if(sPhrase!="" && saveURL.indexOf(sPhrase)==-1)
{
saveURL.push(sPhrase);
localStorage.setItem('link',JSON.stringify(saveURL));
}

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 {
Expand Down Expand Up @@ -209,9 +221,27 @@ function themeChange() {

}

function recordSearchHistory()
{

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


document.addEventListener("DOMContentLoaded", function () {
document.querySelector("button").addEventListener("click", register);
document.querySelector("button").addEventListener("click",function()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a style linter.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please elaborate? I don't know what a linter is

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sure. Linters help to find potential errors in code. You can look into eslint and prettier(style linter - not necessarily errors but helps to have standard coding style throughout the project).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have corrected all the errors in the updated files in accordance with the Airbnb configuration of ESlint that was already setup. I have also added a max-len rule in the .eslintrc file.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope you had fun learning about linters they have a pretty integral part in development.

I apologies so many changes might seem intimidating. But it is happening because this is a really big feature and is introducing a lot code into the codebase. Imagine if we straightaway merge this code, people who might want to contribute next year will face so much trouble to add more awesome features like these. Hope you understand.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course. This experience is teaching me a lot that I would probably haven't learnt otherwise

{
recordSearchHistory();
register();
} );
document.addEventListener("keyup", keyboardShortCutListener, false);
suggestion();
suggestionAsValue();
Expand Down