Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions index.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ body {
}
.description {
font-style: oblique;
text-align: center;
}
.search_wrapper {
border: 0.125rem solid rgb(23, 23, 23);
Expand Down
26 changes: 25 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ let current_search = 'google'
document.querySelector('.search_input').addEventListener('keyup', e => {
const input = e.target.value;
let search_engine = input.split(' ')[0].toLowerCase();
let search_query = input.split(' ').splice(0).join(' ');
let search_query = input.split(' ').splice(1);
switch(search_engine){
case 'google':
case 'youtube':
case 'sheets':
case 'slides':
case 'drive':
case 'docs': break;
default: search_engine = 'google';
search_query = input;
Expand All @@ -26,6 +29,18 @@ document.querySelector('.search_input').addEventListener('keyup', e => {
image.src = 'docs.png';
image.alt = 'Google Docs icon';
break;
case 'slides':
image.src = "slides.png";
image.alt = "Google Slides icon";
break;
case 'drive':
image.src = "drive.png";
image.alt = "Google drive icon";
break;
case 'sheets':
image.src = "sheets.png";
image.alt = "Google Sheets icon";
break;
}
}
if(e.key === 'Enter')
Expand All @@ -36,6 +51,15 @@ document.querySelector('.search_input').addEventListener('keyup', e => {
case 'youtube':
window.location = `https://www.youtube.com/results?search_query=${search_query}`;
break;
case 'drive':
window.location = `https://drive.google.com/drive/search?q=${search_query}`;
break;
case 'slides':
window.location = `https://docs.google.com/presentation/?q=${search_query}`;
break;
case 'sheets':
window.location = `https://docs.google.com/spreadsheets?q=${search_query}`;
break;
default:
window.location = `https://www.google.com/search?q=${search_query}`;
}
Expand Down