From d43c916dcbb8b9f4ab37bc837384c10896c60f2c Mon Sep 17 00:00:00 2001 From: Brett Crafton <100751696+BrettCrafton@users.noreply.github.com> Date: Mon, 13 Jun 2022 21:57:19 -0500 Subject: [PATCH 1/7] added res: Thumbnails for Social Media "Metatags" --- resources.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/resources.js b/resources.js index 50666f5..d01a517 100644 --- a/resources.js +++ b/resources.js @@ -259,6 +259,11 @@ const resources = [ url: 'https://cloudconvert.com/jpg-to-webp', keywords: ['jpg', 'webp', 'converter', 'heic', 'formats', 'high-quality', 'api'] }, + { + name: 'Thumbnails for Social Media "Metatags', + url: 'https://nickcarmont8.medium.com/how-to-add-a-website-thumbnail-for-sharing-your-html-site-on-social-media-facebook-linkedin-12813f8d2618', + keywords: ['metadata', 'metatags', 'thumbnails', 'social media'] + }, // Resource Format - please follow the styling below. // { // name: '', From 13c4c44a83af9dc9277b7c23e36d686a67d78ade Mon Sep 17 00:00:00 2001 From: Brett Crafton <100751696+BrettCrafton@users.noreply.github.com> Date: Mon, 13 Jun 2022 22:02:08 -0500 Subject: [PATCH 2/7] add res: Learn CSS Layouts --- resources.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/resources.js b/resources.js index d01a517..e3752a6 100644 --- a/resources.js +++ b/resources.js @@ -264,6 +264,11 @@ const resources = [ url: 'https://nickcarmont8.medium.com/how-to-add-a-website-thumbnail-for-sharing-your-html-site-on-social-media-facebook-linkedin-12813f8d2618', keywords: ['metadata', 'metatags', 'thumbnails', 'social media'] }, + { + name: 'Learn CSS Layouts', + url: 'https://learnlayout.com/', + keywords: ['CSS', 'Layouts', 'HTML', 'display'] + }, // Resource Format - please follow the styling below. // { // name: '', From 67b6a435baa55932a6bf891dcec83c8b5fbf0a92 Mon Sep 17 00:00:00 2001 From: Jacob Asper Date: Mon, 13 Jun 2022 23:09:59 -0400 Subject: [PATCH 3/7] added function removing default for enter press --- public/js/main.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/public/js/main.js b/public/js/main.js index 0d97e33..aec2958 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -7,6 +7,24 @@ scrollBtn.addEventListener("click", function () { left: 0, }); }); +const input = document.querySelector('input') +//add event listener for when input is focused +input.addEventListener('keydown', (e) => { + if (e.key === 'Enter') { + //stop browser from refreshing + e.preventDefault() + searchOnEnterPress() + //reset search bar to empty + document.querySelector('input').value = '' + } +}); + +function searchOnEnterPress() { + //if enter key is pressed, search + console.log('focused') + getMatches() +} + const btn = document.getElementById('keyword-btn'); btn.addEventListener('click', getMatches); @@ -40,7 +58,7 @@ function renderMatches(matches) { list.innerHTML = ''; // For every match found, render the objects to the DOM in JSON format - if(matches.length > 0) { + if (matches.length > 0) { matches.forEach(match => { const li = document.createElement('li'); From 59e9f23a401f11e27212cad318a0451add609382 Mon Sep 17 00:00:00 2001 From: Brett Crafton <100751696+BrettCrafton@users.noreply.github.com> Date: Mon, 13 Jun 2022 22:10:23 -0500 Subject: [PATCH 4/7] add res: 4 cheat sheets --- resources.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/resources.js b/resources.js index e3752a6..a5eb034 100644 --- a/resources.js +++ b/resources.js @@ -265,9 +265,24 @@ const resources = [ keywords: ['metadata', 'metatags', 'thumbnails', 'social media'] }, { - name: 'Learn CSS Layouts', - url: 'https://learnlayout.com/', - keywords: ['CSS', 'Layouts', 'HTML', 'display'] + name: 'HTML Cheat Sheet', + url: 'https://htmlcheatsheet.com/', + keywords: ['HTML', 'cheat sheet', 'tags'] + }, + { + name: 'CSS Cheat Sheet', + url: 'https://htmlcheatsheet.com/css/', + keywords: ['CSS', 'cheat sheet', 'box model', 'selectors', 'color picker'] + }, + { + name: 'JS "JavaScript" Cheat Sheet', + url: 'https://htmlcheatsheet.com/js/', + keywords: ['JS', 'Javascript', 'cheat sheet', 'conditionals', 'loops', 'variables', 'dates', 'events', 'functions', 'regex', 'json', 'promises', 'arrays'] + }, + { + name: 'SEO Cheat Sheet', + url: 'https://htmlcheatsheet.com/seo/', + keywords: ['SEO', 'cheat sheet'] }, // Resource Format - please follow the styling below. // { From dcfad272738ec8d9a32d9cd7b17fa775e22c76ef Mon Sep 17 00:00:00 2001 From: Jacob Asper Date: Mon, 13 Jun 2022 23:16:28 -0400 Subject: [PATCH 5/7] got rid of unnecessary function --- public/js/main.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/public/js/main.js b/public/js/main.js index aec2958..2e437c2 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -13,18 +13,12 @@ input.addEventListener('keydown', (e) => { if (e.key === 'Enter') { //stop browser from refreshing e.preventDefault() - searchOnEnterPress() + getMatches() //reset search bar to empty document.querySelector('input').value = '' } }); -function searchOnEnterPress() { - //if enter key is pressed, search - console.log('focused') - getMatches() -} - const btn = document.getElementById('keyword-btn'); btn.addEventListener('click', getMatches); From 473c3bf8f4c967960173591c05a05be9576b5209 Mon Sep 17 00:00:00 2001 From: Jacob Asper Date: Mon, 13 Jun 2022 23:21:18 -0400 Subject: [PATCH 6/7] scrolled back to the top on search --- public/js/main.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/js/main.js b/public/js/main.js index 2e437c2..9697f5c 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -7,7 +7,9 @@ scrollBtn.addEventListener("click", function () { left: 0, }); }); + const input = document.querySelector('input') +const scrollContainer = document.querySelector('.scroll-container') //add event listener for when input is focused input.addEventListener('keydown', (e) => { if (e.key === 'Enter') { @@ -16,6 +18,8 @@ input.addEventListener('keydown', (e) => { getMatches() //reset search bar to empty document.querySelector('input').value = '' + //scroll back to the top + scrollContainer.scrollTop = 0 } }); From 6b785021f5e0aff3aa099a3a102c59bcca11f2b6 Mon Sep 17 00:00:00 2001 From: Jacob Asper Date: Mon, 13 Jun 2022 23:21:51 -0400 Subject: [PATCH 7/7] moved scroll to the top into getMatches function so it works for button click too --- public/js/main.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/js/main.js b/public/js/main.js index 9697f5c..af3f4fa 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -16,10 +16,6 @@ input.addEventListener('keydown', (e) => { //stop browser from refreshing e.preventDefault() getMatches() - //reset search bar to empty - document.querySelector('input').value = '' - //scroll back to the top - scrollContainer.scrollTop = 0 } }); @@ -44,6 +40,10 @@ async function getMatches() { } catch (err) { console.error(err); } + //reset search bar to empty + document.querySelector('input').value = '' + //scroll back to the top + scrollContainer.scrollTop = 0 } /**