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
ce6d7653
...
ce6d765348caf3184fc9ebaa8526ccc67e04cc6f
authored
2011-09-19 11:53:42 +0200
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added ClientUtils#getBase64 + minor jsdoc fixes
1 parent
8877515f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
15 deletions
casper.js
casper.js
View file @
ce6d765
...
...
@@ -84,12 +84,12 @@
*
* NOTE: we cannot use window.btoa() for some strange reasons here.
*
* @param
s
tring url The url to download
* @param
S
tring url The url to download
* @return string Base64 encoded result
*/
base64encode
:
function
(
url
)
{
return
result
=
this
.
evaluate
(
function
()
{
return
__utils__
.
encode
(
__utils__
.
getBinary
(
'%url%'
)
);
return
__utils__
.
getBase64
(
'%url%'
);
},
{
url
:
url
});
...
...
@@ -100,7 +100,7 @@
* automatically set page clipRect setting values and sets it back once
* done.
*
* @param
s
tring targetFile A target filename
* @param
S
tring targetFile A target filename
* @param mixed clipRect An optional clipRect object
* @return Casper
*/
...
...
@@ -179,7 +179,7 @@
/**
* Exit phantom on failure, with a logged error message.
*
* @param
s
tring message An optional error message
* @param
S
tring message An optional error message
* @param Number status An optional exit status code (must be > 0)
* @return Casper
*/
...
...
@@ -197,7 +197,7 @@
/**
* Prints something to stdout.
*
* @param
s
tring text A string to echo to stdout
* @param
S
tring text A string to echo to stdout
* @return Casper
*/
echo
:
function
(
text
)
{
...
...
@@ -237,7 +237,7 @@
* returns false.
*
* @param function fn Expression to evaluate
* @param
s
tring message Error message to log
* @param
S
tring message Error message to log
* @return Casper
*/
evaluateOrDie
:
function
(
fn
,
message
)
{
...
...
@@ -261,9 +261,9 @@
/**
* Logs a message.
*
* @param
s
tring message The message to log
* @param
s
tring level The log message level (from Casper.logLevels property)
* @param
s
tring space Space from where the logged event occured (default: "phantom")
* @param
S
tring message The message to log
* @param
S
tring level The log message level (from Casper.logLevels property)
* @param
S
tring space Space from where the logged event occured (default: "phantom")
* @return Casper
*/
log
:
function
(
message
,
level
,
space
)
{
...
...
@@ -289,7 +289,7 @@
* callback argument would defeat the whole purpose of Casper
* actually).
*
* @param
s
tring location The url to open
* @param
S
tring location The url to open
* @return Casper
*/
open
:
function
(
location
)
{
...
...
@@ -333,7 +333,7 @@
/**
* Configures and start the Casper.
*
* @param
s
tring location An optional location to open on start
* @param
S
tring location An optional location to open on start
* @param function then Next step function to execute on page loaded (optional)
* @return Casper
*/
...
...
@@ -406,7 +406,7 @@
/**
* Adds a new navigation step for opening the provided location.
*
* @param
s
tring location The URL to load
* @param
S
tring location The URL to load
* @param function then Next step function to execute on page loaded (optional)
* @return Casper
* @see Casper#open
...
...
@@ -422,7 +422,7 @@
* Adds a new navigation step for opening and evaluate an expression
* against the DOM retrieved from the provided location.
*
* @param
s
tring location The url to open
* @param
S
tring location The url to open
* @param function fn The function to be evaluated within current page DOM
* @param object replacements Optional replacements to performs, eg. for '%foo%' => {foo: 'bar'}
* @return Casper
...
...
@@ -442,7 +442,7 @@
* Base64 encodes a string, even binary ones. Succeeds where
* window.btoa() fails.
*
* @param
s
tring str
* @param
S
tring str
* @return string
*/
this
.
encode
=
function
(
str
)
{
...
...
@@ -474,9 +474,20 @@
};
/**
* Downloads a resource behind an url and returns its base64-encoded
* contents.
*
* @param String url The resource url
* @return String Base64 contents string
*/
this
.
getBase64
=
function
(
url
)
{
return
this
.
encode
(
this
.
getBinary
(
url
));
};
/**
* Retrieves string contents from a binary file behind an url.
*
* @param
s
tring url
* @param
S
tring url
* @return string
*/
this
.
getBinary
=
function
(
url
)
{
...
...
Please
register
or
sign in
to post a comment