mirror of
https://github.com/encounter/phantomjs.git
synced 2026-03-30 11:35:11 -07:00
e8380e42d7
Added CoffeeScript examples where missing, minor other fixes such as spacing standardization (2 spaces is the standard in CoffeeScript via Ruby). Also a small set of minor JS example fixes and additional comments. Fixes http://code.google.com/p/phantomjs/issues/detail?id=907
24 lines
731 B
JavaScript
24 lines
731 B
JavaScript
// Upload an image to imagebin.org
|
|
|
|
var page = require('webpage').create(),
|
|
system = require('system'),
|
|
fname;
|
|
|
|
if (system.args.length !== 2) {
|
|
console.log('Usage: imagebin.js filename');
|
|
phantom.exit(1);
|
|
} else {
|
|
fname = system.args[1];
|
|
page.open("http://imagebin.org/index.php?page=add", function () {
|
|
page.uploadFile('input[name=image]', fname);
|
|
page.evaluate(function () {
|
|
document.querySelector('input[name=nickname]').value = 'phantom';
|
|
document.querySelector('input[name=disclaimer_agree]').click()
|
|
document.querySelector('form').submit();
|
|
});
|
|
window.setTimeout(function () {
|
|
phantom.exit();
|
|
}, 3000);
|
|
});
|
|
}
|