Skip to content

Instantly share code, notes, and snippets.

@jacobandresen
Created May 1, 2012 10:31
Show Gist options
  • Save jacobandresen/2567069 to your computer and use it in GitHub Desktop.
Save jacobandresen/2567069 to your computer and use it in GitHub Desktop.
flatten the Ext4 docs
var casper = require('casper').create({
viewportSize: {
width: 1024,
height: 768
}
});
var seen = [];
function getLinks() {
var links = Ext.query('a.docClass');
return Array.prototype.map.call(links, function (e) {
return e.getAttribute('href');
});
};
var ext4 = Object.create(casper);
ext4.start("http://localhost/ext4/docs/index.html#!/api");
ext4.indexPage = function ( seen , currentPosition ) {
var link = "a[href='" + seen[currentPosition] +"']";
ext4.click(link);
ext4.then(function () {
var text = this.evaluate( function () {
return (Ext.query('.doc-contents')[0].innerText);
});
console.log("=====================================================================");
console.log(this.getTitle());
console.log("=====================================================================");
console.log(text);
currentPosition = currentPosition + 1;
if (seen.length > currentPosition) {
ext4.indexPage( seen, currentPosition);
} else {
ext4.exit();
}
});
}
ext4.then(function () {
var i, seen = this.evaluate(getLinks);
ext4.indexPage( seen, 0 );
});
ext4.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment