Skip to content

Instantly share code, notes, and snippets.

@ScarletPonytail
Created April 5, 2018 15:10
Show Gist options
  • Save ScarletPonytail/7a7b23a169fe07dbe8e811f3141d7164 to your computer and use it in GitHub Desktop.
Save ScarletPonytail/7a7b23a169fe07dbe8e811f3141d7164 to your computer and use it in GitHub Desktop.
JS / JQuery - Query array inline
function suggestUserLocation() {
if ( getCookie( 'closestLocation' ) !== '' ) {
var closestLocation = jQuery.parseJSON( getCookie( 'closestLocation' ) );
var theCountries = [
'Cayman Islands',
'Falkland Islands',
'Philippines',
'UAE',
'United Kingdom',
'United States'
];
jQuery( '#header-country-select .easy-autocomplete-container' ).append( '<div class="siteLocationSuggestion"><div> Are you in ' + ( ( theCountries.indexOf(closestLocation.loc_user) > -1 ) ? 'the ' : '' ) + closestLocation.loc_user + '? &nbsp; Visit <a href="' + closestLocation.loc_weburl + '" target="_blank"> <img src="' + closestLocation.loc_flag + '" /> <span>' + closestLocation.loc_webtext + '</span></a></div></div>' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment