tosenzzz / trimpath

Automatically exported from code.google.com/p/trimpath
0 stars 0 forks source link

breakpoint variable dump inspect functions #25

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I'm sure these could be improved,  maybe put in hierarchical data format:

    /*
     * use like this:  
     * type the following into the command textbox for breakpoint:
     * 
     *   alert( TrimPath.inspect( document ) )
     */

    var inspect = TrimPath.inspect = function(obj) { 

       var report_str = "";
       k = 1;
       for ( var key in obj ) {     
        nlchar = (( k % 3 )==0)?'\n':'..........';
        if ( obj.getAttribute ) {
            report_str += key + ": " + obj.getAttribute(key) + nlchar; //IE
        } else {
            report_str += key + ": " + obj[key] + nlchar; //Firefox
        }
        k++;
       }
       return report_str;
    }

    /*
     * use like this:  
     * type the following into the command textbox for breakpoint:
     * 
     *   alert( TrimPath.inspectStyle( window.document.body ) )
     */ 

     var inspectStyle = TrimPath.inspectStyle = function(elm){
      if (elm.style){
        var str = "";
        k = 1;
        for (var i in elm.style){
          nlchar = (( k % 3 )==0)?'\n':'..........';
          str += i + ": " + elm.style[i] + nlchar;
          k++;
        }
        return str;
      }
    }

Original issue reported on code.google.com by kucerari...@gmail.com on 20 May 2009 at 3:07

GoogleCodeExporter commented 8 years ago
Here's my recent modifier,  stolen from prototypejs and JST-ified,  dumped here 
until
I get on the trimpath project.  The problem is mailto: links are finally broken 
if
the amount of data you try to stuff in them gets too large,  had to truncate a
description parameter to 150 chars:

var detail_results_container_temp = { matter: results[0], status_history:
resultsStatusHistory };

var myModifiers = {
            truncate : function(str, length, truncation) {
                length = length || 30;
                truncation = (truncation==undefined) ? '...' : truncation;
                return str.length > length ?
                  str.slice(0, length - truncation.length) + truncation : str;
              }
        };

detail_results_container_temp._MODIFIERS = myModifiers;

var email_detail_body_stuff =
this.parsedEmailDetailBodyTemplate.process(detail_results_container_temp);

Original comment by kucerari...@gmail.com on 18 Jun 2009 at 3:49

GoogleCodeExporter commented 8 years ago
I am attaching a very handy javascript Dump lib that I found.  Have used it in
production enterprise portlet development.  Just like PHP var_dump().

For example see that alert:

    this.viewer_settings_data = YAHOO.lang.JSON.parse(viewerSettingStr);
        //alert( "restored: "+Dumper( this.viewer_settings_data ) );

Original comment by kucerari...@gmail.com on 8 Jul 2009 at 4:52

Attachments: