refactor: use 'sites' search parameter

https://stackoverflow.com/a/7305734
This commit is contained in:
curben 2019-08-11 00:09:23 +09:30
parent ab3a7c1af1
commit bd7342314d
No known key found for this signature in database
GPG Key ID: 5D9DB57A25D34EE3
2 changed files with 5 additions and 17 deletions

View File

@ -8,6 +8,7 @@
<div class="searchContainer">
<form id="searchForm" method="post" action="https://duckduckgo.com/" target="_blank">
<input type="text" name="q" class="searchBox" id="searchTxt" placeholder="Search..." title="Powered by DuckDuckGo">
<input type="hidden" name="sites" value="curben.netlify.com">
<input type="hidden" name="kd" value="-1">
<input type="hidden" name="kg" value="p">
<input type="hidden" name="kae" value="#000">
@ -31,6 +32,7 @@
<div class="searchContainer">
<form id="searchFormMob" method="post" action="https://duckduckgo.com/" target="_blank">
<input type="text" name="q" class="searchBox" id="searchTxtMob" placeholder="Search..." title="Powered by DuckDuckGo">
<input type="hidden" name="sites" value="curben.netlify.com">
<input type="hidden" name="kd" value="-1">
<input type="hidden" name="kg" value="p">
<input type="hidden" name="kae" value="#000">

View File

@ -1,24 +1,10 @@
// Search button function
const searchClick = document.getElementById('searchClick')
searchClick.addEventListener('click', () => {
const searchTxt = document.getElementById('searchTxt')
const searchForm = document.getElementById('searchForm')
searchTxt.value = searchTxt.value + ' site:curben.netlify.com'
document.getElementById('searchClick').addEventListener('click', () => {
searchForm.submit()
searchTxt.value = searchTxt.value.replace(' site:curben.netlify.com', '')
}, false)
const searchClickMob = document.getElementById('searchClickMob')
searchClickMob.addEventListener('click', () => {
const searchTxt = document.getElementById('searchTxtMob')
const searchForm = document.getElementById('searchFormMob')
searchTxt.value = searchTxt.value + ' site:curben.netlify.com'
searchForm.submit()
searchTxt.value = searchTxt.value.replace(' site:curben.netlify.com', '')
document.getElementById('searchClickMob').addEventListener('click', () => {
searchFormMob.submit()
}, false)
/*