ipgeocode.coffee 392 B

12345678910111213
  1. # Give the estimated location based on the IP address.
  2. window.cb = (data) ->
  3. loc = data.city
  4. if data.region_name.length > 0
  5. loc = loc + ', ' + data.region_name
  6. console.log 'IP address: ' + data.ip
  7. console.log 'Estimated location: ' + loc
  8. phantom.exit()
  9. el = document.createElement 'script'
  10. el.src = 'http://freegeoip.net/json/?callback=window.cb'
  11. document.body.appendChild el