<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,10 +1,9 @@
 /* 
  * Author: Oliver Steele
- * Copyright: Copyright 2007 by Oliver Steele.  All rights reserved.
+ * Copyright: Copyright 2007-2008 by Oliver Steele.  All rights reserved.
  * License: MIT License
  * Homepage: http://osteele.com/javascripts/functional
  * Created: 2007-07-15
- * Modified: 2007-07-21
  */
 
 Functional.install();
@@ -74,13 +73,16 @@ Evaluator.prototype.observeElements = function() {
     $(elements.evalButton).click(eval);
 }
 
-Evaluator.prototype.eval = function(text) {
+Evaluator.prototype.eval = function(textOrNode) {
     var elements = this.elements,
         inputElement = elements.input,
         outputElement = elements.output,
         transcriptElements = elements.transcript;
-    if (arguments.length &lt; 1)
-        text = inputElement.value.strip().replace('\n', '');
+    var text = arguments.length &lt; 1
+        ? inputElement.value.strip().replace('\n', '')
+        : typeof textOrNode == 'string'
+        ? textOrNode
+        : $(textOrNode).text()
     inputElement.value = text;
     Evaluator.scope = this.scope = this.scope || {};
     text = text.replace(/^\s*var\s+/, 'Evaluator.scope.');
@@ -113,6 +115,7 @@ Evaluator.prototype.eval = function(text) {
     }
     this.lastRecord = {input: text, output: html};
     this.options.onUpdate &amp;&amp; this.options.onUpdate();
+    return value;
 }
 
 Evaluator.toString = function(value) {</diff>
      <filename>evaluator.js</filename>
    </modified>
    <modified>
      <diff>@@ -250,7 +250,8 @@ trace([1, 2, 3].map('x*x'.lambda()).map('x+1'.lambda()));
 
 // Define an `onclick` function that abbreviates `Event.observe(_, 'click', ...)`:
 var onclick = Event.observe.bind(Event).partial(_, 'click');
-// These next three statements are parallel in their effect:
-Event.observe('e1', 'click', function(){alert('1')});
-onclick('e2', function(){alert('2')});
+// These next three statements have the same effect.  Click on a
+// of the buttons to execute the corresponding function.
+Event.observe('e1', 'click', function(){ alert('1'); });
+onclick('e2', function(){ alert('2'); });
 onclick('e3', alert.bind(null).saturate('3'));</diff>
      <filename>examples.js</filename>
    </modified>
    <modified>
      <diff>@@ -1,13 +1,11 @@
-/* Copyright 2007 by Oliver Steele.  Available under the MIT License. */
-
-var gEvaluator;
+/* Copyright 2007-2008 by Oliver Steele.  Available under the MIT License. */
 
 $(function() {
     new DocViewer({api:['functional.js', 'to-function.js'],
                    examples:'examples.js',
                    onLoad:loaded});
     function loaded() {
-        gEvaluator = new Evaluator('#evaluator', {onUpdate: showEvaluator});
+        var evaluator = new Evaluator('#evaluator', {onUpdate: showEvaluator});
         ieMode();
         if (navigator.appName != 'Microsoft Internet Explorer')
             $('#header pre').each(function() {
@@ -16,12 +14,11 @@ $(function() {
         $('#evaluator').show();
         resetGradients();
         $(window).resize(scheduleGradientReset);
+        $('.example kbd').click(function() { evaluator.eval(this) });
         $('.protodoc kbd').click(function() {
-            gEvaluator.eval($(this).text());
-            $.scrollTo($('#evaluator'), {speed:1000});
-        });
-        $('.example kbd').click(function() {
-            gEvaluator.eval($(this).text());
+            var value = evaluator.eval(this);
+            typeof value == 'undefined' ||
+                $.scrollTo($('#evaluator'), {speed:1000});
         });
     }
 });
@@ -38,3 +35,11 @@ function ieMode() {
     e.show();
     $('#ie-warning .close').click(function() {this.hide});
 }
+
+// Emulate enough of Prototype for the example to work
+var Event = {
+    observe: function(elt, handlerName, handler) {
+        var e = $(typeof elt == 'string' ? '#' + elt : elt);
+        e[handlerName].call(e, handler);
+    }
+}</diff>
      <filename>index.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>2bacadc26c1c4c2d4801bb51fc1944bf4636357f</id>
    </parent>
  </parents>
  <author>
    <name>Oliver Steele</name>
    <email>steele@osteele.com</email>
  </author>
  <url>http://github.com/osteele/functional-javascript/commit/ae6c9613cd5a4fedc1e7cd51c06ca269d0205245</url>
  <id>ae6c9613cd5a4fedc1e7cd51c06ca269d0205245</id>
  <committed-date>2008-02-14T11:08:07-08:00</committed-date>
  <authored-date>2008-02-14T11:08:07-08:00</authored-date>
  <message>emulate Prototype, for examples</message>
  <tree>4c7519a112a021263d462a017fcc41cf935443b1</tree>
  <committer>
    <name>Oliver Steele</name>
    <email>steele@osteele.com</email>
  </committer>
</commit>
