I need to check if the current location is in Europe and if so execute some code. As there is no umbrella 'EU' code, I've had to list the countries and store them in an array. I can't figure out the best way to check against the array though...
jQuery.ajax( {
url: '//freegeoip.net/json/',
type: 'POST',
dataType: 'jsonp',
success: function(location) {
// If the visitor is browsing from UK.
if (location.country_code === 'GB') {
// do UK thing
}
// If the visitor is browsing from US.
else if(location.country_code === 'US'){
// do US thing
}
else if(location.country_code === EU){
//do EU thing
}
else{
// do nothing
}
}
} );
var EU = ["AT", "BE", "CY", "CZ", "DE", "DK", "EE", "ES", "FI", "FR", "GR", "HU", "IE", "NO", "NL", "PO", "SE"];