Visualize: render one report

Test plugins

HTML

<script src="http://code.jquery.com/jquery-2.1.0.js"></script>
<!--Provide URL to visualize.js-->
<script>
    function ScopeChecker(scope) {
        this.scope = scope;
    }

    ScopeChecker.prototype.getPropertiesCount = function() {
        return this.getPropertiesNames().length;
    };

    ScopeChecker.prototype.getPropertiesNames = function() {
        var allPropertyNames = Object.keys(this.scope);
        var propertyNames = [];

        for (var i = 0; i < allPropertyNames.length; i++) {
            var propertyName = allPropertyNames[i];

            // Remove property names which properties were removed from scope (assigned to undefined).
            if (this.scope[propertyName]) {
                propertyNames.push(propertyName);
            }
        }

        return propertyNames;
    };

    ScopeChecker.prototype.compareProperties = function(scope1PropertiesNames, scope2PropertiesNames) {
        if (!scope1PropertiesNames) {
            throw "Properties for scope 1 not specified";
        }
        if (!scope2PropertiesNames) {
            scope2PropertiesNames = this.getPropertiesNames();
        }

        var comparisonResult = {
            added: [],
            removed: [],
            polutions : []
        };

        var i = 0,
            j = 0;
        for (i = 0; i < scope1PropertiesNames.length; i++) {
            comparisonResult.removed.push(scope1PropertiesNames[i]);
            for (j = 0; j < scope2PropertiesNames.length; j++) {
                if (scope1PropertiesNames[i] === scope2PropertiesNames[j]) {
                    comparisonResult.removed.pop();
                    break;
                }
            }
        }

        for (i = 0; i < scope2PropertiesNames.length; i++) {
            comparisonResult.added.push(scope2PropertiesNames[i]);
            for (j = 0; j < scope1PropertiesNames.length; j++) {
                if (scope2PropertiesNames[i] === scope1PropertiesNames[j]) {
                   ...

JavaScript

visualize({
    auth: {
        name: "jasperadmin",
        password: "jasperadmin",
        organization: "organization_1"
    }
}, function (v) {   
    
    createReport();
    
    $("#selected_resource").change(function () {
        //clean container
        $("#container").html("");
        createReport();
    });
    
     //enable report chooser
    $(':disabled').prop('disabled', false);
    
     function createReport(){
        //render report from another resource
        v("#container").report({
            resource: $("#selected_resource").val(),
            success: function(){
                 setTimeout(function () {
                    console.log("------------------Scope Check Results---------------------------");
                    console.log(scopeChecker.compareProperties(propertiesNames));
                    console.log("----------------------------------------------------------------");
                }, 5000);
            },
            error:handleError
        });
    }
        
    //show error
    function handleError(err){
        alert(err.message);
    }
    
});