Last active
August 29, 2015 14:12
-
-
Save theresaanna/dc9c816ab1bf967a6758 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var loadSingleEntity = function(e) { | |
var urls = []; | |
urls.push(callAPI(buildURL(e))); | |
urls.push(callAPI(url for committee info)); | |
$.when.apply($, urls).done(function() { | |
var i, | |
len = arguments.length; | |
e.results = {}; | |
for (i = 0; i < len; i++) { | |
if (i === 0){ | |
e.results = arguments[i][0].results; | |
} | |
else { | |
// committee data | |
e.results[entitiesArray[i]] = arguments[i][0].results; | |
} | |
} | |
events.emit('render:singleEntity', e); | |
}).fail(function() { | |
events.emit('err:load:singleEntity'); | |
}); | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildCandidateContext: function(results) { | |
// usual stuff... | |
for (i = 0; i < len; i++) { | |
newCandidateObj = { | |
id: '', | |
name: '', | |
office: '', | |
election: '', | |
party: '', | |
state: '', | |
district: '', | |
incumbent_challenge: '', | |
nameURL: '', | |
committee_name: '' | |
}; | |
// more usual stuff... | |
if (results[i] has a property that indicates there is associated committee data) { | |
newCandidateObj.committee_name = whatever; | |
} | |
candidates.push(newCandidateObj); | |
} | |
return candidates; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment