ALL HOW TOs




debugging

alerts

debugger;
alert('whatever'+whatever.val);

NOTE: alerts won't happen unless the debugger; statement precedes them.  Only need once in a javascript file.

inspect object

function xinspect(o,i){
    if(typeof i=='undefined')i='';
    if(i.length>5)return '[MAX ITERATIONS]';
    var r=[];
    for(var p in o){
        var t=typeof o[p];
        r.push(i+'"'+p+'" ('+t+') => '+(t=='object' ? 'object:'+xinspect(o[p],i+'  ') : o[p]+''));
    }
    return r.join(i+'\n');
}
 
// example of use:
alert(xinspect(this));

Ref for [debugging in Firefox using FireBug](https://thecodecentral.com/2007/08/01/debug-javascript-with-firebug).  I wasn't able to get this to work because none of the Hyrax scripts how up in the script tab of FireBug.  Best I can tell, none of the scripts have type=text/javascript as part of the <script> tag.



Testing:

Hyrax uses jasmine for javascript testing.

See Developers guide on Running javascript tests for more info.


  • No labels