Last active
December 21, 2015 15:39
-
-
Save drugoi/6328513 to your computer and use it in GitHub Desktop.
Check when user come from KZ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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