Created
June 25, 2012 04:47
-
-
Save cocodrino/2986585 to your computer and use it in GitHub Desktop.
javascript callbacks to livescript clean code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var phantom = require('phantom'); | |
phantom.create(function(ph) { | |
return ph.createPage(function(page) { | |
return page.open("http://www.google.com", function(status) { | |
console.log("opened google? ", status); | |
return page.evaluate((function() { | |
return document.title; | |
}), function(result) { | |
console.log('Page title is ' + result); | |
return ph.exit(); | |
}); | |
}); | |
}); | |
}); | |
phantom = require 'phantom' | |
ph <-phantom.create | |
page <- ph.createpage | |
status <-page.open(google) | |
console.log "opened google? #{status}" | |
page.evaluate((-> document.title), | |
( -> | |
console.log ("page title is" + it) | |
ph.exit() | |
)) | |
--------------LS comp -------------------------------------------------------- | |
var phantom; | |
phantom = require('phantom'); | |
phantom.create(function(ph){ | |
return ph.createpage(function(page){ | |
return page.open(google, function(status){ | |
console.log("opened google? " + status); | |
return page.evaluate(function(){ | |
return document.title; | |
}, function(it){ | |
console.log("page title is" + it); | |
return ph.exit(); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment