<commit_before>var lizSearch = function() {

    // Attributes
    var config = null;
    var map = null;

    function startExternalSearch() {
        $('#lizmap-search .items li > a').unbind('click');
        $('#lizmap-search .items').html( '<li class="start"><ul><li>'+lizDict['externalsearch.search']+'</li></ul></li>' );
        $('#lizmap-search, #lizmap-search-close').addClass('open');
    }

    function updateExternalSearch( aHTML ) {
        var wgs84 = new OpenLayers.Projection('EPSG:4326');

        $('#lizmap-search .items li > a').unbind('click');
        if ( $('#lizmap-search .items li.start').length != 0 )
            $('#lizmap-search .items').html( aHTML );
        else
            $('#lizmap-search .items').append( aHTML );
        $('#lizmap-search, #lizmap-search-close').addClass('open');
        $('#lizmap-search .items li > a').click(function() {
            var bbox = $(this).attr('href').replace('#','');
            var bbox = OpenLayers.Bounds.fromString(bbox);
            bbox.transform(wgs84, map.getProjectionObject());
            map.zoomToExtent(bbox);

            var feat = new OpenLayers.Feature.Vector(bbox.toGeometry().getCentroid());
            var data = $(this).attr('data');
            if ( data ) {
                var geom = OpenLayers.Geometry.fromWKT(data);
                geom.transform(wgs84, map.getProjectionObject());
                feat = new OpenLayers.Feature.Vector(geom);
            }

            var locateLayer = map.getLayersByName('locatelayer');
            if (locateLayer.length != 0) {
                locateLayer = locateLayer[0];
                locateLayer.destroyFeatures();
                locateLayer.setVisibility(true);
                locateLayer.addFeatures([feat]);
            }

            $('#lizmap-search, #lizmap-search-close').removeClass('open');
            return false;
        });
        $('#lizmap-search-close button').click(function() {
            $('#lizmap-search, #lizmap-search-close').removeClass('open');
            return false;
        });
    }

    function getHighlightRegEx() {
        // Format answers to highlight searched keywords
        var sqval = $('#search-query').val();
        var sqvals = sqval.split(' ');
        var sqvalsn = [];
        var sqrex = '(';
        for(var i in sqvals){
            var sqi = sqvals[i].trim();
            if( sqi == '' ){continue;}
            sqvalsn.push(sqi);<commit_msg>JS - Search: add event when item is selected lizmapexternalsearchitemselected<commit_after>var lizSearch = function() {

    // Attributes
    var config = null;
    var map = null;

    function startExternalSearch() {
        $('#lizmap-search .items li > a').unbind('click');
        $('#lizmap-search .items').html( '<li class="start"><ul><li>'+lizDict['externalsearch.search']+'</li></ul></li>' );
        $('#lizmap-search, #lizmap-search-close').addClass('open');
    }

    function updateExternalSearch( aHTML ) {
        var wgs84 = new OpenLayers.Projection('EPSG:4326');

        $('#lizmap-search .items li > a').unbind('click');
        if ( $('#lizmap-search .items li.start').length != 0 )
            $('#lizmap-search .items').html( aHTML );
        else
            $('#lizmap-search .items').append( aHTML );
        $('#lizmap-search, #lizmap-search-close').addClass('open');
        $('#lizmap-search .items li > a').click(function() {
            var bbox = $(this).attr('href').replace('#','');
            var bbox = OpenLayers.Bounds.fromString(bbox);
            bbox.transform(wgs84, map.getProjectionObject());
            map.zoomToExtent(bbox);

            var feat = new OpenLayers.Feature.Vector(bbox.toGeometry().getCentroid());
            var data = $(this).attr('data');
            if ( data ) {
                var geom = OpenLayers.Geometry.fromWKT(data);
                geom.transform(wgs84, map.getProjectionObject());
                feat = new OpenLayers.Feature.Vector(geom);
            }

            var locateLayer = map.getLayersByName('locatelayer');
            if (locateLayer.length != 0) {
                locateLayer = locateLayer[0];
                locateLayer.destroyFeatures();
                locateLayer.setVisibility(true);
                locateLayer.addFeatures([feat]);
            }

            $('#lizmap-search, #lizmap-search-close').removeClass('open');
            // trigger event containing selected feature
            lizMap.events.triggerEvent('lizmapexternalsearchitemselected',
                {
                    'feature': feat
                }
            );
            return false;
        });
        $('#lizmap-search-close button').click(function() {
            $('#lizmap-search, #lizmap-search-close').removeClass('open');
            return false;
        });
    }

    function getHighlightRegEx() {
        // Format answers to highlight searched keywords
        var sqval = $('#search-query').val();
        var sqvals = sqval.split(' ');
        var sqvalsn = [];
        var sqrex = '(';
        for(var i in sqvals){
            var sqi = sqvals[i].trim();
            if( sqi == '' ){continue;}
            sqvalsn.push(sqi);
{'fraction_non_alphanumeric': 0.16232387569967188, 'fraction_numerical': 0.005018336228527312, 'mean_word_length': 2.053624042427814, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, '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': '2096445', 'n_tokens_mistral': 1526, 'n_tokens_neox': 1496, 'n_words': 269}