diff --git a/controllers/sites.js b/controllers/sites.js index 43d3c12..8649a9a 100644 --- a/controllers/sites.js +++ b/controllers/sites.js @@ -27,7 +27,7 @@ module.exports = { getAll: function(req, res){ Site.getAll(function(err, sites){ if(err) throw err; - res.render('index', { title: "Home", sites: sites }); + res.render('site-listing', { title: "All Sites", sites: sites }); }); }, UniqueSiteVisits: function(req, res){ @@ -35,7 +35,7 @@ module.exports = { if(err) throw err; Site.findAllById(uniqueSites, function(err, uniqueSiteVisits){ if(err) throw err; - res.render('index', { title: "UniqueSiteVisits", sites: uniqueSiteVisits }); + res.render('site-listing', { title: "UniqueSiteVisits", sites: uniqueSiteVisits }); }); }); } diff --git a/views/index.pug b/views/index.pug index b392890..c43d7d8 100644 --- a/views/index.pug +++ b/views/index.pug @@ -3,10 +3,16 @@ extends layout block content h1= title - h2= "Sites Visited: " + visits.length + "/" + totalSites + h2= "Sites Visited: " + a(href="/visits") #{visits.length} + | / + a(href="/sites") #{totalSites} + + - var sitesVisited = []; h2= "Visits" each visit in visits + - sitesVisited.push(visit.id); h3= visit.site //- Commmand list of all the states h5 @@ -15,16 +21,20 @@ block content | #{states[i]} if (i + 1 < states.length) | , - + h2= "Remaining" each site in sites - h3= site.site - //- Commmand list of all the states - h5 - - var states = site.states.split(',') - - for (var i = 0; i < states.length; i++) - | #{states[i]} - if (i + 1 < states.length) - | , + if !(sitesVisited.includes(site.id)) + h3= site.site + //- Commmand list of all the states + h5 + - var states = site.states.split(',') + - for (var i = 0; i < states.length; i++) + | #{states[i]} + if (i + 1 < states.length) + | , + else + h3= "Removed!" include footer.pug + diff --git a/views/site-listing.pug b/views/site-listing.pug new file mode 100644 index 0000000..f6534bc --- /dev/null +++ b/views/site-listing.pug @@ -0,0 +1,18 @@ +extends layout + +block content + h1= title + + h2= "Sites: " + sites.length + + each site in sites + h3= site.site + //- Commmand list of all the states + h5 + - var states = site.states.split(',') + - for (var i = 0; i < states.length; i++) + | #{states[i]} + if (i + 1 < states.length) + | , + + include footer.pug diff --git a/views/visits.pug b/views/visits.pug deleted file mode 100644 index e69de29..0000000