Created
November 20, 2014 00:44
-
-
Save cthrax/7d392e8487f8f55dbde7 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 LocationQuery = function() { | |
this.projects = null; | |
this.parameters = null; | |
this.labels = null; | |
this.gpsBounds = null; | |
this.pageObject = null; | |
this.query = {}; | |
}; | |
LocationQuery.prototype._addToQuery = function(prop) { | |
if (!!this[prop]) { | |
this.query[prop] = this[prop]; | |
} | |
}; | |
LocationQuery.prototype.toParam = function() { | |
var props = ["projects", "parameters", "labels", "gpsBounds", "locationIds", "pageObject"]; | |
props.map(this._addToQuery, this); | |
var val = JSON.stringify(this.query); | |
return { | |
q: val | |
}; | |
}; | |
var LocationDataQuery = function() { | |
this.resolution = null; | |
this.timeslice = null; | |
}; | |
// Inherit from LocationQuery | |
LocationDataQuery.prototype = Object.create(new LocationQuery()); | |
LocationDataQuery.prototype.toParam = function() { | |
// Add locationSpecific properties to query | |
var locationDataProps = ["resolution", "timeslice"]; | |
locationDataProps.map(this._addToQuery, this); | |
// Add super values and return result | |
return LocationQuery.prototype.toParam.call(this); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment