Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scripts/controllers/installationsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
installationsController.index = function(ctx, next) {
installationView.index(ctx.installation);
};

// this is a great use of middleware. Using it to compose async functionality is
// one of the things it's best for.
installationsController.loadByMedium = function(ctx, next) {
var mediumData = function(installationsInMedium) {
ctx.installation = installationsInMedium;
Expand Down
2 changes: 2 additions & 0 deletions scripts/models/artMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ function showPosition(position) {
}

artMap.initMap = function () { //creates map
// it may have been helpful to clear up what these numbers represent.
// maybe with something like: var pdxCoords = {lat: 45.5315, lng: -122.6668}
var lat = 45.5315;
var lng = -122.6668
var mapOptions = {
Expand Down
3 changes: 2 additions & 1 deletion scripts/models/findMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ findMap.setPinCoords = function (filteredArray){
}



//prefer camelCase for function and variable names
findMap.place_all_Pins = function(locationData){ //takes a 2d array of coords
var opts = {};
if (allPins.length) {
Expand All @@ -64,6 +64,7 @@ findMap.setPinCoords = function (filteredArray){
google.maps.event.addListener(marker, "click", function (event) {
var latitude = this.position.lat();
var obj;
// Nice use of both routing and passing functions
Installation.findWhere('lat', latitude, function(data) {
page('/loveart/' + data[0].id);
});
Expand Down
17 changes: 15 additions & 2 deletions scripts/models/installations.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
this[e] = opts[e];
},this);
}

// The technical term for a function like this is a noop (no operation)
// it's possible that you may need something like this. Usually, though,
// you'd use a noop for a function that was expecting to be passed a callback
// and would throw a TypeError because it was trying to call something that
// isn't there. Looking through your code it seems like none of the places where
// you pass myTemp actually have to have a callback so you likely could have just
// left it out.
function myTemp(){
};

Expand Down Expand Up @@ -78,7 +84,14 @@
}); //execute select
};//fetchAll


// the following functions (the ones that start with 'all') likely could have
// been refactored to take another argument. Like:
// Installation.allBy = function(category, callback) {
// webDB.execute('SELECT DISTINCT ' + category + ' FROM Installations', callback);
// }
// or if you wanted to get even fancier about it you could go through a list of all of
// the categories and return the results of each query as an array. This gets tough though
// because you have to manage the sequence of async calls returning.
Installation.allMediums = function(callback) {
webDB.execute('SELECT DISTINCT medium FROM Installations', callback);
};
Expand Down
10 changes: 9 additions & 1 deletion scripts/views/searchView.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

searchView.populateFilters = function(){
var template = Handlebars.compile($('#option-template').text());

//The if statements here don't appear to be doing anything. Since
//you put your append logic inside the conditional it's going to
//evaluate it either way. Which means that it's running the query
//and appending the results. No matter what the results thereof
//are.
Installation.allMediums(function(rows) {
if ($('#medium-filter').append(rows.map(function(row){
return template({val: row.medium});
Expand Down Expand Up @@ -37,6 +41,10 @@

searchView.handleFilters = function () {
$('#filters').on('change', 'select', function() {
// this is a neat way to solve the problem of getting Which
// filter was interacted with from the element itself. It might
// be a bit more idiomatic and stable to store the needed
// information as a data attribute instead of on the id.
var f = this.id.replace('-filter', '');
var v = $(this).val();
Installation.findWhere(f, v, function (filteredArray) {
Expand Down