-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#124 Implement Search history #129
base: master
Are you sure you want to change the base?
Changes from 1 commit
44afcad
0e14876
f17ce0f
f56b51c
3c9228b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,152 @@ | ||
|
||
.main { | ||
width: 200px; | ||
height: 200px; | ||
} | ||
width: 360px; | ||
height: 500px; | ||
} | ||
#backB | ||
{ | ||
background-color: white | ||
} | ||
#backB: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; | ||
} | ||
#histHead | ||
{ | ||
font-family: 'Titillium Web', sans-serif; | ||
color: grey; | ||
text-align: left; | ||
} | ||
#tHead | ||
{ | ||
font-family: 'Titillium Web', sans-serif; | ||
color: grey; | ||
text-align: left; | ||
margin-left: 10px; | ||
|
||
} | ||
#hList | ||
{ | ||
text-align: left; | ||
list-style: none; | ||
font-family: "sans-serif", Arial, Helvetica; | ||
} | ||
|
||
#histClear | ||
{ | ||
border-radius: 7px; | ||
font-style: "sans-serif", Arial, Helvetica; | ||
font-weight: 600; | ||
color: grey; | ||
background-color: white; | ||
border: none; | ||
} | ||
#histClear:hover | ||
{ | ||
box-shadow: 0px 0px 7px 0px grey; | ||
} | ||
#xadd | ||
{ | ||
color: red; | ||
} | ||
#cHist | ||
{ | ||
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%; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,74 @@ | ||
|
||
var radios = document.getElementsByName('theme'); | ||
var histo=[]; | ||
var histLink=[]; | ||
var radios = document.getElementById('them'); | ||
|
||
if(!localStorage.getItem('theme')) | ||
localStorage.setItem('theme', 'light'); | ||
|
||
if(localStorage.getItem('theme') == 'light') | ||
{ | ||
console.log("light"); | ||
phoenix7139 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
radios[0].checked = true; | ||
radios.checked = false; | ||
} | ||
else | ||
{ | ||
console.log("dark"); | ||
radios[1].checked = true; | ||
radios.checked = true; | ||
} | ||
|
||
function handleThemeChange(event) { | ||
if(event.target.value == 'light') | ||
if(radios.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 radios = document.getElementById('them'); | ||
radios.addEventListener('click', handleThemeChange); | ||
}); | ||
|
||
var mydiv = document.getElementById("hList"); | ||
var histButton = document.querySelector("#histClear"); | ||
|
||
histo=(JSON.parse(localStorage.getItem('search'))); | ||
histLink=(JSON.parse(localStorage.getItem('link'))); | ||
|
||
mydiv.textContent=""; | ||
var count=0; | ||
histo.forEach(function(entr) | ||
{ | ||
|
||
|
||
var aTag = document.createElement('a'); | ||
aTag.setAttribute('target','_blank') | ||
aTag.setAttribute('href',histLink[count]); | ||
aTag.innerHTML = entr; | ||
mydiv.appendChild(aTag); | ||
var mybr = document.createElement('br'); | ||
phoenix7139 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
mydiv.appendChild(mybr); | ||
var myhr = document.createElement('hr'); | ||
mydiv.appendChild(myhr); | ||
count++; | ||
|
||
}) | ||
|
||
|
||
histButton.addEventListener("mouseover",function() | ||
{ | ||
document.getElementById("xadd").innerHTML="X"; | ||
|
||
}); | ||
|
||
histButton.addEventListener("mouseout",function() | ||
{ | ||
document.getElementById("xadd").innerHTML=""; | ||
|
||
}); | ||
|
||
histButton.addEventListener("click",function() | ||
{ | ||
localStorage.clear(); | ||
location.reload(); | ||
|
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,6 +107,7 @@ function register(event) { | |
var dotCheck; | ||
var uuid; | ||
|
||
|
||
query = text.value; | ||
query = encodeURIComponent(query); | ||
// Note :- avoid hardcoded uuid. | ||
|
@@ -146,6 +147,17 @@ function register(event) { | |
formats = formats + "|" + suggestedFormat; | ||
} | ||
/* eslint-disable */ | ||
|
||
var sLink=[]; | ||
if(localStorage.getItem('link')) | ||
sLink=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+")"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sPhrase can have a better name. |
||
if(sPhrase!="" && sLink.indexOf(sPhrase)==-1) | ||
{ | ||
sLink.push(sPhrase); | ||
localStorage.setItem('link',JSON.stringify(sLink)); | ||
} | ||
|
||
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 { | ||
|
@@ -209,9 +221,27 @@ function themeChange() { | |
|
||
} | ||
|
||
function recordSearchHistory() | ||
{ | ||
|
||
var sHist=[]; | ||
if(localStorage.getItem('search')) | ||
sHist=JSON.parse(localStorage.getItem('search')); | ||
var x=text.value; | ||
if(x!="" && sHist.indexOf(x)==-1) | ||
{ | ||
sHist.push(x); | ||
localStorage.setItem('search',JSON.stringify(sHist)); | ||
} | ||
} | ||
|
||
|
||
document.addEventListener("DOMContentLoaded", function () { | ||
document.querySelector("button").addEventListener("click", register); | ||
document.querySelector("button").addEventListener("click",function() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need a style linter. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please elaborate? I don't know what a linter is There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
|
There was a problem hiding this comment.
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.