From 576794933dece90554d7024dbf0fadfc6d8fcf4a Mon Sep 17 00:00:00 2001 From: Phil B Date: Fri, 14 Sep 2018 00:39:05 +0100 Subject: [PATCH 01/13] Unstyled but kind of working news app --- images/header-ventoux.jpg | Bin 0 -> 17795 bytes index.html | 54 ++++++++++++++++++++++ index.js | 92 ++++++++++++++++++++++++++++++++++++++ style.css | 83 ++++++++++++++++++++++++++++++++++ 4 files changed, 229 insertions(+) create mode 100644 images/header-ventoux.jpg create mode 100644 index.html create mode 100644 index.js create mode 100644 style.css diff --git a/images/header-ventoux.jpg b/images/header-ventoux.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5df79421f1d161047daff3520f2f2d73154ac069 GIT binary patch literal 17795 zcmbSyRX`oh(%|4uu;A_x+}$O(1`F;G+#P}i_u%dj9D=*MI|O&P;DkNo`|iK@VIOw4 zXXbQwO?7ouYgJ93*TvTj07Y6tN&)}_1v)S~0C?Sm=Mi_aFa-c9DOvy)0021P9T+%( z0ZMs*9+ZF6QJ^#~7!&{oigQ5^-oNQmP?{PH;x8N=lx7CuBZA@@(8Ka?*>+Gm)&HNe z)1b7)H^{&E%b>I>h@hglysEGUv8b(sovnj`lZCAf@qb`4%*;$;#Qy|<4utzw|9@gh zDLF-A76xV}1~!0&iJ6OsiJOO+iI|0zhmC`WiS;k8E~o(X|I|(m%4Ph^2@@zy6#@ag zaXkonAY%TJnhOMni~9$T0)oTG{lmE|2>uq{qBp8Gpco$XurM)!YGVf7#7s;)pqq^g z;QSX4)Sh7f$of_c?B6s$=q)&?%^*N=GYAgxZ~H-m^3ea4e*bU!4G#?bA3B{NeDHtM z_HW$<3b22#*Z=O_H#R|-uPcBk01FKb0}TZW0|NsG2MdpgfrN;FfQW;J{tklxmxz!6 z7ayOPoPmm%l#UD^pPG|~j)|F#jg5$ko1cq?kAanq<&6j!92^`X0wOjN5;hA7J_*bJ zb9n6pP+Jw%+Ad(EG{i?Zf)=E z?(H8O9$j8t-~7J4yMK6mlj}{+|AhaeT&N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B36nl z3PNqi48)xzb*B#J_KV>Z^hX_y^CCgIj4IW%O4&WNnXE*(<=}j6ei?~L5C)tU z>HaG1mPjil{xG7g#K1bY$yWk={lW(`Stg{4^ge+_qqa8BY+;XA)q@-r#r zJnDb^WR26>B*(Ku^6HnGXFy(U=vnT{Pg717gHKF zZ5!&kjZN5-mnHw8DqQD&X5yrk*~nv2Vy7Z+(j+9rnZcDAYQW=zQ!Sx%-7$}5NKBI| z9GkZL{A7$m;F3&Crc*xbX{%}{N-?N`!Dz*$AKTc&5O?i2Ua*0T0t?-PVhEMD4Uujy z@7|}(tz#OJpU%~v_bZXZR^saTW1ab$Gq4G} z9b6;@gjfZA6lqDd>+qrIY2TDcB0DGYAVVVaJ&ek^*iu>T;zhv^$6>7Ew*$Bv-j6BG z2=eXi3F#&B)*5D>q)hU5XX|GRc=SszH)q^^9nyI>Fae>}Mwaly6us~kA5*DuRXqRF#xXlXJ{cqDAVZdLGE$Q!k{Twpf6FA*u_wr);Xst9 z^98tpfXkU(OdW%&%O$iYj$>%thHz@7JB~$Dsb(fieI#0A&KBr61Ft4zs0KGD437xX z(+<&A&owGDD%U%PX1@!sOw@9>c<((fkeh+BUZEr$cIw!008GCEDW!hs$-bwZmdX?M z_;8p5W|&cm32Oy&^FoOZK68_=OHF14slaCp}C`{#O8!0B!%E zHLmzTiW+0qz5Un(agPU27-5A}UQT7k@f<;<@9UI=&m+fkDC+fbR2*&1!veV+0E1Du zc@@DlJ@7S^+Rku_F9X#4nI(0anAQa0^l?CxK-Ntv1>bBFY1l{Cuge@_#lr*y4_w@2 s)8CZ|pfu@*%X2P{ImC|`;s71KxQN!*8ltpK;~_&^KH0`fmUPem*_ + + + + + + + Layout 2 + + + + +

+
+
+
+ +
Search for anything. About cycling ....
+ +
+ +
+ + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..a26dc97 --- /dev/null +++ b/index.js @@ -0,0 +1,92 @@ +function formListener () { + const formElement = document.querySelector("form"); + const formInput = document.querySelector("#form-search"); + formElement.addEventListener('submit', event => { + event.preventDefault(); + clearArticles(); + search = formInput.value; + page=1; + getArticles(1) + console.log("HI"); + }); +} + +function nextListener () { + const nextButton = document.querySelector("#next"); + nextButton.addEventListener('click', event => { + page ++; + console.log(`getting page: ${page}`) + + getArticles(page); + addPageLink(); + }); +} + + +function mouseOverArticle(articleNode) { + articleNode.addEventListener("mouseover", event => { + articleNode.style.backgroundColor = "red"; + }) + articleNode.addEventListener("mouseout", event => { + articleNode.style.backgroundColor = "white"; + }) +} + +function clearArticles() { + const mainNode = document.querySelector('main'); + mainNode.innerHTML = ""; +} + +function createArticles(body) { + clearArticles(); + body.articles.forEach(article => { + const articleNode = document.createElement('div'); + articleNode.innerHTML = ` +
${article.title}
+ ` + const parentNode = document.querySelector('main'); + parentNode.appendChild(articleNode); + mouseOverArticle(articleNode); + }); +}; + +function getArticles(page) { + var url = 'https://newsapi.org/v2/everything?' + + 'q=' + search + + '&page=' + page + + '&apiKey=280f7af9f5c448c4a3598861960c947a'; + var req = new Request(url); + fetch(req) + .then(function (response) { + return response.json(); + }) + .then(function (body) { + createArticles(body); + }) +} + +function addPageLink() { + const pageLinkNode = document.createElement('li'); + const parentNode = document.querySelector('.pagination__ul'); + console.log(parentNode); + pageLinkNode.innerHTML = page; + pageLinkNode.className = "pagination__page"; + parentNode.appendChild(pageLinkNode); + pageLinkNode.addEventListener("click", event => {getArticles(pageLinkNode.innerHTML)}); +} + + +let search = "cycling"; +let page = 1; +getArticles(); +formListener(); +nextListener(); +addPageLink(); + diff --git a/style.css b/style.css new file mode 100644 index 0000000..3f46771 --- /dev/null +++ b/style.css @@ -0,0 +1,83 @@ +* { + box-sizing: inherit; +} + +body { + box-sizing: border-box; + margin: 0; + font-family: "Open Sans", sans-serif; + display: flex; + flex-direction: column; + min-height: 100vh; + background: gray; + } + +.app { + display: flex; + flex-direction: column; + flex:1; + background: white; +} + +.hero__photo { + display:flex; + flex-direction:row; + min-height:200px; + background-image: + url("images/header-ventoux.jpg"); + object-fit: cover; + + } + +img { + width:100%; + height:auto; + } + +nav { + display:none; +} + +main { + display: flex; + flex-direction: column; + margin: 10px; +} + +article { + display: flex; + flex-direction: column; + margin: 0 0 10px 0; +} + +.article__title { + margin-bottom: 5px; + font-weight:400; +} + +.article__description { + font-size:0.8em; +} + +.article__meta { + display:flex; + flex-direction: row; + justify-content: space-between; + border-bottom:2px; + font-size:0.8em; +} + +.article__image { + display:none; +} + +.pagination__ul { + display:flex; + flex-direction:row; + flex:1; +} + +.pagination__page { + display:flex; + min-width:50px; +} From 501780ce7b5d21f5c73b7bc4f21da2c9a0f22610 Mon Sep 17 00:00:00 2001 From: Phil B Date: Fri, 14 Sep 2018 11:03:37 +0100 Subject: [PATCH 02/13] minor updates to styling, added click event to article div, refectored article template --- index.html | 22 ++++++++++------------ index.js | 47 +++++++++++++++++++++++++++++++++-------------- style.css | 30 ++++++++++++++++++++++++++---- 3 files changed, 69 insertions(+), 30 deletions(-) diff --git a/index.html b/index.html index 572afe1..6303db4 100644 --- a/index.html +++ b/index.html @@ -15,23 +15,20 @@
- -
Search for anything. About cycling ....
- + +
All the news ... All the time!
+
-
- - -
@@ -48,6 +45,7 @@ + diff --git a/index.js b/index.js index a26dc97..2742f38 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,4 @@ +// adds a listener to the search submit button function formListener () { const formElement = document.querySelector("form"); const formInput = document.querySelector("#form-search"); @@ -7,10 +8,10 @@ function formListener () { search = formInput.value; page=1; getArticles(1) - console.log("HI"); }); } +// adds a listener to the next button function nextListener () { const nextButton = document.querySelector("#next"); nextButton.addEventListener('click', event => { @@ -22,46 +23,63 @@ function nextListener () { }); } - +// adds listeners that change the colour of the article the mouse is over function mouseOverArticle(articleNode) { articleNode.addEventListener("mouseover", event => { articleNode.style.backgroundColor = "red"; }) articleNode.addEventListener("mouseout", event => { - articleNode.style.backgroundColor = "white"; + articleNode.style.backgroundColor = "gray"; + }) +} + +// add a listener to article creating 'click' event that takes user to URL +function clickArticle(articleNode, url) { + articleNode.addEventListener("click", event => { + window.location = url; }) } +// clears existing articles from page in preparation for a new search or new page function clearArticles() { const mainNode = document.querySelector('main'); mainNode.innerHTML = ""; } -function createArticles(body) { - clearArticles(); - body.articles.forEach(article => { - const articleNode = document.createElement('div'); - articleNode.innerHTML = ` +function articleTemplate(article) { + return `
${article.title}
- ` + ` +} + + +// takes request body and turns it into html to be appended into 'main' +function createArticles(body) { + clearArticles(); + body.articles.forEach(article => { + const articleNode = document.createElement('div'); + articleNode.className = "article"; + articleNode.innerHTML = articleTemplate(article); const parentNode = document.querySelector('main'); parentNode.appendChild(articleNode); - mouseOverArticle(articleNode); + mouseOverArticle(articleNode) + clickArticle(articleNode, article.url); }); }; +// api request to news api. Returns json and calls createArticles function function getArticles(page) { var url = 'https://newsapi.org/v2/everything?' + 'q=' + search + '&page=' + page + - '&apiKey=280f7af9f5c448c4a3598861960c947a'; + '&apiKey=280f7af9f5c448c4a3598861960c947a&sortBy=publishedAt'; var req = new Request(url); fetch(req) .then(function (response) { @@ -72,6 +90,7 @@ function getArticles(page) { }) } +// adds a link to a new page when the next button is clicked function addPageLink() { const pageLinkNode = document.createElement('li'); const parentNode = document.querySelector('.pagination__ul'); @@ -83,7 +102,7 @@ function addPageLink() { } -let search = "cycling"; +let search = "uk"; let page = 1; getArticles(); formListener(); diff --git a/style.css b/style.css index 3f46771..18d5d88 100644 --- a/style.css +++ b/style.css @@ -3,6 +3,7 @@ } body { + box-sizing: border-box; margin: 0; font-family: "Open Sans", sans-serif; @@ -15,10 +16,15 @@ body { .app { display: flex; flex-direction: column; - flex:1; + flex:10; background: white; } +.article { + display: flex; + flex-direction:column; + margin:1em; +} .hero__photo { display:flex; flex-direction:row; @@ -38,16 +44,25 @@ nav { display:none; } +header { + display:flex; + flex-direction:column; + margin-left: 1em; + margin-right: 1em; +} + main { display: flex; flex-direction: column; - margin: 10px; + margin: 1em; } -article { +.article { display: flex; flex-direction: column; - margin: 0 0 10px 0; + margin:0; + margin-bottom:1em; + background:gray; } .article__title { @@ -81,3 +96,10 @@ article { display:flex; min-width:50px; } + +input[type=search] { + border: 1px dotted #999; + border-radius: 0; + + -webkit-appearance: none; + } From cff2b57a1c49a0220e8f64f14a92ac150898ea24 Mon Sep 17 00:00:00 2001 From: Phil B Date: Fri, 14 Sep 2018 12:46:11 +0100 Subject: [PATCH 03/13] created functionality to exclude news source by clicking on link - needs some serious polish still --- index.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 2742f38..e8b91b7 100644 --- a/index.js +++ b/index.js @@ -46,7 +46,15 @@ function clearArticles() { mainNode.innerHTML = ""; } -function articleTemplate(article) { +function excludeDomain(articleDomain) { + if (!excludedDomainsArray.includes(articleDomain)) { + excludedDomainsArray.push(articleDomain); + } + console.log(excludedDomainsArray.toString()); + getArticles(1,excludedDomainsArray.toString()); +} + +function articleTemplate(article, articleDomain) { return `
${article.title}
@@ -54,7 +62,7 @@ function articleTemplate(article) {
` } @@ -66,20 +74,22 @@ function createArticles(body) { body.articles.forEach(article => { const articleNode = document.createElement('div'); articleNode.className = "article"; - articleNode.innerHTML = articleTemplate(article); + let articleDomain = article.url.replace(/^(?:https?:\/\/)?(?:www\.)?/i, "").split('/')[0]; + articleNode.innerHTML = articleTemplate(article,articleDomain); const parentNode = document.querySelector('main'); parentNode.appendChild(articleNode); mouseOverArticle(articleNode) - clickArticle(articleNode, article.url); + //clickArticle(articleNode, article.url); }); }; // api request to news api. Returns json and calls createArticles function -function getArticles(page) { +function getArticles(page, excludedDomainsStr='') { var url = 'https://newsapi.org/v2/everything?' + 'q=' + search + '&page=' + page + - '&apiKey=280f7af9f5c448c4a3598861960c947a&sortBy=publishedAt'; + '&apiKey=280f7af9f5c448c4a3598861960c947a&sortBy=publishedAt' + + '+&excludeDomains=' + excludedDomainsStr; var req = new Request(url); fetch(req) .then(function (response) { @@ -94,14 +104,13 @@ function getArticles(page) { function addPageLink() { const pageLinkNode = document.createElement('li'); const parentNode = document.querySelector('.pagination__ul'); - console.log(parentNode); pageLinkNode.innerHTML = page; pageLinkNode.className = "pagination__page"; parentNode.appendChild(pageLinkNode); pageLinkNode.addEventListener("click", event => {getArticles(pageLinkNode.innerHTML)}); } - +const excludedDomainsArray = []; let search = "uk"; let page = 1; getArticles(); From 6344a23a230d808ca18a013886b9f3890681b519 Mon Sep 17 00:00:00 2001 From: Phil B Date: Fri, 14 Sep 2018 13:18:47 +0100 Subject: [PATCH 04/13] can now add and remove domains - still no polish. --- index.html | 3 +++ index.js | 22 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 6303db4..dbf825d 100644 --- a/index.html +++ b/index.html @@ -30,6 +30,9 @@ +
    + +
diff --git a/index.js b/index.js index e8b91b7..d1826d0 100644 --- a/index.js +++ b/index.js @@ -54,6 +54,24 @@ function excludeDomain(articleDomain) { getArticles(1,excludedDomainsArray.toString()); } +function createExcluded() { + console.log(excludedDomainsArray.length); + document.querySelector('.excludedDomains').innerHTML = ""; + if (excludedDomainsArray.length>0) { + console.log(61); + excludedDomainsArray.forEach(domain => { + const parentNode = document.querySelector('.excludedDomains'); + const childNode = document.createElement('li'); + childNode.innerHTML = domain; + parentNode.appendChild(childNode); + childNode.addEventListener("click", event => { + excludedDomainsArray.splice(excludedDomainsArray.indexOf(domain),1); + getArticles(); + }) + }) + } +} + function articleTemplate(article, articleDomain) { return `
${article.title}
@@ -96,7 +114,9 @@ function getArticles(page, excludedDomainsStr='') { return response.json(); }) .then(function (body) { - createArticles(body); + createArticles(body) + createExcluded();; + console.log("boom"); }) } From efdbf7d406fe1ccbafea973457c1cebaf55489a9 Mon Sep 17 00:00:00 2001 From: Phil B Date: Fri, 14 Sep 2018 17:07:17 +0100 Subject: [PATCH 05/13] slightly more styling --- index.html | 1 + index.js | 35 ++++++++++--- style.css | 144 +++++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 160 insertions(+), 20 deletions(-) diff --git a/index.html b/index.html index dbf825d..6a736d1 100644 --- a/index.html +++ b/index.html @@ -30,6 +30,7 @@ + Publishers you have excluded from search. Click to re-apply.
diff --git a/index.js b/index.js index d1826d0..e3feedd 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,5 @@ +let itemId = 1; + // adds a listener to the search submit button function formListener () { const formElement = document.querySelector("form"); @@ -26,17 +28,18 @@ function nextListener () { // adds listeners that change the colour of the article the mouse is over function mouseOverArticle(articleNode) { articleNode.addEventListener("mouseover", event => { - articleNode.style.backgroundColor = "red"; + articleNode.style.backgroundColor = "#ffc754"; }) articleNode.addEventListener("mouseout", event => { - articleNode.style.backgroundColor = "gray"; + articleNode.style.backgroundColor = "white"; }) } // add a listener to article creating 'click' event that takes user to URL function clickArticle(articleNode, url) { articleNode.addEventListener("click", event => { - window.location = url; + + window.location = url; }) } @@ -47,6 +50,7 @@ function clearArticles() { } function excludeDomain(articleDomain) { + event.stopPropagation(); if (!excludedDomainsArray.includes(articleDomain)) { excludedDomainsArray.push(articleDomain); } @@ -54,6 +58,7 @@ function excludeDomain(articleDomain) { getArticles(1,excludedDomainsArray.toString()); } +// creates red buttons for excluded domains / publishers at top of page. function createExcluded() { console.log(excludedDomainsArray.length); document.querySelector('.excludedDomains').innerHTML = ""; @@ -62,6 +67,7 @@ function createExcluded() { excludedDomainsArray.forEach(domain => { const parentNode = document.querySelector('.excludedDomains'); const childNode = document.createElement('li'); + childNode.className = "excludedDomains__li"; childNode.innerHTML = domain; parentNode.appendChild(childNode); childNode.addEventListener("click", event => { @@ -80,7 +86,7 @@ function articleTemplate(article, articleDomain) {
` } @@ -89,15 +95,32 @@ function articleTemplate(article, articleDomain) { // takes request body and turns it into html to be appended into 'main' function createArticles(body) { clearArticles(); + itemId = 0; body.articles.forEach(article => { + console.log(article.content); + itemId ++ const articleNode = document.createElement('div'); articleNode.className = "article"; let articleDomain = article.url.replace(/^(?:https?:\/\/)?(?:www\.)?/i, "").split('/')[0]; - articleNode.innerHTML = articleTemplate(article,articleDomain); + articleNode.innerHTML = articleTemplate(article,articleDomain, itemId); const parentNode = document.querySelector('main'); parentNode.appendChild(articleNode); + + const excludeDomainSpan = document.createElement('span'); + excludeDomainSpan.textContent = "Exclude Publisher"; + excludeDomainSpan.className = "excludeButton"; + console.log(itemId); + const excludeDomainSpanParent = document.querySelector(`#item${itemId}`); + excludeDomainSpanParent.appendChild(excludeDomainSpan); + excludeDomainSpan.addEventListener("click", event => { + excludeDomain(articleDomain); + }) + + // create span element + // insert span element into element with id article.url + // set click click listener on span mouseOverArticle(articleNode) - //clickArticle(articleNode, article.url); + clickArticle(articleNode, article.url); }); }; diff --git a/style.css b/style.css index 18d5d88..4d93d45 100644 --- a/style.css +++ b/style.css @@ -10,29 +10,21 @@ body { display: flex; flex-direction: column; min-height: 100vh; - background: gray; + background:#eeeeee; } .app { display: flex; flex-direction: column; flex:10; - background: white; + background: #eeeeee; } -.article { - display: flex; - flex-direction:column; - margin:1em; -} .hero__photo { display:flex; flex-direction:row; - min-height:200px; - background-image: - url("images/header-ventoux.jpg"); - object-fit: cover; - + min-height:60px; + background:#33b5e5; } img { @@ -51,6 +43,17 @@ header { margin-right: 1em; } +.excludedDomains { + display:flex; + padding:0; + margin:1em; + align-content:flex-start; +} + +.excludedDomains__li { + display:flex; +} + main { display: flex; flex-direction: column; @@ -61,12 +64,13 @@ main { display: flex; flex-direction: column; margin:0; + padding:10px; margin-bottom:1em; - background:gray; + background:white; } .article__title { - margin-bottom: 5px; + margin-bottom:5px; font-weight:400; } @@ -78,6 +82,7 @@ main { display:flex; flex-direction: row; justify-content: space-between; + margin-top:10px; border-bottom:2px; font-size:0.8em; } @@ -103,3 +108,114 @@ input[type=search] { -webkit-appearance: none; } + + .excludedDomains { + display:flex; + flex-direction: row; + flex-wrap: wrap; + margin-left:1em; + } + .excludedDomains__li { + -moz-box-shadow:inset 0px 39px 0px -24px #ff4444; + -webkit-box-shadow:inset 0px 39px 0px -24px #ff4444; + box-shadow:inset 0px 39px 0px -24px #ff4444; + background-color:#ff4444; + -moz-border-radius:4px; + -webkit-border-radius:4px; + border-radius:4px; + border:1px solid #ffffff; + display:inline-block; + cursor:pointer; + color:#ffffff; + font-family:Arial; + font-size:10px; + padding:6px 15px; + margin: 0 5px 5px 0; + text-decoration:none; + text-shadow:0px 1px 0px #b23e35; +} +.excludedDomains__li:hover { + background-color:#72b352; + -moz-box-shadow:inset 0px 39px 0px -24px #72b352; + -webkit-box-shadow:inset 0px 39px 0px -24px #72b352; +} +.excludedDomains__li:active { + position:relative; + top:1px; +} + +.excludeButton { + -moz-box-shadow:inset 0px 39px 0px -24px #ff4444; + -webkit-box-shadow:inset 0px 39px 0px -24px #ff4444; + box-shadow:inset 0px 39px 0px -24px #ff4444; + background-color:#ff4444; + -moz-border-radius:4px; + -webkit-border-radius:4px; + border-radius:4px; + border:1px solid #ffffff; + display:inline-block; + cursor:pointer; + color:#ffffff; + font-family:Arial; + font-size:10px; + padding:6px 15px; + margin-top:5px; + text-decoration:none; + text-shadow:0px 1px 0px #b23e35; +} +.excludeButton:hover { + background-color:black; + -moz-box-shadow:inset 0px 39px 0px -24px black; + -webkit-box-shadow:inset 0px 39px 0px -24px black; +} +.excludeButton:active { + position:relative; + top:1px; +} + +p { + margin:0; +} + +.search { + width: 100%; + position: relative + } + + .searchTerm { + float: left; + width: 100%; + border: 3px solid #00B4CC; + padding: 5px; + height: 20px; + border-radius: 5px; + outline: none; + color: #9DBFAF; + } + + .searchTerm:focus{ + color: #00B4CC; + } + + .searchButton { + position: absolute; + right: -50px; + width: 40px; + height: 36px; + border: 1px solid #00B4CC; + background: #00B4CC; + text-align: center; + color: #fff; + border-radius: 5px; + cursor: pointer; + font-size: 20px; + } + + /*Resize the wrap to see the search bar change!*/ +.wrap { + width: 30%; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + } \ No newline at end of file From 6087073a6925dbe9b6634304d656ee4fe67a1d44 Mon Sep 17 00:00:00 2001 From: Phil B Date: Sat, 15 Sep 2018 18:07:23 +0100 Subject: [PATCH 06/13] added some responsiveness and images for tablet and above --- index.html | 27 +++++++----- index.js | 65 ++++++++++++++++++++-------- style.css | 125 +++++++++++++++++++++++++++++++++-------------------- 3 files changed, 139 insertions(+), 78 deletions(-) diff --git a/index.html b/index.html index 6a736d1..0ca04b3 100644 --- a/index.html +++ b/index.html @@ -15,38 +15,41 @@
- -
All the news ... All the time!
+ +
+
-
- Publishers you have excluded from search. Click to re-apply. -
    -
+
+ Excluded publishers
Click to re-apply.
+
    + +
+
+ +
+ + + +
-
diff --git a/index.js b/index.js index e3feedd..1e5fb7c 100644 --- a/index.js +++ b/index.js @@ -9,7 +9,8 @@ function formListener () { clearArticles(); search = formInput.value; page=1; - getArticles(1) + getArticles(1,excludedDomainsArray); + console.log(excludedDomainsArray); }); } @@ -18,8 +19,6 @@ function nextListener () { const nextButton = document.querySelector("#next"); nextButton.addEventListener('click', event => { page ++; - console.log(`getting page: ${page}`) - getArticles(page); addPageLink(); }); @@ -45,7 +44,13 @@ function clickArticle(articleNode, url) { // clears existing articles from page in preparation for a new search or new page function clearArticles() { - const mainNode = document.querySelector('main'); + const mainNode = document.querySelector('.articles'); + mainNode.innerHTML = ""; +} + +// clears pagination +function clearPagination() { + const mainNode = document.querySelector('.pagination__ul'); mainNode.innerHTML = ""; } @@ -63,6 +68,7 @@ function createExcluded() { console.log(excludedDomainsArray.length); document.querySelector('.excludedDomains').innerHTML = ""; if (excludedDomainsArray.length>0) { + document.querySelector('.excludedDomains__message').style.display = 'flex'; console.log(61); excludedDomainsArray.forEach(domain => { const parentNode = document.querySelector('.excludedDomains'); @@ -75,6 +81,12 @@ function createExcluded() { getArticles(); }) }) + document.querySelector('.excludedDomainsDiv').style.display = 'flex'; + } else { + document.querySelector('.excludedDomainsDiv').style.display = 'none'; + } + if (excludedDomainsArray.length > 4) { + document.querySelector('.excludedDomainsDiv').style.flexDirection = 'column'; } } @@ -97,19 +109,17 @@ function createArticles(body) { clearArticles(); itemId = 0; body.articles.forEach(article => { - console.log(article.content); itemId ++ const articleNode = document.createElement('div'); articleNode.className = "article"; let articleDomain = article.url.replace(/^(?:https?:\/\/)?(?:www\.)?/i, "").split('/')[0]; articleNode.innerHTML = articleTemplate(article,articleDomain, itemId); - const parentNode = document.querySelector('main'); + const parentNode = document.querySelector('.articles'); parentNode.appendChild(articleNode); const excludeDomainSpan = document.createElement('span'); excludeDomainSpan.textContent = "Exclude Publisher"; excludeDomainSpan.className = "excludeButton"; - console.log(itemId); const excludeDomainSpanParent = document.querySelector(`#item${itemId}`); excludeDomainSpanParent.appendChild(excludeDomainSpan); excludeDomainSpan.addEventListener("click", event => { @@ -121,11 +131,12 @@ function createArticles(body) { // set click click listener on span mouseOverArticle(articleNode) clickArticle(articleNode, article.url); + document.body.scrollTop = document.documentElement.scrollTop = 0; }); }; // api request to news api. Returns json and calls createArticles function -function getArticles(page, excludedDomainsStr='') { +function getArticles(page=1, excludedDomainsStr='', i) { var url = 'https://newsapi.org/v2/everything?' + 'q=' + search + '&page=' + page + @@ -139,25 +150,41 @@ function getArticles(page, excludedDomainsStr='') { .then(function (body) { createArticles(body) createExcluded();; - console.log("boom"); + addPagination(body.totalResults); }) } // adds a link to a new page when the next button is clicked -function addPageLink() { - const pageLinkNode = document.createElement('li'); - const parentNode = document.querySelector('.pagination__ul'); - pageLinkNode.innerHTML = page; - pageLinkNode.className = "pagination__page"; - parentNode.appendChild(pageLinkNode); - pageLinkNode.addEventListener("click", event => {getArticles(pageLinkNode.innerHTML)}); +// function addPageLink() { +// const pageLinkNode = document.createElement('li'); +// const parentNode = document.querySelector('.pagination__ul'); +// pageLinkNode.innerHTML = page; +// pageLinkNode.className = "pagination__page"; +// parentNode.appendChild(pageLinkNode); +// pageLinkNode.addEventListener("click", event => {getArticles(pageLinkNode.innerHTML)}); +// } + +// adds 5 page links to bottom of page +function addPagination(totalResults) { + clearPagination(); + let numberOfPages = Math.floor(totalResults/20)+1; + if (numberOfPages > 5) {numberOfPages = 5}; + for (i=1;i<=numberOfPages;i++) { + const pageLinkNode = document.createElement('li'); + const parentNode = document.querySelector('.pagination__ul'); + pageLinkNode.innerHTML = i; + pageLinkNode.className = "pagination__page"; + parentNode.appendChild(pageLinkNode); + console.log("i: " + i) + // console.log("page aP :" + page); + pageLinkNode.addEventListener("click", event => {getArticles(pageLinkNode.innerHTML)}); + } } const excludedDomainsArray = []; let search = "uk"; -let page = 1; getArticles(); formListener(); -nextListener(); -addPageLink(); +// nextListener(); +// addPageLink(); diff --git a/style.css b/style.css index 4d93d45..abf1eb6 100644 --- a/style.css +++ b/style.css @@ -6,7 +6,7 @@ body { box-sizing: border-box; margin: 0; - font-family: "Open Sans", sans-serif; + font-family: Helvetica Neue,Helvetica,Arial,sans-serif; display: flex; flex-direction: column; min-height: 100vh; @@ -20,7 +20,7 @@ body { background: #eeeeee; } -.hero__photo { +.top { display:flex; flex-direction:row; min-height:60px; @@ -41,6 +41,13 @@ header { flex-direction:column; margin-left: 1em; margin-right: 1em; + margin-bottom: 10px; +} + +.excludedDomainsDiv { + display: flex; + flex-direction:column; + } .excludedDomains { @@ -113,13 +120,13 @@ input[type=search] { display:flex; flex-direction: row; flex-wrap: wrap; - margin-left:1em; + margin:0; } .excludedDomains__li { - -moz-box-shadow:inset 0px 39px 0px -24px #ff4444; - -webkit-box-shadow:inset 0px 39px 0px -24px #ff4444; - box-shadow:inset 0px 39px 0px -24px #ff4444; - background-color:#ff4444; + -moz-box-shadow:inset 0px 39px 0px -24px #fd7627; + -webkit-box-shadow:inset 0px 39px 0px -24px #fd7627; + box-shadow:inset 0px 39px 0px -24px #fd7627; + background-color:#fd7627; -moz-border-radius:4px; -webkit-border-radius:4px; border-radius:4px; @@ -177,45 +184,69 @@ p { margin:0; } -.search { - width: 100%; - position: relative - } - - .searchTerm { - float: left; - width: 100%; - border: 3px solid #00B4CC; - padding: 5px; - height: 20px; - border-radius: 5px; - outline: none; - color: #9DBFAF; - } - - .searchTerm:focus{ - color: #00B4CC; - } - - .searchButton { - position: absolute; - right: -50px; - width: 40px; - height: 36px; - border: 1px solid #00B4CC; - background: #00B4CC; - text-align: center; - color: #fff; - border-radius: 5px; - cursor: pointer; - font-size: 20px; +.excludedDomainsDiv { + display:flex; + flex-direction: row; +} + + .excludedDomains__message { + display:none; + margin-bottom:10px; + font-size:.7em; + min-width: 150px; + + } - /*Resize the wrap to see the search bar change!*/ -.wrap { - width: 30%; - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - } \ No newline at end of file + .pagination__page { + display: inline-block; + padding: 0px 9px; + margin-right: 4px; + border-radius: 3px; + border: solid 1px #c0c0c0; + background: #e9e9e9; + box-shadow: inset 0px 1px 0px rgba(255,255,255, .8), 0px 1px 3px rgba(0,0,0, .1); + font-size: .875em; + font-weight: bold; + text-decoration: none; + color: #717171; + text-shadow: 0px 1px 0px rgba(255,255,255, 1); +} + +.pagination__page:hover, .page.gradient:hover { + background: #fefefe; + background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FEFEFE), to(#f0f0f0)); + background: -moz-linear-gradient(0% 0% 270deg,#FEFEFE, #f0f0f0); +} + +.pagination__page.active { + border: none; + background: #616161; + box-shadow: inset 0px 0px 8px rgba(0,0,0, .5), 0px 1px 0px rgba(255,255,255, .8); + color: #f0f0f0; + text-shadow: 0px 0px 3px rgba(0,0,0, .5); +} + +@media (min-width: 768px) { + main { + flex-direction: row-reverse; + } + + .excludedDomainsDiv { + flex:3; + flex-direction:column; + padding:10px; + background: white; + margin-left:10px; + } + + .articles { + flex:9; + } + + .article__image { + display: block; + margin-top:10px; + } + +} \ No newline at end of file From 20c4a3638987c3524e7fe746442bed6eb1b9ff81 Mon Sep 17 00:00:00 2001 From: Phil B Date: Sat, 15 Sep 2018 18:21:43 +0100 Subject: [PATCH 07/13] Unstyled but kind of working news app --- .DS_Store | Bin 0 -> 8196 bytes images/news-etc.png | Bin 0 -> 20210 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 .DS_Store create mode 100644 images/news-etc.png diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..afbc1efc855b4027637eae18d48a56fb2a998273 GIT binary patch literal 8196 zcmeHMPiz!b82`Su(0PT@p%%IWEUYv@!L}4A6y)EwTaW@3!nU-9Vwv3;+R^Du*_qu1 zYE3obNicFkyl6ZaAn}9;FQ^BNVj>=D1QQQ>@n|%fcv8Rj-fYuusqv%|<|XsK_r5># zz4yJ}%(vex0APF8*aQ#(0EI42)dkc&pm90BX0?)lQ$ZBT9y)C|owD5&&DB}jAtQ`H z7=bVXVFbbmgc0~ZM1XQOZ^|5bUrNJ1j6fKHM=}EZ{Sc#z(|AB9Bo(g?>O=`Zw2auI z(OCTSCmQ1nqVa%ENJ<=PC{2krSNwWGsMH7beNoNFf(lx=Gsf)FLr<=-qqrrE9 z&r_qe<@wFc-(X2;*}VDXic+CeR92iy4!ilJulrfAUC*54v!l8{oC?O>u4_+?_0)08 z%nzzH3D@y;%P}*;*fLB~8R)ef!_Bw5S;z3ieUeh3C`@64YGiDzWovUoY;)_T@rKw~ zYb%Xgwrm?8XG-mwO}jf!kDR|S_Wbw@Z-^}e2JaiFlJlwl8jWTI#P)Itxyh0%g-zZo zY?84B+JVl4hXz$O>zT()TlcM;*`fQUH>g&5wA;?K>m1FPIoero+O@MI4oMcLbvvCU zWwXt;lhy^(>+{WXJ|CU%+>D$IXmKl(Cx&mqb^ueWH2m zlY0`Am5Zv>#np_Rpr|;$b;dF?J$cLUhx>IeZ90bK4E5$L&q~>5x1*1ki?M;R$)&ZC zN^P08q97_ZQPeu6FPpN?W-b4`@Ue20#s&;pd6#Q&FNXTQ!i1!5m8PBKl0?R&-cXcD zbx~C%tJgL#Rad$_+KJ>evW-mjSod>uq=KVuW-W?pupV1anYLuLvK@+gi1p^=b|tf# z?N(S{+8r68O?txZ-ngbc!`&X%J^#q4>ClosBj1&^k)<89q<$`IGYq~Ur7m7CPg=yF zF5W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ySGtxG^ApLbrrpa_=x8J0HF+YoK@M#flC|n z)-om@LHtuOn(szCBXISf#|m;=zItujgc5hvSO2W(kICpb?NLtm^u=I})`(J@@w^8s zwV`p+S!a{bv9OLgx*lbkCKOeMKagLlN3U0~=0wnrY8h8g2@1aF7~b&SW$e9#w Date: Sat, 15 Sep 2018 19:21:46 +0100 Subject: [PATCH 08/13] fixed some alignment issues --- index.html | 4 +--- style.css | 9 ++++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index 0ca04b3..232a6a7 100644 --- a/index.html +++ b/index.html @@ -44,15 +44,13 @@
-
- + diff --git a/style.css b/style.css index abf1eb6..fb08c5d 100644 --- a/style.css +++ b/style.css @@ -30,6 +30,7 @@ body { img { width:100%; height:auto; + max-width:300px; } nav { @@ -64,9 +65,10 @@ header { main { display: flex; flex-direction: column; - margin: 1em; + margin: 1em 1em 0 1em; } + .article { display: flex; flex-direction: column; @@ -102,6 +104,7 @@ main { display:flex; flex-direction:row; flex:1; + margin:0 0 1em 0; } .pagination__page { @@ -235,9 +238,9 @@ p { .excludedDomainsDiv { flex:3; flex-direction:column; - padding:10px; + padding:10px 10px 0 10px; background: white; - margin-left:10px; + margin:0 0 1em 10px; } .articles { From 9e6e5d99b9cded4d5411353e8b17b7fca3f4866a Mon Sep 17 00:00:00 2001 From: Phil B Date: Sat, 15 Sep 2018 22:34:38 +0100 Subject: [PATCH 09/13] added top publishers but need to tidy in the morning --- index.html | 3 +++ index.js | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- style.css | 42 +++++++++++++++++++++++++++++++++++++----- 3 files changed, 89 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index 232a6a7..61969cf 100644 --- a/index.html +++ b/index.html @@ -34,6 +34,9 @@
+
+ +
diff --git a/index.js b/index.js index 1e5fb7c..23f87a0 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ let itemId = 1; + // adds a listener to the search submit button function formListener () { const formElement = document.querySelector("form"); @@ -48,6 +49,12 @@ function clearArticles() { mainNode.innerHTML = ""; } +// clears publishers +function clearPublishers() { + const mainNode = document.querySelector('.publisher__list'); + mainNode.innerHTML = ""; +} + // clears pagination function clearPagination() { const mainNode = document.querySelector('.pagination__ul'); @@ -136,12 +143,14 @@ function createArticles(body) { }; // api request to news api. Returns json and calls createArticles function -function getArticles(page=1, excludedDomainsStr='', i) { +function getArticles(page=1, excludedDomainsStr='', filterDomains="") { + console.log(filterDomains); var url = 'https://newsapi.org/v2/everything?' + 'q=' + search + '&page=' + page + '&apiKey=280f7af9f5c448c4a3598861960c947a&sortBy=publishedAt' + - '+&excludeDomains=' + excludedDomainsStr; + '+&excludeDomains=' + excludedDomainsStr + '&domains=' + filterDomains; + console.log(url); var req = new Request(url); fetch(req) .then(function (response) { @@ -150,7 +159,9 @@ function getArticles(page=1, excludedDomainsStr='', i) { .then(function (body) { createArticles(body) createExcluded();; + publisherCount(body.articles); addPagination(body.totalResults); + }) } @@ -181,6 +192,39 @@ function addPagination(totalResults) { } } +function publisherCount(articles) { + clearPublishers(); + const publishersNames = []; + const publishersObjects = {}; + + console.log(articles.length); + articles.forEach(article => { + if (!publishersNames.includes(article.source.name)) { + let articleDomain = article.url.replace(/^(?:https?:\/\/)?(?:www\.)?/i, "").split('/')[0]; + publishersNames.push(article.source.name) + publishersObjects[article.source.name]= {name:article.source.name,domain:articleDomain,count:1} + } else { + publishersObjects[article.source.name].count++; + } + }) + + publishersNames.forEach(publisher => { + const parentNode = document.querySelector('.publisher__list'); + const childNode = document.createElement('div'); + childNode.textContent = `${publisher} (${publishersObjects[publisher].count})`; + parentNode.appendChild(childNode); + childNode.addEventListener("click", event => {getArticles(1,"",publishersObjects[publisher].domain)}) + console.log("208" + publishersObjects[publisher].name); + + }) + + + // console.log(publishersNames); + // console.log(publishersObjects); + // console.log(555); +} + +const publisherObject = []; const excludedDomainsArray = []; let search = "uk"; getArticles(); @@ -188,3 +232,6 @@ formListener(); // nextListener(); // addPageLink(); + + + diff --git a/style.css b/style.css index fb08c5d..034fd8d 100644 --- a/style.css +++ b/style.css @@ -40,8 +40,8 @@ nav { header { display:flex; flex-direction:column; - margin-left: 1em; - margin-right: 1em; + margin-left: 10px; + margin-right: 10px; margin-bottom: 10px; } @@ -54,7 +54,7 @@ header { .excludedDomains { display:flex; padding:0; - margin:1em; + margin:10px; align-content:flex-start; } @@ -65,16 +65,23 @@ header { main { display: flex; flex-direction: column; - margin: 1em 1em 0 1em; + margin: 10px 10px 0 10px; + padding: 0; } +.articles { + display:flex; + flex:9; + flex-direction:column; + margin:0; +} .article { display: flex; flex-direction: column; margin:0; padding:10px; - margin-bottom:1em; + margin-bottom:10px; background:white; } @@ -244,7 +251,32 @@ p { } .articles { + display:flex; flex:9; + flex-direction:column; + } + + .article__image { + display: block; + margin-top:10px; + } + +} + +@media (min-width: 960px) { + + + .articles { + display:flex; + flex:9; + flex-direction:row; + flex-wrap:wrap; + justify-content: space-around; + } + + .article { + width:49%; + margin: 0 0 10px 0; } .article__image { From 6914f444074f4d4ded2a35cb7eb942d49e212d8e Mon Sep 17 00:00:00 2001 From: Phil B Date: Sun, 16 Sep 2018 14:44:55 +0100 Subject: [PATCH 10/13] tidied up sidebar and did some minor refactoring of code --- index.html | 18 +++-- index.js | 228 ++++++++++++++++++++++++----------------------------- style.css | 22 +++++- 3 files changed, 132 insertions(+), 136 deletions(-) diff --git a/index.html b/index.html index 61969cf..de3b3de 100644 --- a/index.html +++ b/index.html @@ -29,14 +29,18 @@
-
- Excluded publishers
Click to re-apply.
-
    - -
-
- +
+
+ Excluded publishers
Click to re-apply.
+
    + +
+
+
+
+
+
diff --git a/index.js b/index.js index 23f87a0..7a99c53 100644 --- a/index.js +++ b/index.js @@ -2,81 +2,100 @@ let itemId = 1; // adds a listener to the search submit button -function formListener () { +const formListener = () => { const formElement = document.querySelector("form"); const formInput = document.querySelector("#form-search"); formElement.addEventListener('submit', event => { event.preventDefault(); - clearArticles(); search = formInput.value; page=1; getArticles(1,excludedDomainsArray); - console.log(excludedDomainsArray); }); } -// adds a listener to the next button -function nextListener () { - const nextButton = document.querySelector("#next"); - nextButton.addEventListener('click', event => { - page ++; - getArticles(page); - addPageLink(); - }); +// api request to news api. Returns json and calls createArticles function +const getArticles = (page=1, excludedDomainsStr='', filterDomains="") => { + var url = 'https://newsapi.org/v2/everything?' + + 'q=' + search + + '&page=' + page + + '&apiKey=280f7af9f5c448c4a3598861960c947a&sortBy=publishedAt' + + '+&excludeDomains=' + excludedDomainsStr + '&domains=' + filterDomains; + var req = new Request(url); + fetch(req) + .then(function (response) { + return response.json(); + }) + .then(function (body) { + createArticles(body) + createExcluded();; + publisherCount(body.articles); + addPagination(body.totalResults); + + }) } -// adds listeners that change the colour of the article the mouse is over -function mouseOverArticle(articleNode) { - articleNode.addEventListener("mouseover", event => { - articleNode.style.backgroundColor = "#ffc754"; - }) - articleNode.addEventListener("mouseout", event => { - articleNode.style.backgroundColor = "white"; - }) + +// takes request body and turns it into html to be appended into '.articles' +const createArticles = (body) => { + clearDiv('.articles'); + itemId = 0; + body.articles.forEach(article => { + itemId ++ + const articleNode = document.createElement('div'); + articleNode.className = "article"; + let articleDomain = article.url.replace(/^(?:https?:\/\/)?(?:www\.)?/i, "").split('/')[0]; + articleNode.innerHTML = articleTemplate(article,articleDomain, itemId); + const parentNode = document.querySelector('.articles'); + parentNode.appendChild(articleNode); + + const excludeDomainSpan = document.createElement('span'); + excludeDomainSpan.textContent = "Exclude Publisher"; + excludeDomainSpan.className = "excludeButton"; + const excludeDomainSpanParent = document.querySelector(`#item${itemId}`); + excludeDomainSpanParent.appendChild(excludeDomainSpan); + excludeDomainSpan.addEventListener("click", event => { + excludeDomain(articleDomain); + }) + mouseOverArticle(articleNode) + clickArticle(articleNode, article.url); + document.body.scrollTop = document.documentElement.scrollTop = 0; + }); +}; + +const articleTemplate = (article, articleDomain) => { + return ` +
${article.title}
+
+
${article.description}
+
+
+ ` } // add a listener to article creating 'click' event that takes user to URL -function clickArticle(articleNode, url) { - articleNode.addEventListener("click", event => { - +const clickArticle = (articleNode, url) => { + articleNode.addEventListener("click", event => { window.location = url; }) } -// clears existing articles from page in preparation for a new search or new page -function clearArticles() { - const mainNode = document.querySelector('.articles'); - mainNode.innerHTML = ""; -} - -// clears publishers -function clearPublishers() { - const mainNode = document.querySelector('.publisher__list'); - mainNode.innerHTML = ""; -} - -// clears pagination -function clearPagination() { - const mainNode = document.querySelector('.pagination__ul'); - mainNode.innerHTML = ""; -} function excludeDomain(articleDomain) { event.stopPropagation(); if (!excludedDomainsArray.includes(articleDomain)) { excludedDomainsArray.push(articleDomain); } - console.log(excludedDomainsArray.toString()); getArticles(1,excludedDomainsArray.toString()); } // creates red buttons for excluded domains / publishers at top of page. function createExcluded() { - console.log(excludedDomainsArray.length); document.querySelector('.excludedDomains').innerHTML = ""; if (excludedDomainsArray.length>0) { document.querySelector('.excludedDomains__message').style.display = 'flex'; - console.log(61); excludedDomainsArray.forEach(domain => { const parentNode = document.querySelector('.excludedDomains'); const childNode = document.createElement('li'); @@ -97,87 +116,17 @@ function createExcluded() { } } -function articleTemplate(article, articleDomain) { - return ` -
${article.title}
-
-
${article.description}
-
-
- ` -} -// takes request body and turns it into html to be appended into 'main' -function createArticles(body) { - clearArticles(); - itemId = 0; - body.articles.forEach(article => { - itemId ++ - const articleNode = document.createElement('div'); - articleNode.className = "article"; - let articleDomain = article.url.replace(/^(?:https?:\/\/)?(?:www\.)?/i, "").split('/')[0]; - articleNode.innerHTML = articleTemplate(article,articleDomain, itemId); - const parentNode = document.querySelector('.articles'); - parentNode.appendChild(articleNode); - const excludeDomainSpan = document.createElement('span'); - excludeDomainSpan.textContent = "Exclude Publisher"; - excludeDomainSpan.className = "excludeButton"; - const excludeDomainSpanParent = document.querySelector(`#item${itemId}`); - excludeDomainSpanParent.appendChild(excludeDomainSpan); - excludeDomainSpan.addEventListener("click", event => { - excludeDomain(articleDomain); - }) - // create span element - // insert span element into element with id article.url - // set click click listener on span - mouseOverArticle(articleNode) - clickArticle(articleNode, article.url); - document.body.scrollTop = document.documentElement.scrollTop = 0; - }); -}; -// api request to news api. Returns json and calls createArticles function -function getArticles(page=1, excludedDomainsStr='', filterDomains="") { - console.log(filterDomains); - var url = 'https://newsapi.org/v2/everything?' + - 'q=' + search + - '&page=' + page + - '&apiKey=280f7af9f5c448c4a3598861960c947a&sortBy=publishedAt' + - '+&excludeDomains=' + excludedDomainsStr + '&domains=' + filterDomains; - console.log(url); - var req = new Request(url); - fetch(req) - .then(function (response) { - return response.json(); - }) - .then(function (body) { - createArticles(body) - createExcluded();; - publisherCount(body.articles); - addPagination(body.totalResults); - }) -} -// adds a link to a new page when the next button is clicked -// function addPageLink() { -// const pageLinkNode = document.createElement('li'); -// const parentNode = document.querySelector('.pagination__ul'); -// pageLinkNode.innerHTML = page; -// pageLinkNode.className = "pagination__page"; -// parentNode.appendChild(pageLinkNode); -// pageLinkNode.addEventListener("click", event => {getArticles(pageLinkNode.innerHTML)}); -// } // adds 5 page links to bottom of page function addPagination(totalResults) { - clearPagination(); + clearDiv('.pagination__ul'); let numberOfPages = Math.floor(totalResults/20)+1; if (numberOfPages > 5) {numberOfPages = 5}; for (i=1;i<=numberOfPages;i++) { @@ -186,18 +135,19 @@ function addPagination(totalResults) { pageLinkNode.innerHTML = i; pageLinkNode.className = "pagination__page"; parentNode.appendChild(pageLinkNode); - console.log("i: " + i) - // console.log("page aP :" + page); pageLinkNode.addEventListener("click", event => {getArticles(pageLinkNode.innerHTML)}); } } -function publisherCount(articles) { - clearPublishers(); - const publishersNames = []; +// counts the articles on the search query by publisher and sorts them. Publisher can be clicked to show search by term + publishers filter. +// can definitely be re-written. Seems like a pretty messy way of sortinging that I've used. + +const publisherCount = (articles) => { + clearDiv('.publisher__list'); + let publishersNames = []; const publishersObjects = {}; + const publishersCount = []; - console.log(articles.length); articles.forEach(article => { if (!publishersNames.includes(article.source.name)) { let articleDomain = article.url.replace(/^(?:https?:\/\/)?(?:www\.)?/i, "").split('/')[0]; @@ -208,29 +158,55 @@ function publisherCount(articles) { } }) + publishersNames.forEach(publisher => { + publishersCount.push([publishersObjects[publisher].name,publishersObjects[publisher].count]); + }) + + publishersCount.sort(function(b, a) { + return a[1] - b[1]; + }); + + publishersNames =[]; + + publishersCount.forEach(publisher => { + publishersNames.push(publisher[0]); + }) + publishersNames.forEach(publisher => { const parentNode = document.querySelector('.publisher__list'); const childNode = document.createElement('div'); childNode.textContent = `${publisher} (${publishersObjects[publisher].count})`; parentNode.appendChild(childNode); childNode.addEventListener("click", event => {getArticles(1,"",publishersObjects[publisher].domain)}) - console.log("208" + publishersObjects[publisher].name); - }) +} - // console.log(publishersNames); - // console.log(publishersObjects); - // console.log(555); +// adds listeners that change the colour of the article the mouse is over - move to css +const mouseOverArticle = (articleNode) => { + articleNode.addEventListener("mouseover", event => { + articleNode.style.backgroundColor = "#ffc754"; + }) + articleNode.addEventListener("mouseout", event => { + articleNode.style.backgroundColor = "white"; + }) } + +const clearDiv = (divClass) => { + const mainNode = document.querySelector(divClass); + mainNode.innerHTML = ""; + console.log(`div cleared: ${divClass}`); +}; + const publisherObject = []; const excludedDomainsArray = []; let search = "uk"; + + getArticles(); formListener(); -// nextListener(); -// addPageLink(); + diff --git a/style.css b/style.css index 034fd8d..853bd7c 100644 --- a/style.css +++ b/style.css @@ -108,14 +108,13 @@ main { } .pagination__ul { - display:flex; flex-direction:row; flex:1; margin:0 0 1em 0; + } .pagination__page { - display:flex; min-width:50px; } @@ -208,6 +207,10 @@ p { } + .publishers { + display:none; + } + .pagination__page { display: inline-block; padding: 0px 9px; @@ -238,18 +241,31 @@ p { } @media (min-width: 768px) { + .publishers { + display: flex; + flex-direction:column; + padding:10px 10px 0 10px; + background: white; + margin:0 0 1em 10px; + } + main { flex-direction: row-reverse; } .excludedDomainsDiv { - flex:3; flex-direction:column; padding:10px 10px 0 10px; background: white; margin:0 0 1em 10px; } + .sideOrTopBar { + display:flex; + flex-direction:column; + flex:3; + } + .articles { display:flex; flex:9; From e6e24e77aaabde465330c8b8290186dd5234308c Mon Sep 17 00:00:00 2001 From: Phil B Date: Sun, 16 Sep 2018 18:22:12 +0100 Subject: [PATCH 11/13] now pulling 100 stories and can flip between 5 pages using the array that brings in. Also decided it was about time to put a little formatting into the date. And also using the 100 results to populate a sorted list of top ten publishers for the query --- index.js | 39 ++++++++++++++++++++++++++++----------- style.css | 8 ++++---- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/index.js b/index.js index 7a99c53..156dc04 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,5 @@ let itemId = 1; +let hundredArticles = []; // adds a listener to the search submit button @@ -15,19 +16,21 @@ const formListener = () => { // api request to news api. Returns json and calls createArticles function const getArticles = (page=1, excludedDomainsStr='', filterDomains="") => { + console.log('Function : Fetching Articles (getArticles)'); var url = 'https://newsapi.org/v2/everything?' + 'q=' + search + '&page=' + page + - '&apiKey=280f7af9f5c448c4a3598861960c947a&sortBy=publishedAt' + - '+&excludeDomains=' + excludedDomainsStr + '&domains=' + filterDomains; + '&apiKey=280f7af9f5c448c4a3598861960c947a' + + '&excludeDomains=' + excludedDomainsStr + '&domains=' + filterDomains + '&pageSize=100&sortBy=publishedAt&language=en'; var req = new Request(url); fetch(req) .then(function (response) { return response.json(); }) .then(function (body) { - createArticles(body) - createExcluded();; + hundredArticles = body.articles; + createArticles(0); + createExcluded(); publisherCount(body.articles); addPagination(body.totalResults); @@ -36,10 +39,14 @@ const getArticles = (page=1, excludedDomainsStr='', filterDomains="") => { // takes request body and turns it into html to be appended into '.articles' -const createArticles = (body) => { +const createArticles = (startArticle) => { + console.log('Function : Creating Articles (createArticles)'); clearDiv('.articles'); + // console.log(hundredArticles); + + twentyArticles = hundredArticles.slice(startArticle,startArticle+20); itemId = 0; - body.articles.forEach(article => { + twentyArticles.forEach(article => { itemId ++ const articleNode = document.createElement('div'); articleNode.className = "article"; @@ -47,7 +54,6 @@ const createArticles = (body) => { articleNode.innerHTML = articleTemplate(article,articleDomain, itemId); const parentNode = document.querySelector('.articles'); parentNode.appendChild(articleNode); - const excludeDomainSpan = document.createElement('span'); excludeDomainSpan.textContent = "Exclude Publisher"; excludeDomainSpan.className = "excludeButton"; @@ -55,6 +61,7 @@ const createArticles = (body) => { excludeDomainSpanParent.appendChild(excludeDomainSpan); excludeDomainSpan.addEventListener("click", event => { excludeDomain(articleDomain); + console.log(articleDomain); }) mouseOverArticle(articleNode) clickArticle(articleNode, article.url); @@ -63,6 +70,15 @@ const createArticles = (body) => { }; const articleTemplate = (article, articleDomain) => { + if (!article.urlToImage) { + article.urlToImage="images/blank.gif"; + }; + if (!article.description) { + article.description=" "; + }; + + dateSlicedAndSplit = (article.publishedAt.slice(0,10).split('-')); + return `
${article.title}
@@ -71,7 +87,7 @@ const articleTemplate = (article, articleDomain) => {
` } @@ -135,7 +151,7 @@ function addPagination(totalResults) { pageLinkNode.innerHTML = i; pageLinkNode.className = "pagination__page"; parentNode.appendChild(pageLinkNode); - pageLinkNode.addEventListener("click", event => {getArticles(pageLinkNode.innerHTML)}); + pageLinkNode.addEventListener("click", event => {createArticles((pageLinkNode.innerHTML-1)*20)}); } } @@ -172,7 +188,9 @@ const publisherCount = (articles) => { publishersNames.push(publisher[0]); }) - publishersNames.forEach(publisher => { + let topTenPublishers = publishersNames.slice(0,10); + + topTenPublishers.forEach(publisher => { const parentNode = document.querySelector('.publisher__list'); const childNode = document.createElement('div'); childNode.textContent = `${publisher} (${publishersObjects[publisher].count})`; @@ -196,7 +214,6 @@ const mouseOverArticle = (articleNode) => { const clearDiv = (divClass) => { const mainNode = document.querySelector(divClass); mainNode.innerHTML = ""; - console.log(`div cleared: ${divClass}`); }; const publisherObject = []; diff --git a/style.css b/style.css index 853bd7c..d56ddae 100644 --- a/style.css +++ b/style.css @@ -244,9 +244,9 @@ p { .publishers { display: flex; flex-direction:column; - padding:10px 10px 0 10px; + padding:10px 10px 10px 10px; background: white; - margin:0 0 1em 10px; + margin:0 0 10px 10px; } main { @@ -263,12 +263,12 @@ p { .sideOrTopBar { display:flex; flex-direction:column; - flex:3; + flex:4; } .articles { display:flex; - flex:9; + flex:8; flex-direction:column; } From 8f3fd495ad99affe6ca2485157159677be1168b6 Mon Sep 17 00:00:00 2001 From: Phil B Date: Sun, 16 Sep 2018 18:42:42 +0100 Subject: [PATCH 12/13] just changed the html title tag --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index de3b3de..c29c169 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,7 @@ - Layout 2 + Phil's Newsreader. From dc25636e168d7d2815142bd988aa8fa8c1145cb6 Mon Sep 17 00:00:00 2001 From: Phil B Date: Mon, 17 Sep 2018 17:10:20 +0100 Subject: [PATCH 13/13] added missing images --- functionNames.js | 48 +++++++++++ images/.DS_Store | Bin 0 -> 6148 bytes images/blank.gif | Bin 0 -> 42 bytes new.js | 220 +++++++++++++++++++++++++++++++++++++++++++++++ old.js | 213 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 481 insertions(+) create mode 100644 functionNames.js create mode 100644 images/.DS_Store create mode 100644 images/blank.gif create mode 100644 new.js create mode 100644 old.js diff --git a/functionNames.js b/functionNames.js new file mode 100644 index 0000000..d7bed71 --- /dev/null +++ b/functionNames.js @@ -0,0 +1,48 @@ +// adds a listener to the search submit button +function formListener () { + +function articleTemplate(article, articleDomain) { + return + + // takes request body and turns it into html to be appended into 'main' +function createArticles(body) { + +// api request to news api. Returns json and calls createArticles function +function getArticles(page=1, excludedDomainsStr='', filterDomains="") { + +// add a listener to article creating 'click' event that takes user to URL +function clickArticle(articleNode, url) { + +// adds listeners that change the colour of the article the mouse is over +function mouseOverArticle(articleNode) { + + + +// clears existing articles from page in preparation for a new search or new page +function clearArticles() { + +// clears publishers +function clearPublishers() { + +// clears pagination +function clearPagination() { + +function excludeDomain(articleDomain) { + +// creates red buttons for excluded domains / publishers at top of page. +function createExcluded() { + + + +// adds 5 page links to bottom of page +function addPagination(totalResults) { + +function publisherCount(articles) { +clearPublishers(); + +global + +const publisherObject = []; +const excludedDomainsArray = []; +let search = "uk"; +let itemId = 1; diff --git a/images/.DS_Store b/images/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..1f5edb96861301a04104c267f50647f95060b40f GIT binary patch literal 6148 zcmeHKyG{c!5FA5_NTi6UC|%NkL``Ewp`hjmAjt`YA}$IEQ2KZHN|^B)(1oibgmxwG z?Crykk)vAG2s-CUCmZ!5evfZ*tl$T{tXm>6F{LnsfQi2wbvYD4E VW<&KNe<>&WMW7Jk${E-L1D^~zED8Vs literal 0 HcmV?d00001 diff --git a/images/blank.gif b/images/blank.gif new file mode 100644 index 0000000000000000000000000000000000000000..f191b280ce91e6cb8c387735c10ef9bc5da6c83b GIT binary patch literal 42 ocmZ?wbhEHbWMp7uXkY+=|Ns9h{$ybUF?B!$NQQxl(S^Yp0J!f4_W%F@ literal 0 HcmV?d00001 diff --git a/new.js b/new.js new file mode 100644 index 0000000..f37d4b0 --- /dev/null +++ b/new.js @@ -0,0 +1,220 @@ +let itemId = 1; +let hundredArticles = []; + + +// adds a listener to the search submit button +const formListener = () => { + const formElement = document.querySelector("form"); + const formInput = document.querySelector("#form-search"); + formElement.addEventListener('submit', event => { + event.preventDefault(); + search = formInput.value; + page=1; + getArticles(1,excludedDomainsArray); + }); +} + +// api request to news api. Returns json and calls createArticles function +const getArticles = (page=1, excludedDomainsStr='', filterDomains="") => { + console.log('Function : Fetching Articles (getArticles)'); + var url = 'https://newsapi.org/v2/everything?' + + 'q=' + search + + '&page=' + page + + '&apiKey=280f7af9f5c448c4a3598861960c947a' + + '&excludeDomains=' + excludedDomainsStr + '&domains=' + filterDomains + '&pageSize=100&sortBy=publishedAt'; + var req = new Request(url); + fetch(req) + .then(function (response) { + return response.json(); + }) + .then(function (body) { + hundredArticles = body.articles; + createArticles(0); + createExcluded(); + publisherCount(body.articles); + addPagination(body.totalResults); + + }) +} + + +// takes request body and turns it into html to be appended into '.articles' +const createArticles = (startArticle) => { + console.log('Function : Creating Articles (createArticles)'); + clearDiv('.articles'); + // console.log(hundredArticles); + + twentyArticles = hundredArticles.slice(startArticle,startArticle+20); + itemId = 0; + twentyArticles.forEach(article => { + itemId ++ + const articleNode = document.createElement('div'); + articleNode.className = "article"; + let articleDomain = article.url.replace(/^(?:https?:\/\/)?(?:www\.)?/i, "").split('/')[0]; + articleNode.innerHTML = articleTemplate(article,articleDomain, itemId); + const parentNode = document.querySelector('.articles'); + parentNode.appendChild(articleNode); + const excludeDomainSpan = document.createElement('span'); + excludeDomainSpan.textContent = "Exclude Publisher"; + excludeDomainSpan.className = "excludeButton"; + const excludeDomainSpanParent = document.querySelector(`#item${itemId}`); + excludeDomainSpanParent.appendChild(excludeDomainSpan); + excludeDomainSpan.addEventListener("click", event => { + excludeDomain(articleDomain); + console.log(articleDomain); + }) + mouseOverArticle(articleNode) + clickArticle(articleNode, article.url); + document.body.scrollTop = document.documentElement.scrollTop = 0; + }); +}; + +const articleTemplate = (article, articleDomain) => { + console.log(article.urlToImage); + return ` +
${article.title}
+
+
${article.description}
+
+
+ ` +} + +// add a listener to article creating 'click' event that takes user to URL +const clickArticle = (articleNode, url) => { + articleNode.addEventListener("click", event => { + window.location = url; + }) +} + + +function excludeDomain(articleDomain) { + event.stopPropagation(); + if (!excludedDomainsArray.includes(articleDomain)) { + excludedDomainsArray.push(articleDomain); + } + getArticles(1,excludedDomainsArray.toString()); +} + +// creates red buttons for excluded domains / publishers at top of page. +function createExcluded() { + document.querySelector('.excludedDomains').innerHTML = ""; + if (excludedDomainsArray.length>0) { + document.querySelector('.excludedDomains__message').style.display = 'flex'; + excludedDomainsArray.forEach(domain => { + const parentNode = document.querySelector('.excludedDomains'); + const childNode = document.createElement('li'); + childNode.className = "excludedDomains__li"; + childNode.innerHTML = domain; + parentNode.appendChild(childNode); + childNode.addEventListener("click", event => { + excludedDomainsArray.splice(excludedDomainsArray.indexOf(domain),1); + getArticles(); + }) + }) + document.querySelector('.excludedDomainsDiv').style.display = 'flex'; + } else { + document.querySelector('.excludedDomainsDiv').style.display = 'none'; + } + if (excludedDomainsArray.length > 4) { + document.querySelector('.excludedDomainsDiv').style.flexDirection = 'column'; + } +} + + + + + + + + + +// adds 5 page links to bottom of page +function addPagination(totalResults) { + clearDiv('.pagination__ul'); + let numberOfPages = Math.floor(totalResults/20)+1; + if (numberOfPages > 5) {numberOfPages = 5}; + for (i=1;i<=numberOfPages;i++) { + const pageLinkNode = document.createElement('li'); + const parentNode = document.querySelector('.pagination__ul'); + pageLinkNode.innerHTML = i; + pageLinkNode.className = "pagination__page"; + parentNode.appendChild(pageLinkNode); + pageLinkNode.addEventListener("click", event => {createArticles((pageLinkNode.innerHTML-1)*20)}); + } +} + +// counts the articles on the search query by publisher and sorts them. Publisher can be clicked to show search by term + publishers filter. +// can definitely be re-written. Seems like a pretty messy way of sortinging that I've used. + +const publisherCount = (articles) => { + clearDiv('.publisher__list'); + let publishersNames = []; + const publishersObjects = {}; + const publishersCount = []; + + articles.forEach(article => { + if (!publishersNames.includes(article.source.name)) { + let articleDomain = article.url.replace(/^(?:https?:\/\/)?(?:www\.)?/i, "").split('/')[0]; + publishersNames.push(article.source.name) + publishersObjects[article.source.name]= {name:article.source.name,domain:articleDomain,count:1} + } else { + publishersObjects[article.source.name].count++; + } + }) + + publishersNames.forEach(publisher => { + publishersCount.push([publishersObjects[publisher].name,publishersObjects[publisher].count]); + }) + + publishersCount.sort(function(b, a) { + return a[1] - b[1]; + }); + + publishersNames =[]; + + publishersCount.forEach(publisher => { + publishersNames.push(publisher[0]); + }) + + publishersNames.forEach(publisher => { + const parentNode = document.querySelector('.publisher__list'); + const childNode = document.createElement('div'); + childNode.textContent = `${publisher} (${publishersObjects[publisher].count})`; + parentNode.appendChild(childNode); + childNode.addEventListener("click", event => {getArticles(1,"",publishersObjects[publisher].domain)}) + }) +} + + +// adds listeners that change the colour of the article the mouse is over - move to css +const mouseOverArticle = (articleNode) => { + articleNode.addEventListener("mouseover", event => { + articleNode.style.backgroundColor = "#ffc754"; + }) + articleNode.addEventListener("mouseout", event => { + articleNode.style.backgroundColor = "white"; + }) +} + + +const clearDiv = (divClass) => { + const mainNode = document.querySelector(divClass); + mainNode.innerHTML = ""; +}; + +const publisherObject = []; +const excludedDomainsArray = []; +let search = "uk"; + + +getArticles(); +formListener(); + + + + + diff --git a/old.js b/old.js new file mode 100644 index 0000000..d98f2fb --- /dev/null +++ b/old.js @@ -0,0 +1,213 @@ +let itemId = 1; + + +// adds a listener to the search submit button +const formListener = () => { + const formElement = document.querySelector("form"); + const formInput = document.querySelector("#form-search"); + formElement.addEventListener('submit', event => { + event.preventDefault(); + search = formInput.value; + page=1; + getArticles(1,excludedDomainsArray); + }); +} + +// api request to news api. Returns json and calls createArticles function +const getArticles = (page=1, excludedDomainsStr='', filterDomains="") => { + var url = 'https://newsapi.org/v2/everything?' + + 'q=' + search + + '&page=' + page + + '&apiKey=280f7af9f5c448c4a3598861960c947a&sortBy=publishedAt' + + '+&excludeDomains=' + excludedDomainsStr + '&domains=' + filterDomains + '&pageSize=100&sortBy=publishedAt'; + var req = new Request(url); + fetch(req) + .then(function (response) { + return response.json(); + }) + .then(function (body) { + createArticles(body) + createExcluded();; + publisherCount(body.articles); + addPagination(body.totalResults); + + }) +} + + +// takes request body and turns it into html to be appended into '.articles' +const createArticles = (body) => { + clearDiv('.articles'); + twentyArticles = body.articles.slice(0,10); + itemId = 0; + twentyArticles.forEach(article => { + itemId ++ + const articleNode = document.createElement('div'); + articleNode.className = "article"; + let articleDomain = article.url.replace(/^(?:https?:\/\/)?(?:www\.)?/i, "").split('/')[0]; + articleNode.innerHTML = articleTemplate(article,articleDomain, itemId); + const parentNode = document.querySelector('.articles'); + parentNode.appendChild(articleNode); + const excludeDomainSpan = document.createElement('span'); + excludeDomainSpan.textContent = "Exclude Publisher"; + excludeDomainSpan.className = "excludeButton"; + const excludeDomainSpanParent = document.querySelector(`#item${itemId}`); + excludeDomainSpanParent.appendChild(excludeDomainSpan); + excludeDomainSpan.addEventListener("click", event => { + excludeDomain(articleDomain); + }) + mouseOverArticle(articleNode) + clickArticle(articleNode, article.url); + document.body.scrollTop = document.documentElement.scrollTop = 0; + }); +}; + +const articleTemplate = (article, articleDomain) => { + return ` +
${article.title}
+
+
${article.description}
+
+
+ ` +} + +// add a listener to article creating 'click' event that takes user to URL +const clickArticle = (articleNode, url) => { + articleNode.addEventListener("click", event => { + window.location = url; + }) +} + + +function excludeDomain(articleDomain) { + event.stopPropagation(); + if (!excludedDomainsArray.includes(articleDomain)) { + excludedDomainsArray.push(articleDomain); + } + getArticles(1,excludedDomainsArray.toString()); +} + +// creates red buttons for excluded domains / publishers at top of page. +function createExcluded() { + document.querySelector('.excludedDomains').innerHTML = ""; + if (excludedDomainsArray.length>0) { + document.querySelector('.excludedDomains__message').style.display = 'flex'; + excludedDomainsArray.forEach(domain => { + const parentNode = document.querySelector('.excludedDomains'); + const childNode = document.createElement('li'); + childNode.className = "excludedDomains__li"; + childNode.innerHTML = domain; + parentNode.appendChild(childNode); + childNode.addEventListener("click", event => { + excludedDomainsArray.splice(excludedDomainsArray.indexOf(domain),1); + getArticles(); + }) + }) + document.querySelector('.excludedDomainsDiv').style.display = 'flex'; + } else { + document.querySelector('.excludedDomainsDiv').style.display = 'none'; + } + if (excludedDomainsArray.length > 4) { + document.querySelector('.excludedDomainsDiv').style.flexDirection = 'column'; + } +} + + + + + + + + + +// adds 5 page links to bottom of page +function addPagination(totalResults) { + clearDiv('.pagination__ul'); + let numberOfPages = Math.floor(totalResults/20)+1; + if (numberOfPages > 5) {numberOfPages = 5}; + for (i=1;i<=numberOfPages;i++) { + const pageLinkNode = document.createElement('li'); + const parentNode = document.querySelector('.pagination__ul'); + pageLinkNode.innerHTML = i; + pageLinkNode.className = "pagination__page"; + parentNode.appendChild(pageLinkNode); + pageLinkNode.addEventListener("click", event => {getArticles(pageLinkNode.innerHTML)}); + } +} + +// counts the articles on the search query by publisher and sorts them. Publisher can be clicked to show search by term + publishers filter. +// can definitely be re-written. Seems like a pretty messy way of sortinging that I've used. + +const publisherCount = (articles) => { + clearDiv('.publisher__list'); + let publishersNames = []; + const publishersObjects = {}; + const publishersCount = []; + + articles.forEach(article => { + if (!publishersNames.includes(article.source.name)) { + let articleDomain = article.url.replace(/^(?:https?:\/\/)?(?:www\.)?/i, "").split('/')[0]; + publishersNames.push(article.source.name) + publishersObjects[article.source.name]= {name:article.source.name,domain:articleDomain,count:1} + } else { + publishersObjects[article.source.name].count++; + } + }) + + publishersNames.forEach(publisher => { + publishersCount.push([publishersObjects[publisher].name,publishersObjects[publisher].count]); + }) + + publishersCount.sort(function(b, a) { + return a[1] - b[1]; + }); + + publishersNames =[]; + + publishersCount.forEach(publisher => { + publishersNames.push(publisher[0]); + }) + + publishersNames.forEach(publisher => { + const parentNode = document.querySelector('.publisher__list'); + const childNode = document.createElement('div'); + childNode.textContent = `${publisher} (${publishersObjects[publisher].count})`; + parentNode.appendChild(childNode); + childNode.addEventListener("click", event => {getArticles(1,"",publishersObjects[publisher].domain)}) + }) +} + + +// adds listeners that change the colour of the article the mouse is over - move to css +const mouseOverArticle = (articleNode) => { + articleNode.addEventListener("mouseover", event => { + articleNode.style.backgroundColor = "#ffc754"; + }) + articleNode.addEventListener("mouseout", event => { + articleNode.style.backgroundColor = "white"; + }) +} + + +const clearDiv = (divClass) => { + const mainNode = document.querySelector(divClass); + mainNode.innerHTML = ""; + console.log(`div cleared: ${divClass}`); +}; + +const publisherObject = []; +const excludedDomainsArray = []; +let search = "uk"; + + +getArticles(); +formListener(); + + + + +