mirror of https://github.com/vitalif/phantomjs
14 lines
411 B
CoffeeScript
14 lines
411 B
CoffeeScript
|
# Give the estimated location based on the IP address.
|
||
|
|
||
|
document.cb = (data) ->
|
||
|
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()
|
||
|
|
||
|
el = document.createElement 'script'
|
||
|
el.src = 'http://freegeoip.net/json/?callback=document.cb'
|
||
|
document.body.appendChild el
|