зеркало из https://github.com/mozilla/ubiquity.git
CmdUtils: Made getGeoLocation provide short names as well.
This commit is contained in:
Родитель
4599004177
Коммит
0700d76f7c
|
@ -368,9 +368,14 @@ function setLastResult(result) {
|
||||||
// the requesting {{{XMLHttpRequest}}} instead.
|
// the requesting {{{XMLHttpRequest}}} instead.
|
||||||
//
|
//
|
||||||
// The geolocation object has at least the following properties:
|
// The geolocation object has at least the following properties:
|
||||||
// {{{lat}}}, {{{lon}}}, {{{city}}}, {{{state}}}, {{{country}}}
|
//
|
||||||
// (See [[http://code.google.com/apis/maps/documentation/geocoding/#Types]]
|
// {{{ lat lon city state country }}}
|
||||||
// for a list of possible properties.)
|
//
|
||||||
|
// Plus their short versions as {{{*Short}}} if available.
|
||||||
|
//
|
||||||
|
// * {{{countryShort}}} is aliased as {{{country_code}}} for backcompat.
|
||||||
|
// * See [[http://code.google.com/apis/maps/documentation/geocoding/#Types]]
|
||||||
|
// for a list of possible properties.
|
||||||
//
|
//
|
||||||
// You can choose to use the function synchronously: do not pass in any
|
// You can choose to use the function synchronously: do not pass in any
|
||||||
// callback, and the geolocation object will instead be returned
|
// callback, and the geolocation object will instead be returned
|
||||||
|
@ -396,8 +401,10 @@ function getGeoLocation(callback) {
|
||||||
if (dat.status != "OK") break;
|
if (dat.status != "OK") break;
|
||||||
for each (let result in dat.results)
|
for each (let result in dat.results)
|
||||||
for each (let address in result.address_components)
|
for each (let address in result.address_components)
|
||||||
for each (let type in address.types)
|
for each (let type in address.types) if (!loc[type])
|
||||||
if (!loc[type]) loc[type] = address.long_name;
|
((loc[type] = address.long_name) === address.short_name ||
|
||||||
|
(loc[type + 'Short'] = address.short_name));
|
||||||
|
loc.country_code = loc.countryShort || loc.politicalShort;
|
||||||
loc.country = loc.country || loc.political;
|
loc.country = loc.country || loc.political;
|
||||||
loc.city = loc.locality;
|
loc.city = loc.locality;
|
||||||
loc.state = loc.administrative_area_level_1;
|
loc.state = loc.administrative_area_level_1;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче