Skip to content

Instantly share code, notes, and snippets.

@ericf
Created July 6, 2011 17:19
Show Gist options
  • Select an option

  • Save ericf/1067797 to your computer and use it in GitHub Desktop.

Select an option

Save ericf/1067797 to your computer and use it in GitHub Desktop.
// *** Place *** //
Place = Y.Base.create('place', Y.Model, [YQLSync], {
idAttribute : 'woeid',
query : 'SELECT * FROM geo.places WHERE woeid={id}',
parse : function (results) {
if ( ! results) { return; }
var data = results.place;
return {
woeid : data.woeid,
country : data.country.code,
region : data.admin1.content,
locality : data.locality1.content,
latitude : data.centroid.latitude,
longitude : data.centroid.longitude
};
},
toString : function () {
var country = this.get('country'),
region = this.get('region'),
locality = this.get('locality');
if (locality) {
return ( locality + ', ' + region );
}
if (region) {
return ( region + ', ' + country );
}
return country || '';
}
}, {
ATTRS : {
woeid : {},
country : {},
region : {},
locality : {},
latitude : {},
longitude : {}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment