in Geo module, actually use image symlinks; add Ox.getFlagByCountryCode method

This commit is contained in:
rolux 2012-04-01 23:08:35 +02:00
parent fbc15dcadf
commit 241f0bc064

View file

@ -125,7 +125,6 @@ Ox.load.Geo = function(options, callback) {
> Ox.getCountryByCode('US').name > Ox.getCountryByCode('US').name
'United States' 'United States'
@*/ @*/
Ox.getCountryByCode = function(code) { Ox.getCountryByCode = function(code) {
var country; var country;
code = code.toUpperCase(); code = code.toUpperCase();
@ -147,7 +146,6 @@ Ox.load.Geo = function(options, callback) {
> Ox.getCountryByGeoname('The Bottom, Saba, Bonaire, Sint Eustatius and Saba').code > Ox.getCountryByGeoname('The Bottom, Saba, Bonaire, Sint Eustatius and Saba').code
'BQ' 'BQ'
@*/ @*/
Ox.getCountryByGeoname = function(geoname) { Ox.getCountryByGeoname = function(geoname) {
// fixme: UAE correction doesn't belong here, fix in map // fixme: UAE correction doesn't belong here, fix in map
geoname = (geoname || '').replace(' - United Arab Emirates', ', United Arab Emirates') geoname = (geoname || '').replace(' - United Arab Emirates', ', United Arab Emirates')
@ -167,7 +165,6 @@ Ox.load.Geo = function(options, callback) {
> Ox.getCountryByName('USA').code > Ox.getCountryByName('USA').code
'US' 'US'
@*/ @*/
Ox.getCountryByName = function(name) { Ox.getCountryByName = function(name) {
var country; var country;
Ox.forEach(Ox.COUNTRIES, function(c) { Ox.forEach(Ox.COUNTRIES, function(c) {
@ -179,6 +176,10 @@ Ox.load.Geo = function(options, callback) {
return country; return country;
}; };
Ox.getFlagByCountryCode = function(code, size) {
return Ox.PATH + 'Ox.Geo/png/flags/' + size + '/' + code + '.png';
};
/*@ /*@
Ox.getImageByGeoname <f> Returns an image URL for a given geoname Ox.getImageByGeoname <f> Returns an image URL for a given geoname
(type, size, geoname) -> <s> Image URL (type, size, geoname) -> <s> Image URL
@ -186,10 +187,9 @@ Ox.load.Geo = function(options, callback) {
size <n> Image width (32, 256, 2048 (flag), 16, 256, 1024 (icon)) size <n> Image width (32, 256, 2048 (flag), 16, 256, 1024 (icon))
geoname <s> Geoname geoname <s> Geoname
@*/ @*/
Ox.getFlagByGeoname = function(geoname, size) { Ox.getFlagByGeoname = function(geoname, size) {
var country = Ox.getCountryByGeoname(geoname), var country = Ox.getCountryByGeoname(geoname),
code = country ? country.flag || country.code : 'NTHH'; code = country ? country.code : 'NTHH';
return Ox.PATH + 'Ox.Geo/png/flags/' + size + '/' + code + '.png'; return Ox.PATH + 'Ox.Geo/png/flags/' + size + '/' + code + '.png';
}; };
@ -200,7 +200,6 @@ Ox.load.Geo = function(options, callback) {
size <n> Image width (32, 256, 2048 (flag), 16, 256, 1024 (icon)) size <n> Image width (32, 256, 2048 (flag), 16, 256, 1024 (icon))
language <s> Language language <s> Language
@*/ @*/
Ox.getFlagByLanguage = function(language, size) { Ox.getFlagByLanguage = function(language, size) {
language = language language = language
.replace(' languages', '') .replace(' languages', '')