<commit_before>console.log('devtools.js');

chrome.devtools.panels.create('Backbase', 'backbase.png', 'panel.html', function(panel) {
    panel.onHidden.addListener(function() {
        chrome.devtools.inspectedWindow.eval(`
                document.body.removeChild(document.getElementById('ivo-bobul'));
            `)
    });
});

chrome.devtools.panels.elements.createSidebarPane('Backbase Item Model', function(sidebar) {

    var getInfo = function (){
        var propertyList = ['Description','TemplateName','templateUrl','title','version'];
        var dataList = ['contextItemName','extendedItemName','name','securityProfile'];
        var elm, pref, key;
        var obj = {};
        var errorMSg = {message : 'This element do not have a widget content'};
        obj.preference = {};

        if ($0.closest("[data-pid]") == null) {
            errorMSg;
        } else {
            elm = b$.portal.portalModel.all[$0.closest("[data-pid]").attributes['data-pid'].value];
            pref = elm.attributes;

            // get preference
            for (key in pref) {
                if (propertyList.indexOf(pref[key].localName) > -1 ){
                    obj.preference[pref[key].localName] = pref[key].nodeValue;
                }
            }
            //get other information
            for (key in elm) {
                if (dataList.indexOf(key) > -1 ){
                    obj[key] = elm[key];
                }
            }
            obj;
        }
    };

    function update() {
        sidebar.setExpression(getInfo.toString().match(/function[^{]+\{([\s\S]*)\}$/)[1]);<commit_msg>Use the same structure for the sidebar pane in elements as in Backbase panel<commit_after>console.log('devtools.js');

chrome.devtools.panels.create('Backbase', 'backbase.png', 'panel.html', function(panel) {
    panel.onHidden.addListener(function() {
        chrome.devtools.inspectedWindow.eval(`
                document.body.removeChild(document.getElementById('ivo-bobul'));
            `)
    });
});

chrome.devtools.panels.elements.createSidebarPane('Backbase Item Model', function(sidebar) {
    var GET_ITEM_MODEL_EXPRESSION = `
        (function() {
            function getComponentsTree(node) {
                return {
                    name: node.name,
                    type: node.tagName,
                    parent: node.parentItemName,
                    contextItemName: node.contextItemName,
                    extendedItemName: node.extendedItemName,
                    preferences: node.preferences.array.map(formatItemPreference),
                    tags: node.tags.map(formatItemTag)
                };
            }

            function formatItemPreference(preference) {
                return {
                    name: preference.name,
                    label: preference.label,
                    value: preference.value,
                    viewHint: preference.viewHint
                }
            }

            function formatItemTag(tag) {
                return {
                    name: tag.value,
                    type: tag.type
                }
            }

            var bbItemNode = $0.closest("[data-pid]");
            if (bbItemNode) {
                return getComponentsTree(b$.portal.portalModel.all[bbItemNode.attributes['data-pid'].value]);
            } else {
                return {
                    message: "This element doesn't have associated Backbase Item"
                };
            }
        }());
    `;

    function update() {
        sidebar.setExpression(GET_ITEM_MODEL_EXPRESSION);
{'fraction_non_alphanumeric': 0.12461752433936023, 'fraction_numerical': 0.0016689847009735744, 'mean_word_length': 1.7242424242424241, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7264662', 'n_tokens_mistral': 975, 'n_tokens_neox': 930, 'n_words': 157}