diff --git a/drive.png b/drive.png new file mode 100644 index 0000000..e1e4f64 Binary files /dev/null and b/drive.png differ diff --git a/index.css b/index.css index 09dae3a..5ec675b 100644 --- a/index.css +++ b/index.css @@ -15,7 +15,7 @@ body { display: flex; flex-direction: column; max-width: min(100vw, 80rem); - /* Hint */ + text-align: center; } .container > * { margin: 0.5rem; @@ -88,4 +88,4 @@ body { .search_icon { width: 1.5rem; height: 1.5rem; -} \ No newline at end of file +} diff --git a/index.js b/index.js index ba99abc..6f36ec0 100644 --- a/index.js +++ b/index.js @@ -2,13 +2,16 @@ 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(' ')[1]; switch(search_engine){ case 'google': case 'youtube': - case 'docs': break; + case 'docs': + case 'drive': + case 'slides': + case 'sheets': break; default: search_engine = 'google'; - search_query = input; + // search_query = input.split(' ')[1]; } if(search_engine !== current_search) { current_search = search_engine; @@ -26,17 +29,47 @@ document.querySelector('.search_input').addEventListener('keyup', e => { image.src = 'docs.png'; image.alt = 'Google Docs icon'; break; + case 'drive': + image.src = 'drive.png'; + image.alt = 'Google Drive icon'; + break; + case 'slides': + image.src = 'slides.png'; + image.alt = 'Google Drive icon'; + break; + case 'sheets': + image.src = 'sheets.png'; + image.alt = 'Google Drive icon'; + break; + + + default: + image.src = 'google.png'; + image.alt = 'Google icon'; } - } + } if(e.key === 'Enter') switch(search_engine) { case 'docs': window.location = `https://docs.google.com/document/?q=${search_query}`; break; - case 'youtube': + case 'youtube': window.location = `https://www.youtube.com/results?search_query=${search_query}`; break; - default: + + case 'drive': + window.location = `https://drive.google.com/drive/search?q=${search_query}` ; + break; + + case 'slides': + window.location = `https://docs.google.com/presentation/u/0/?tgif=d&q=${search_query}` ; + break; + + case 'sheets': + window.location = `https://docs.google.com/spreadsheets/u/0/?tgif=d&q=${search_query}` ; + break; + + default: window.location = `https://www.google.com/search?q=${search_query}`; } -}); \ No newline at end of file +}); diff --git a/sheets.png b/sheets.png new file mode 100644 index 0000000..e95f684 Binary files /dev/null and b/sheets.png differ diff --git a/slides.png b/slides.png new file mode 100644 index 0000000..ede1c29 Binary files /dev/null and b/slides.png differ