2011-04-22 19:39:51 +04:00
|
|
|
# Give the estimated location based on the IP address.
|
|
|
|
|
2011-05-11 13:42:18 +04:00
|
|
|
window.cb = (data) ->
|
2011-05-29 16:21:25 +04:00
|
|
|
loc = data.city
|
|
|
|
if data.region_name.length > 0
|
|
|
|
loc = loc + ', ' + data.region_name
|
|
|
|
console.log 'IP address: ' + data.ip
|
|
|
|
console.log 'Estimated location: ' + loc
|
|
|
|
phantom.exit()
|
2011-04-22 19:39:51 +04:00
|
|
|
|
|
|
|
el = document.createElement 'script'
|
2011-05-11 13:42:18 +04:00
|
|
|
el.src = 'http://freegeoip.net/json/?callback=window.cb'
|
2011-04-22 19:39:51 +04:00
|
|
|
document.body.appendChild el
|