Skip to content

Instantly share code, notes, and snippets.

@drugoi
Last active December 21, 2015 15:39
Show Gist options
  • Save drugoi/6328513 to your computer and use it in GitHub Desktop.
Save drugoi/6328513 to your computer and use it in GitHub Desktop.
Check when user come from KZ
function setCityByIp() {
var arrcity = ['Aktau', 'Aktobe', 'Almaty', 'Astana', 'Atyrau', 'Zhezkazgan', 'Karagandy', 'Kyzylorda', 'Kokshetau', 'Kostanay', 'Pavlodar', 'Petropavl', 'Semey', 'Taldykorgan', 'Taraz', 'Oral', 'Oskemen', 'Shymkent'];
$.get("http://ipinfo.io", function(response) {
for (var i=0; i < arrcity.length; i++) {
if (arrcity[i] == response.city) {
console.log('You\'re from ' + response.city + 'KZ');
} else if (response.city == null) {
console.log('You\'re not from KZ');
}
}
}, "jsonp");
}
setCityByIp();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment