(re) added 'name' to functions
Showing
5 changed files
with
10 additions
and
10 deletions
... | @@ -37,7 +37,7 @@ casper.start('http://www.bbc.co.uk/', function() { | ... | @@ -37,7 +37,7 @@ casper.start('http://www.bbc.co.uk/', function() { |
37 | }); | 37 | }); |
38 | }); | 38 | }); |
39 | 39 | ||
40 | var next = function() { | 40 | var next = function next() { |
41 | var image = "bbcshot" + currentLink + ".png"; | 41 | var image = "bbcshot" + currentLink + ".png"; |
42 | images.push(image); | 42 | images.push(image); |
43 | this.echo("Processing image " + currentLink); | 43 | this.echo("Processing image " + currentLink); |
... | @@ -53,7 +53,7 @@ var next = function() { | ... | @@ -53,7 +53,7 @@ var next = function() { |
53 | } | 53 | } |
54 | }; | 54 | }; |
55 | 55 | ||
56 | var buildPage = function() { | 56 | var buildPage = function buildPage() { |
57 | this.echo('Build result page'); | 57 | this.echo('Build result page'); |
58 | var fs = require('fs'); | 58 | var fs = require('fs'); |
59 | this.viewport(624, 400); | 59 | this.viewport(624, 400); | ... | ... |
... | @@ -7,7 +7,7 @@ var upTo = ~~casper.cli.get(0) || 10; // max 10 links | ... | @@ -7,7 +7,7 @@ var upTo = ~~casper.cli.get(0) || 10; // max 10 links |
7 | 7 | ||
8 | // Fetch all <a> elements from the page and return | 8 | // Fetch all <a> elements from the page and return |
9 | // the ones which contains a href starting with 'http://' | 9 | // the ones which contains a href starting with 'http://' |
10 | var searchLinks = function() { | 10 | var searchLinks = function searchLinks() { |
11 | var filter = Array.prototype.filter; | 11 | var filter = Array.prototype.filter; |
12 | var map = Array.prototype.map; | 12 | var map = Array.prototype.map; |
13 | return map.call(filter.call(document.querySelectorAll("a"), function(a) { | 13 | return map.call(filter.call(document.querySelectorAll("a"), function(a) { |
... | @@ -25,7 +25,7 @@ var links = [ | ... | @@ -25,7 +25,7 @@ var links = [ |
25 | ]; | 25 | ]; |
26 | 26 | ||
27 | // Just opens the page and prints the title | 27 | // Just opens the page and prints the title |
28 | var start = function(link) { | 28 | var start = function start(link) { |
29 | this.start(link, function() { | 29 | this.start(link, function() { |
30 | this.echo("Page title: " + (this.getTitle())); | 30 | this.echo("Page title: " + (this.getTitle())); |
31 | }); | 31 | }); |
... | @@ -33,7 +33,7 @@ var start = function(link) { | ... | @@ -33,7 +33,7 @@ var start = function(link) { |
33 | 33 | ||
34 | // Get the links, and add them to the links array | 34 | // Get the links, and add them to the links array |
35 | // (It could be done all in one step, but it is intentionally splitted) | 35 | // (It could be done all in one step, but it is intentionally splitted) |
36 | var addLinks = function(link) { | 36 | var addLinks = function addLinks(link) { |
37 | this.then(function() { | 37 | this.then(function() { |
38 | var found = this.evaluate(searchLinks); | 38 | var found = this.evaluate(searchLinks); |
39 | this.echo("" + found.length + " links found on " + link); | 39 | this.echo("" + found.length + " links found on " + link); |
... | @@ -50,7 +50,7 @@ casper.then(function() { | ... | @@ -50,7 +50,7 @@ casper.then(function() { |
50 | var currentLink = 0; | 50 | var currentLink = 0; |
51 | 51 | ||
52 | // As long as it has a next link, and is under the maximum limit, will keep running | 52 | // As long as it has a next link, and is under the maximum limit, will keep running |
53 | var check = function() { | 53 | var check = function check() { |
54 | if (links[currentLink] && currentLink < upTo) { | 54 | if (links[currentLink] && currentLink < upTo) { |
55 | this.echo("--- Link " + currentLink + " ---"); | 55 | this.echo("--- Link " + currentLink + " ---"); |
56 | start.call(this, links[currentLink]); | 56 | start.call(this, links[currentLink]); | ... | ... |
1 | var getLinks = function() { | 1 | var getLinks = function getLinks() { |
2 | var links; | 2 | var links; |
3 | links = document.querySelectorAll("h3.r a"); | 3 | links = document.querySelectorAll("h3.r a"); |
4 | return Array.prototype.map.call(links, function(e) { | 4 | return Array.prototype.map.call(links, function(e) { | ... | ... |
... | @@ -17,7 +17,7 @@ if (casper.cli.args.length === 0) { | ... | @@ -17,7 +17,7 @@ if (casper.cli.args.length === 0) { |
17 | ; | 17 | ; |
18 | } | 18 | } |
19 | 19 | ||
20 | var processPage = function() { | 20 | var processPage = function processPage() { |
21 | var url; | 21 | var url; |
22 | this.echo("capturing page " + currentPage); | 22 | this.echo("capturing page " + currentPage); |
23 | this.capture("google-results-p" + currentPage + ".png"); | 23 | this.capture("google-results-p" + currentPage + ".png"); | ... | ... |
... | @@ -2,7 +2,7 @@ var casper = require('casper').create({ | ... | @@ -2,7 +2,7 @@ var casper = require('casper').create({ |
2 | verbose: true | 2 | verbose: true |
3 | }); | 3 | }); |
4 | 4 | ||
5 | var countLinks = function() { | 5 | var countLinks = function countLinks() { |
6 | return document.querySelectorAll('a').length; | 6 | return document.querySelectorAll('a').length; |
7 | }; | 7 | }; |
8 | 8 | ||
... | @@ -42,7 +42,7 @@ casper.then(function() { | ... | @@ -42,7 +42,7 @@ casper.then(function() { |
42 | 42 | ||
43 | var currentSuite = 0; | 43 | var currentSuite = 0; |
44 | 44 | ||
45 | var check = function() { | 45 | var check = function check() { |
46 | if (suites[currentSuite]) { | 46 | if (suites[currentSuite]) { |
47 | suites[currentSuite].call(this); | 47 | suites[currentSuite].call(this); |
48 | currentSuite++; | 48 | currentSuite++; | ... | ... |
-
Please register or sign in to post a comment