<commit_before>'use strict';

var orgJGrapesOsgiPortletsServices = {
    l10n: {
        "serviceAbbrevDS": "${_("serviceAbbrevDS")}",
        "serviceBundle": "${_("serviceBundle")}",
        "serviceImplementedBy": "${_("serviceImplementedBy")}",
        "serviceRanking": "${_("serviceRanking")}",
        "serviceScope": "${_("serviceScope")}",
        "serviceScopeBundle": "${_("serviceScopeBundle")}",
        "serviceScopePrototype": "${_("serviceScopePrototype")}",
        "serviceScopeSingleton": "${_("serviceScopeSingleton")}",
    }
};

(function() {

    var l10n = orgJGrapesOsgiPortletsServices.l10n;
    
    function createTooltip(service) {
        let tooltip = '<div>';
        tooltip += '<table><tbody>';
        tooltip += '<tr><td>' + l10n.serviceBundle + ':</td>';
        tooltip += '<td>' + service.bundleName + ' (' + service.bundleId + ')</td></tr>';
        tooltip += '<tr><td>' + l10n.serviceScope + ':</td>';
        tooltip += '<td>' + l10n[service.scope];
        if (service.dsScope !== undefined) {
            tooltip += " (" + l10n.serviceAbbrevDS + ": " + l10n[service.dsScope] + ")";
        }
        tooltip += '</td></tr>';
        tooltip += '<tr><td>' + l10n.serviceImplementedBy + ':</td>';
        tooltip += '<td>' + service.implementationClass + '</td></tr>';
        tooltip += '<tr><td>' + l10n.serviceRanking + ':</td>';
        tooltip += '<td>' + service.ranking + '</td></tr>';
        tooltip += '</tbody></table></div>';
        return tooltip;
    }

    function registerTooltip(row, serviceInfo) {
        row.data("serviceInfo", serviceInfo);
        row.tooltip({
            items: "[data-service-id]",
            content: function() {
                return createTooltip($( this ).data("serviceInfo"));
            },
            classes: {
                "ui-tooltip": "ui-corner-all ui-widget-shadow jgrapes-osgi-services-preview-tooltip"
            }
        });
    }
    
    orgJGrapesOsgiPortletsServices.initPreviewTable = function(tableSelector) {
        JGPortal.lockMessageQueue();
        let table = tableSelector.DataTable( {
            "initComplete": function( settings, json ) {
                tableSelector.DataTable().processing(true);
                JGPortal.unlockMessageQueue();
            },
            "columns": [ 
                { "data": "id" },
                { "data": "type",
                  "render": function(data, type, row, meta) {
                      return data.replace(/\./g, '.&#x200b;');
                  }
                },
            ],
            "searching": false,
            "paging": false,
            "info": false,
            "dom": "t",
            "rowCallback": function( row, data, dataIndex ) {
                $(row).attr("data-service-id", data.id);
                registerTooltip($(row), data);<commit_msg>Cleanup tooltip duplicates.<commit_after>'use strict';

var orgJGrapesOsgiPortletsServices = {
    l10n: {
        "serviceAbbrevDS": "${_("serviceAbbrevDS")}",
        "serviceBundle": "${_("serviceBundle")}",
        "serviceImplementedBy": "${_("serviceImplementedBy")}",
        "serviceRanking": "${_("serviceRanking")}",
        "serviceScope": "${_("serviceScope")}",
        "serviceScopeBundle": "${_("serviceScopeBundle")}",
        "serviceScopePrototype": "${_("serviceScopePrototype")}",
        "serviceScopeSingleton": "${_("serviceScopeSingleton")}",
    }
};

(function() {

    var l10n = orgJGrapesOsgiPortletsServices.l10n;
    
    function createTooltip(service) {
        let tooltip = '<div>';
        tooltip += '<table><tbody>';
        tooltip += '<tr><td>' + l10n.serviceBundle + ':</td>';
        tooltip += '<td>' + service.bundleName + ' (' + service.bundleId + ')</td></tr>';
        tooltip += '<tr><td>' + l10n.serviceScope + ':</td>';
        tooltip += '<td>' + l10n[service.scope];
        if (service.dsScope !== undefined) {
            tooltip += " (" + l10n.serviceAbbrevDS + ": " + l10n[service.dsScope] + ")";
        }
        tooltip += '</td></tr>';
        tooltip += '<tr><td>' + l10n.serviceImplementedBy + ':</td>';
        tooltip += '<td>' + service.implementationClass + '</td></tr>';
        tooltip += '<tr><td>' + l10n.serviceRanking + ':</td>';
        tooltip += '<td>' + service.ranking + '</td></tr>';
        tooltip += '</tbody></table></div>';
        return tooltip;
    }

    function registerTooltip(row, serviceInfo) {
        row.data("serviceInfo", serviceInfo);
        row.tooltip({
            items: "[data-service-id]",
            content: function() {
                return createTooltip($( this ).data("serviceInfo"));
            },
            classes: {
                "ui-tooltip": "ui-corner-all ui-widget-shadow jgrapes-osgi-services-preview-tooltip"
            },
            close: function() {
                // https://bugs.jqueryui.com/ticket/10689
                $(".ui-helper-hidden-accessible > *:not(:last)").remove();
            },
        });
    }
    
    orgJGrapesOsgiPortletsServices.initPreviewTable = function(tableSelector) {
        JGPortal.lockMessageQueue();
        let table = tableSelector.DataTable( {
            "initComplete": function( settings, json ) {
                tableSelector.DataTable().processing(true);
                JGPortal.unlockMessageQueue();
            },
            "columns": [ 
                { "data": "id" },
                { "data": "type",
                  "render": function(data, type, row, meta) {
                      return data.replace(/\./g, '.&#x200b;');
                  }
                },
            ],
            "searching": false,
            "paging": false,
            "info": false,
            "dom": "t",
            "rowCallback": function( row, data, dataIndex ) {
                $(row).attr("data-service-id", data.id);
                registerTooltip($(row), data);
{'fraction_non_alphanumeric': 0.18505338078291814, 'fraction_numerical': 0.00864260294865277, 'mean_word_length': 2.0580310880829016, 'pattern_counts': {'":': 40, '<': 63, '<?xml version=': 0, '>': 64, 'https://': 1, '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': '6445772', 'n_tokens_mistral': 1750, 'n_tokens_neox': 1657, 'n_words': 280}