Reputation: 20448
I'm trying to follow this tutorial
http://eloquentjavascript.net/chapter8.html
It mentions a function inPlacePrinter
. I cannot find the source code for this in the actual text. I have tried poking around in view source since the interactive version seems to work but cannot locate the raw code. How do I find it?
Upvotes: 0
Views: 205
Reputation: 409
In oo.js there is this line:
var div = __ENV.parent.DIV();
__ENV is not defined elsewhere, nor in any of the other js files, maybe is part of the MochiKit framework used on page.
You can replace inPlacePrinter() with this 2 functions in order to show the output in browser console:
function show(x){
var show = "";
for (var y = 0; y < arguments.length; y++) {
show += arguments[y];
}
console.log(show);
}
function showTerrarium(terrarium){
this.show(terrarium);
return function() {
console.clear();
this.showTerrarium(terrarium);
}
}
And used them in this way
/*replace:*/ terrarium.onStep = partial(inPlacePrinter(), terrarium);
/*with:*/ terrarium.onStep = partial(showTerrarium(terrarium), terrarium);
Maybe there is a better solution, but this worked.
Upvotes: 2
Reputation: 21996
Try using something like Firebug to look at the JavaScript files.
Upvotes: 0
Reputation: 1777
thats a big tutorial. About half way down the page is this statement:
But all these extra variables can get messy. Another good solution is to use a function similar to partial from chapter 6. Instead of adding arguments to a function, this one adds a this object, using the first argument to the function's apply method:
Is the function inPlacePrinter in the object called partial in chapter 6?
Upvotes: 0