// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
$(document).ready(function() {
/* Activating Best In Place */
jQuery(".best_in_place").best_in_place()
});
function inspect(obj, maxLevels, level)
{
var str = '', type, msg;
// Start Input Validations
// Don't touch, we start iterating at level zero
if(level == null) level = 0;
// At least you want to show the first level
if(maxLevels == null) maxLevels = 1;
if(maxLevels < 1)
return 'Error: Levels number must be > 0';
// We start with a non null object
if(obj == null)
return 'Error: Object NULL';
// End Input Validations
// Each Iteration must be indented
str += '
';
// Start iterations for all objects in obj
for(property in obj)
{
try
{
// Show "property" and "type property"
type = typeof(obj[property]);
str += '- (' + type + ') ' + property +
( (obj[property]==null)?(': null'):('')) + '
';
// We keep iterating if this property is an Object, non null
// and we are inside the required number of levels
if((type == 'object') && (obj[property] != null) && (level+1 < maxLevels))
str += inspect(obj[property], maxLevels, level+1);
}
catch(err)
{
// Is there some properties in obj we can't access? Print it red.
if(typeof(err) == 'string') msg = err;
else if(err.message) msg = err.message;
else if(err.description) msg = err.description;
else msg = 'Unknown';
str += '- (Error) ' + property + ': ' + msg +'
';
}
}
// Close indent
str += '
';
var container = $("").html(str);
container.purr({isSticky:true});
return str;
}