Convert imagebin.js to CoffeeScript

1.2
IceArmy 2011-06-06 18:18:22 -07:00
parent 8ee3340d7e
commit 6390f92550
1 changed files with 19 additions and 0 deletions

19
examples/imagebin.coffee Normal file
View File

@ -0,0 +1,19 @@
# Upload an image to imagebin.org
page = new WebPage()
if phantom.args.length isnt 1
console.log 'Usage: imagebin.coffee filename'
phantom.exit()
else
fname = phantom.args[0]
page.open 'http://imagebin.org/index.php?page=add', ->
page.uploadFile 'input[name=image]', fname
page.evaluate ->
document.querySelector('input[name=nickname]').value = 'phantom'
document.querySelector('input[name=disclaimer_agree]').click()
document.querySelector('form').submit()
window.setTimeout ->
phantom.exit()
, 3000