update examples
This commit is contained in:
parent
adb3355975
commit
679dc34dfa
3 changed files with 29 additions and 34 deletions
|
|
@ -4,7 +4,7 @@ Load the image module.
|
|||
Ox.load('Image', function() {
|
||||
|
||||
/*
|
||||
Load a sample image (about which you can read more on
|
||||
Load a sample image (which has its own entry in
|
||||
<a href="see http://en.wikipedia.org/wiki/Lenna">Wikipedia</a>).
|
||||
*/
|
||||
Ox.Image('png/lenna256.png', function(image) {
|
||||
|
|
@ -52,8 +52,8 @@ Ox.load('Image', function() {
|
|||
match = value.match(/^(\w+)\((.*?)\)$/),
|
||||
fn = match[1], args;
|
||||
/*
|
||||
The <code>map</code> method takes a function as its argument, which
|
||||
we can't <code>JSON.parse</code>, but have to <code>eval</code>.
|
||||
The `map` method takes a function as its argument, which we can't
|
||||
`JSON.parse`, but have to `eval`.
|
||||
*/
|
||||
try {
|
||||
args = JSON.parse('[' + match[2] + ']');
|
||||
|
|
@ -61,21 +61,19 @@ Ox.load('Image', function() {
|
|||
args = [eval('f = ' + match[2])];
|
||||
}
|
||||
/*
|
||||
The <code>src</code> and <code>encode</code> methods are
|
||||
asynchronous and take a callback function.
|
||||
The `src` and `encode` methods are asynchronous and take a callback
|
||||
function.
|
||||
*/
|
||||
if (fn == 'src' || fn == 'encode') {
|
||||
image[fn].apply(null, args.concat(function(image) {
|
||||
$image.attr({src: image.src()});
|
||||
}));
|
||||
/*
|
||||
The <code>decode</code> method is asynchronous too, and its callback
|
||||
function gets passed a string.
|
||||
The `decode` method is asynchronous too, and its callback function
|
||||
gets passed a string.
|
||||
*/
|
||||
} else if (fn == 'decode') {
|
||||
image[fn].apply(null, args.concat(function(str) {
|
||||
alert(str);
|
||||
}));
|
||||
image[fn].apply(null, args.concat(alert));
|
||||
/*
|
||||
All other methods simply return the image.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue