<commit_before>/*
  Live searching on repositories
*/
if (!Gitorious)
    var Gitorious = {};

$(document).ready(function () {
    var searchContainer = jQuery("#repo_search");
    var searchUri = searchContainer.attr("gts:searchUri");

    var backend = {get: function (uri, phrase, callback){
        jQuery.getJSON(uri + phrase, function(data) {
            callback(data);
        });
    }}
    /*
      Renderer for rendering repositories as search results
     */
    var renderer = {
        // Should return something that can be appended to a jQuery object
        render: function(repo) {
            row = jQuery('<li class="clone"></li>');

            repo_title = repo.description || repo.name

            title = jQuery('<div class="name"><a href="' + repo.uri + 
                           '" title="' + repo_title + '">' + repo.name + "</a></div>");
            title.appendTo(row);
            
            ownerType = repo.owner_type;
            description = jQuery('<div class="' + ownerType + '"></div>');

            ownerUri = repo.owner_uri;
            ownerTag = jQuery('<a href="' + ownerUri + '">' + repo.owner + '</a>');
            ownerTag.appendTo(description);

            
            if (image = repo.img) {
                imageTag = jQuery('<img src="' + image + '" width="16" height="16" />');
                imageTag.prependTo(description);
            }

            description.appendTo(row);
            return row;
        }
    }

    jQuery("#repo_search").liveSearch(backend, {
        resourceUri: searchUri, 
        itemClass: "clone",
        resultContainer: ".repository_list",
        waitingClass: "searching",
        renderer: renderer,
        onDisplay: function() {
            jQuery(".team_clones").hide();
            jQuery(".personal_clones").hide();
            jQuery("#show_all_clones").hide();
        },
        onReset: function (){
            jQuery(".team_clones").show();
            jQuery(".personal_clones").show();
        }
    });

    jQuery("#show_all_clones").live("click", function(e) {
        jQuery("#clone-list-container").load( $(this).attr("href") + ".js" );
        $(this).hide();
        return false;
    });
});<commit_msg>Escape HMTL tags in the liveSearch renderer<commit_after>/*
  Live searching on repositories
*/
if (!Gitorious)
    var Gitorious = {};

$(document).ready(function () {
    var searchContainer = jQuery("#repo_search");
    var searchUri = searchContainer.attr("gts:searchUri");

    var backend = {get: function (uri, phrase, callback){
        jQuery.getJSON(uri + phrase, function(data) {
            callback(data);
        });
    }}

    /*
      Renderer for rendering repositories as search results
     */
    var renderer = {
        escape: function(str) {
            return str.replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/&/g,'&amp;');
        },

        // Should return something that can be appended to a jQuery object
        render: function(repo) {
            row = jQuery('<li class="clone"></li>');

            repo_title = this.escape(repo.description || repo.name);

            title = jQuery('<div class="name"><a href="' + repo.uri + 
                           '" title="' + repo_title + '">' +
                           this.escape(repo.name) + "</a></div>");
            title.appendTo(row);

            ownerType = repo.owner_type;
            description = jQuery('<div class="' + this.escape(ownerType) + '"></div>');

            ownerUri = repo.owner_uri;
            ownerTag = jQuery('<a href="' + ownerUri + '">' +
                              this.escape(repo.owner) + '</a>');
            ownerTag.appendTo(description);

            if (image = repo.img) {
                imageTag = jQuery('<img src="' + image + '" width="16" height="16" />');
                imageTag.prependTo(description);
            }

            description.appendTo(row);
            return row;
        }
    };

    jQuery("#repo_search").liveSearch(backend, {
        resourceUri: searchUri, 
        itemClass: "clone",
        resultContainer: ".repository_list",
        waitingClass: "searching",
        renderer: renderer,
        onDisplay: function() {
            jQuery(".team_clones").hide();
            jQuery(".personal_clones").hide();
            jQuery("#show_all_clones").hide();
        },
        onReset: function() {
            jQuery(".team_clones").show();
            jQuery(".personal_clones").show();
        }
    });

    jQuery("#show_all_clones").live("click", function(e) {
        jQuery("#clone-list-container").load( $(this).attr("href") + ".js" );
        $(this).hide();
        return false;
    });
});
{'fraction_non_alphanumeric': 0.164290274526495, 'fraction_numerical': 0.0017024898914662695, 'mean_word_length': 1.9634300126103406, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, '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': '4997738', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1259, 'n_words': 254}