<commit_before>$(function () {

    $(".navigation ul li.active").removeClass('active');
    var prev = $(".navigation ul li:first");
    $(".purple").insertBefore(prev).css('top','0px').addClass('active');

    var searchApis = function(query){
        if(!query) query = {};
        var swaggerClient = new SwaggerClient({
            url: swaggerURL,
            success: function (swaggerData) {
                //TODO:Need to have a proper fix from swagger definition retrieval service
                setAuthHeader(swaggerClient);
                swaggerClient["API Collection"].get_apis(query,
                    {"responseContentType": 'application/json'},
                    function (jsonData) {
                        var callbacks = {
                            onSuccess: function () {
                                $(".setbgcolor").generateBgcolor({
                                    definite: true
                                });

                                $(".api-name-icon").each(function () {
                                    var elem = $(this).next().children(".api-name");
                                    $(this).nametoChar({
                                        nameElement: elem
                                    });
                                });
                            }, onFailure: function (message, e) {
                            }
                        };
                        var mode = "OVERWRITE";
                        //Render APIs listing page
                        UUFClient.renderFragment("org.wso2.carbon.apimgt.web.store.feature.api-listing", jsonData.obj,
                            "api-listing", mode, callbacks);
                    },
                    function (error) {
                        if (error.status == 401) {
                            redirectToLogin(contextPath);
                        }
                    }
                );

            },
            failure: function (error) {
                console.log("Error occurred while loading swagger definition");
            }
        });

    };
    /*
    Generate a backend friendly search query base on user input.
     */
    var generateQuery = function(){
        //Get the user search input
        var queryInput = $('#searchApiQuery').val();
        var query = "";
        //Get the lifecycle dropdown selection
        var searchApiLifecycle = $('#searchApiLifecycle').val();

        if(searchApiLifecycle != ""){
            query = "current_lc_status:"+searchApiLifecycle;
        }

        //When All is not selected on the dropdown we get rid of the full text search and append the name: param at the front
        if(queryInput != "" && queryInput.search(":") == -1 && searchApiLifecycle != "" ) {
            query =  "name:" + queryInput + "," + query;
        } else if(queryInput != "" && queryInput.search(":") != -1 && searchApiLifecycle != "" ){
            query =  queryInput + "," + query;
        } else if(queryInput != "" && searchApiLifecycle == "" ){
            query = queryInput;
        }
        return query;
    };
    $("#searchApiQuery").on('keyup', function (e) {
        if (e.keyCode == 13) {
            searchApis({query:generateQuery()});
        }
    });

    $('#searchApi').click(function () {
        searchApis({query:generateQuery()});
    });

    $('#searchApiLifecycleList li a').click(function(){
        $('#searchApiLifecycle').val($(this).attr('data-lifecycle'));
    });

    searchApis();

});<commit_msg>Store search when type is selected from the drop down list<commit_after>$(function () {

    $(".navigation ul li.active").removeClass('active');
    var prev = $(".navigation ul li:first");
    $(".purple").insertBefore(prev).css('top','0px').addClass('active');

    var searchApis = function(query){
        if(!query) query = {};
        var swaggerClient = new SwaggerClient({
            url: swaggerURL,
            success: function (swaggerData) {
                //TODO:Need to have a proper fix from swagger definition retrieval service
                setAuthHeader(swaggerClient);
                swaggerClient["API Collection"].get_apis(query,
                    {"responseContentType": 'application/json'},
                    function (jsonData) {
                        var callbacks = {
                            onSuccess: function () {
                                $(".setbgcolor").generateBgcolor({
                                    definite: true
                                });

                                $(".api-name-icon").each(function () {
                                    var elem = $(this).next().children(".api-name");
                                    $(this).nametoChar({
                                        nameElement: elem
                                    });
                                });
                            }, onFailure: function (message, e) {
                            }
                        };
                        var mode = "OVERWRITE";
                        //Render APIs listing page
                        UUFClient.renderFragment("org.wso2.carbon.apimgt.web.store.feature.api-listing", jsonData.obj,
                            "api-listing", mode, callbacks);
                    },
                    function (error) {
                        if (error.status == 401) {
                            redirectToLogin(contextPath);
                        }
                    }
                );

            },
            failure: function (error) {
                console.log("Error occurred while loading swagger definition");
            }
        });

    };
    /*
    Generate a backend friendly search query base on user input.
     */
    var generateQuery = function(){
        //Get the user search input
        var queryInput = $('#searchApiQuery').val();
        var query = "";
        //Get the lifecycle dropdown selection
        var searchApiLifecycle = $('#searchApiLifecycle').val();

        if(searchApiLifecycle != ""){
            query = "current_lc_status:"+searchApiLifecycle;
        }

        //When All is not selected on the dropdown we get rid of the full text search and append the name: param at the front
        if(queryInput != "" && queryInput.search(":") == -1 && searchApiLifecycle != "" ) {
            query =  "name:" + queryInput + "," + query;
        } else if(queryInput != "" && queryInput.search(":") != -1 && searchApiLifecycle != "" ){
            query =  queryInput + "," + query;
        } else if(queryInput != "" && searchApiLifecycle == "" ){
            query = queryInput;
        }
        return query;
    };
    $("#searchApiQuery").on('keyup', function (e) {
        if (e.keyCode == 13) {
            searchApis({query:generateQuery()});
        }
    });

    $('#searchApi').click(function () {
        searchApis({query:generateQuery()});
    });

    $('#searchApiLifecycleList li a').click(function(){
        $('#searchApiLifecycle').val($(this).attr('data-lifecycle'));
        searchApis({query:generateQuery()});
    });

    searchApis();

});
{'fraction_non_alphanumeric': 0.13173318448227742, 'fraction_numerical': 0.0025118615685180016, 'mean_word_length': 1.3779031187790312, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4827148', 'n_tokens_mistral': 1747, 'n_tokens_neox': 1656, 'n_words': 375}