Last change
on this file since 31525 was 31525, checked in by ak19, 7 years ago |
Nathan provided more stuff: Themes folder contains Sencha's Themebuilder which generates GXT Themes. It includes the .theme and generated .jar files for the project theme.
|
File size:
1.3 KB
|
Rev | Line | |
---|
[31525] | 1 | # Get driving direction using Google Directions API.
|
---|
| 2 |
|
---|
| 3 | page = require('webpage').create()
|
---|
| 4 | system = require 'system'
|
---|
| 5 |
|
---|
| 6 | if system.args.length < 3
|
---|
| 7 | console.log 'Usage: direction.coffee origin destination'
|
---|
| 8 | console.log 'Example: direction.coffee "San Diego" "Palo Alto"'
|
---|
| 9 | phantom.exit 1
|
---|
| 10 | else
|
---|
| 11 | origin = system.args[1]
|
---|
| 12 | dest = system.args[2]
|
---|
| 13 | page.open encodeURI('http://maps.googleapis.com/maps/api/directions/xml?origin=' + origin +
|
---|
| 14 | '&destination=' + dest + '&units=imperial&mode=driving&sensor=false'),
|
---|
| 15 | (status) ->
|
---|
| 16 | if status isnt 'success'
|
---|
| 17 | console.log 'Unable to access network'
|
---|
| 18 | else
|
---|
| 19 | steps = page.content.match(/<html_instructions>(.*)<\/html_instructions>/ig)
|
---|
| 20 | if not steps
|
---|
| 21 | console.log 'No data available for ' + origin + ' to ' + dest
|
---|
| 22 | else
|
---|
| 23 | for ins in steps
|
---|
| 24 | ins = ins.replace(/\</ig, '<').replace(/\>/ig, '>')
|
---|
| 25 | ins = ins.replace(/\<div/ig, '\n<div')
|
---|
| 26 | ins = ins.replace(/<.*?>/g, '')
|
---|
| 27 | console.log(ins)
|
---|
| 28 | console.log ''
|
---|
| 29 | console.log page.content.match(/<copyrights>.*<\/copyrights>/ig).join('').replace(/<.*?>/g, '')
|
---|
| 30 | phantom.exit()
|
---|
Note:
See
TracBrowser
for help on using the repository browser.