mirror of https://github.com/vitalif/phantomjs
Examples: new coffeescript versions.
parent
1c94da0daf
commit
2c8e9bd5b4
|
@ -0,0 +1,13 @@
|
||||||
|
# Read the Phantom webpage '#intro' element text using jQuery and "includeJs"
|
||||||
|
|
||||||
|
page = new WebPage()
|
||||||
|
|
||||||
|
page.onConsoleMessage = (msg) -> console.log msg
|
||||||
|
|
||||||
|
page.open "http://www.phantomjs.org", (status) ->
|
||||||
|
if status is "success"
|
||||||
|
page.includeJs "http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", ->
|
||||||
|
page.evaluate ->
|
||||||
|
console.log "$(\"#intro\").text() -> " + $("#intro").text()
|
||||||
|
phantom.exit()
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
###
|
||||||
|
Sort integers from the command line in a very ridiculous way: leveraging timeouts :P
|
||||||
|
###
|
||||||
|
|
||||||
|
if phantom.args < 1
|
||||||
|
console.log "Usage: phantomjs sleepsort.js PUT YOUR INTEGERS HERE SEPARATED BY SPACES"
|
||||||
|
phantom.exit()
|
||||||
|
else
|
||||||
|
sortedCount = 0
|
||||||
|
for int in phantom.args
|
||||||
|
setTimeout ((j) ->
|
||||||
|
->
|
||||||
|
console.log j
|
||||||
|
++sortedCount
|
||||||
|
phantom.exit() if sortedCount is phantom.args.length)(int),
|
||||||
|
int
|
||||||
|
|
Loading…
Reference in New Issue