-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8637e91
commit e60ea61
Showing
2 changed files
with
82 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,56 @@ | ||
var recentSearchQueries=[]; | ||
var recentSearchQueryUrls=[]; | ||
var toggle = document.getElementById('theme'); | ||
|
||
if(!localStorage.getItem('theme')) | ||
localStorage.setItem('theme', 'light'); | ||
|
||
if(localStorage.getItem('theme') == 'light') | ||
{ | ||
/* eslint-disable no-unused-vars */ | ||
/* eslint-disable no-restricted-globals */ | ||
/* eslint-disable vars-on-top */ | ||
var recentSearchQueries = []; | ||
var recentSearchQueryUrls = []; | ||
var historyListElement; | ||
var clearHistory; | ||
var count; | ||
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 | ||
{ | ||
} else { | ||
console.log("dark"); | ||
toggle.checked = true; | ||
} | ||
|
||
function handleThemeChange(event) { | ||
if (toggle.checked==false) | ||
localStorage.setItem('theme', 'light'); | ||
else | ||
localStorage.setItem('theme', 'dark'); | ||
if (toggle.checked === false) localStorage.setItem("theme", "light"); | ||
else localStorage.setItem("theme", "dark"); | ||
} | ||
|
||
document.addEventListener("DOMContentLoaded", function () { | ||
var toggle = document.getElementById('theme'); | ||
toggle.addEventListener('click', handleThemeChange); | ||
toggle = document.getElementById("theme"); | ||
toggle.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'); | ||
var mybr = document.createElement("br"); | ||
historyListElement.appendChild(mybr); | ||
var myhr = document.createElement('hr'); | ||
var myhr = document.createElement("hr"); | ||
historyListElement.appendChild(myhr); | ||
count++; | ||
|
||
}) | ||
|
||
|
||
count += 1; | ||
}); | ||
|
||
|
||
clearHistory.addEventListener("click",function() | ||
{ | ||
clearHistory.addEventListener("click", function () { | ||
localStorage.clear(); | ||
location.reload(); | ||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters