[Bps-public-commit] r12663 - pie/branches/named-params/pieplate/PIE-Plate/share/web/static/js

jesse at bestpractical.com jesse at bestpractical.com
Sat May 24 05:29:59 EDT 2008


Author: jesse
Date: Sat May 24 05:29:52 2008
New Revision: 12663

Modified:
   pie/branches/named-params/pieplate/PIE-Plate/share/web/static/js/pieui.js

Log:
checkpoint

Modified: pie/branches/named-params/pieplate/PIE-Plate/share/web/static/js/pieui.js
==============================================================================
--- pie/branches/named-params/pieplate/PIE-Plate/share/web/static/js/pieui.js	(original)
+++ pie/branches/named-params/pieplate/PIE-Plate/share/web/static/js/pieui.js	Sat May 24 05:29:52 2008
@@ -14,18 +14,24 @@
     jQuery(ret)
     .html(this.name+': '+this.toString() );
 //      .click(function () { alert (that.name) });
+    jQuery(ret).createAppend('div', { className: 'name'} , [this.name]);
+    ret = jQuery(ret).createAppend('div', { className: 'lorzy-code-args'});
+
+
 
     jQuery.each(this.args, function(name, exp) {
         console.log(name +  ": "+exp);
         var entry = ret.createAppend('div', { className: that.name+' '+name });
         entry.addClass('lorzy-code-arg');
-        jQuery(entry).html(name);
+        entry.createAppend('div', { className: 'name'}, [ name]);
+        var value = entry.createAppend('div', { className: 'value'});
         if (typeof(exp) == 'string') {
-            lorzy_show_expression_str(exp, entry);
+            lorzy_show_expression_str(exp, value);
             return;
-        }
+        } else {
         console.log(typeof(exp));
-        lorzy_show_expression.apply(exp, [entry]);
+        lorzy_show_expression.apply(exp, [value]); //[entry]);
+        }
     });
 
 }
@@ -34,7 +40,48 @@
     jQuery(ops).each(
         function() {
             lorzy_show_expression.apply(this, [jQuery('#wrapper')]);
+            
         });
+        var tree = lorzy_generate_struct(jQuery('#wrapper'));
+        console.log(tree.toJSON());
+//    jQuery('#wrapper').after(jQuery('<a href="#">Traverse</a>').attr('id', 'clicky'));
+    
+ //   jQuery('#clicky').click(function () { lorzy_generate_struct(jQuery('#wrapper'))});
 };
 
+function lorzy_generate_struct(parent) {
+
+      var ops = jQuery(parent).children();
+     var tree=    jQuery.map(ops, function (op) {
+
+            if( jQuery(op).hasClass('lorzy-code')) {
+                
+                var codeargs =  jQuery(op).children('.lorzy-code-args').children();
+                return { 'name': jQuery(op).children('.name').text(), 'args': lorzy_generate_args_struct(codeargs)  };
+            } else if (jQuery(op).hasClass('lorzy-const')) {
+               return jQuery(op).text();
+            }else  {
+                    console.log('dunno what to do with' + jQuery(op).content);
+            }
+       }
+
+        );
+   
+    return tree;
+
+                    //#lorzy_generate_struct(op)]:
+
+};
+
+
+
+
+function lorzy_generate_args_struct(args) {
+    var myArray = {};
+     jQuery.map(args, function (op)  {
+               myArray[ jQuery(op).children('.name').text() ] =  lorzy_generate_struct(jQuery(op).children('.value').get(0));
+    });
+
+    return myArray;
+}
 



More information about the Bps-public-commit mailing list