Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
5c3db051
...
5c3db051a4aa6270f66c742825cf02b729f3cf02
authored
2011-12-27 15:26:59 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
minor tweaks added to samples/dynamic.js
1 parent
45719c88
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
samples/dynamic.js
samples/dynamic.js
View file @
5c3db05
...
...
@@ -9,7 +9,7 @@ if (phantom.casperArgs.args.length !== 1) {
}
// If we don't set a limit, it could go on forever
var
upTo
=
Number
(
phantom
.
casperArgs
.
args
[
0
],
10
)
;
var
upTo
=
~~
phantom
.
casperArgs
.
args
[
0
]
;
var
casper
=
new
phantom
.
Casper
({
verbose
:
true
...
...
@@ -20,9 +20,9 @@ var casper = new phantom.Casper({
function
searchLinks
()
{
var
filter
=
Array
.
prototype
.
filter
,
map
=
Array
.
prototype
.
map
;
return
map
.
call
(
filter
.
call
(
document
.
querySelectorAll
(
'a'
),
function
(
a
)
{
return
/^http:
\/\/
.*/i
.
test
(
a
.
getAttribute
(
'href'
));
}),
function
(
a
)
{
return
map
.
call
(
filter
.
call
(
document
.
querySelectorAll
(
'a'
),
function
(
a
)
{
return
(
/^http:
\/\/
.*/i
)
.
test
(
a
.
getAttribute
(
'href'
));
}),
function
(
a
)
{
return
a
.
getAttribute
(
'href'
);
});
}
...
...
@@ -35,16 +35,16 @@ var links = [
];
// Just opens the page and prints the title
var
start
=
function
(
self
,
link
)
{
self
.
start
(
link
,
function
(
self
)
{
var
start
=
function
(
self
,
link
)
{
self
.
start
(
link
,
function
(
self
)
{
self
.
echo
(
'Page title: '
+
self
.
getTitle
());
})
})
;
};
// Get the links, and add them to the links array
// (It could be done all in one step, but it is intentionally splitted)
var
addLinks
=
function
(
self
,
link
)
{
self
.
then
(
function
(
self
)
{
var
addLinks
=
function
(
link
)
{
this
.
then
(
function
(
self
)
{
var
found
=
self
.
evaluate
(
searchLinks
);
self
.
echo
(
found
.
length
+
" links found on "
+
link
);
links
=
links
.
concat
(
found
);
...
...
@@ -62,7 +62,7 @@ function check(self) {
if
(
links
[
currentLink
]
&&
currentLink
<
upTo
)
{
self
.
echo
(
'--- Link '
+
currentLink
+
' ---'
);
start
(
self
,
links
[
currentLink
]);
addLinks
(
self
,
links
[
currentLink
]);
addLinks
.
call
(
self
,
links
[
currentLink
]);
currentLink
++
;
self
.
run
(
check
);
}
else
{
...
...
Please
register
or
sign in
to post a comment