Permalink
Browse files

added comments on the rest of the shit

  • Loading branch information...
jordan-castelloe committed Jan 11, 2018
1 parent 2dab281 commit 290089bf167542186c677047139b12423e49f3be
Showing with 14 additions and 16 deletions.
  1. +1 −0 assets/js/dataFormatter.js
  2. +1 −0 assets/js/dom.js
  3. +7 −8 assets/js/main.js
  4. +5 −8 assets/js/timeFormatter.js
@@ -3,6 +3,7 @@
const $ = require('jquery');
const getData = require('./firebase');
// sticks type names on attraction objects
module.exports.getTypeNames = (arrayOfAttractionObjects) => {
return new Promise ( (resolve, reject) => {
getData.getTypes().then( (arrayOfTypeObjects) => {
View
@@ -21,6 +21,7 @@ const displayAttractions = attractions => {
$("#attraction-list").html(sidebar({attractions: attractionArray}));
};
// accepts current attractions and passes them into appropriate handlebars template
const displayTimeAttractions = attractions => {
let attractionArray = [];
const sidebar = require("../templates/timeAttr.hbs");
View
@@ -7,28 +7,27 @@ const timeFormatter = require("./timeFormatter");
const $ = require('jquery');
const moment = require('moment');
// resolves getAreas promise and getAllAttractions promise
let promiseArr = [firebase.getAreas(), firebase.getAllAttractions()];
Promise.all(promiseArr)
.then( (results) => {
let areas = [];
let attractions = [];
if (results[0][0].hasOwnProperty("colorTheme")) {
if (results[0][0].hasOwnProperty("colorTheme")) { // assigning areas and attractions based on promise.all array
areas = results[0];
attractions = results[1];
}
else {
areas = results[1];
attractions = results[0];
}
domController.displayAreaGrid(areas);
timeFormatter.getAttractionsWithHours(attractions);
let currentTime = moment().format("HH:mmA");
let currentAttractions = timeFormatter.getCurrentAttractions(currentTime);
domController.displayAttractions(currentAttractions);
domController.displayAreaGrid(areas); // displays area grid
timeFormatter.getAttractionsWithHours(attractions); // accepts all attractions and returns attractions that have hours
let currentTime = moment().format("HH:mmA"); // gets current time with moment
timeFormatter.getCurrentAttractions(currentTime); //passes in current time and returns an array of attractions happening at that time
});
events.activateEvents();
domController.populateFooter();
timeFormatter.activateClock();
View
@@ -6,32 +6,29 @@ const dataFormatter = require('./dataFormatter');
let attractionsWithAreas = [];
module.exports.activateClock = function(){
};
// called in main.js, accepts all attractions and filters down to attractions with hours
// passes attractions with hours into the getAreaNames function
// passes attractions with hours into the getAreaNames function
// goes to get areaNames, stores attractions with areaNames in this module
module.exports.getAttractionsWithHours = (allAttractions) => {
let attractionsWithHours = allAttractions.filter(function (attractionObject) {
if (attractionObject.hasOwnProperty('times')){
return attractionObject;
}
});
dataFormatter.getAreaNames(attractionsWithHours).then( (att) => {
attractionsWithAreas = att;
attractionsWithAreas = att; // this is an array of attractions with areaName properties attached
});
};
// accepts a time, goes through attractions with areas attached, searches for attractions that match the time you passed in
module.exports.getCurrentAttractions = (time) => {
let currentAttractions = [];
attractionsWithAreas.forEach(attractionObject => {
let timesArray = attractionObject.times;
if (timesArray.indexOf(time) != -1){
currentAttractions.push(attractionObject);
}
// return currentAttractions;
printToDom.displayTimeAttractions(currentAttractions);
printToDom.displayTimeAttractions(currentAttractions);
});
};

0 comments on commit 290089b

Please sign in to comment.