<commit_before>var Views = {};
Views.ListingView = Backbone.View.extend({
	initialize: function() {
		this.listenTo(this.collection, 'add', this.collectionAdded);
		this.listenTo(this.collection, 'change', this.collectionChanged);
		this.listenTo(this.collection, 'remove', this.collectionRemoved);
		
		this.childViews = [];

		this._addAllModels();
	},

	events: {
		"click span#add-item" : "addItemClick"
	},

	render: function() {
		var fragment = document.createDocumentFragment();

		if(this.childViews.length > 0) {
			_(this.childViews).each(function(currentView) {
				fragment.appendChild(currentView.render().el);
			});
		} else {
			$(Templates.EmptyListingTemplate()).appendTo(fragment);
		}

		this.$('.item-listing').html(fragment);
		return this;
	},

	collectionAdded: function(item) {
		this._addViewForModel(item);
		this.render();
	},

	collectionRemoved: function(item) {
		this.childViews = this.childViews.filter(function(view) {
			return view.model.id !== item.id;
		});
		this.render();
	},

	collectionChanged: function() {
		this.childViews = [];
		this._addAllModels();
	},

	addItemClick: function() {
		
	},

	_addViewForModel: function(item) {
		this.childViews.push(new Views.ItemView({
			model: item
		}));
	},

	_addAllModels: function() {
		this.collection.each(function(item) {
			_addViewForModel(item);
		});
		this.render();
	}
});

Views.ItemView = Backbone.View.extend({
	template: Templates.ItemListingTemplate,

	events: {
		"click button#btn-pledge" : "pledgeClick"
	},

	pledgeClick: function() {
		
	},

	initialize: function() {
		this.listenTo(this.model, "change", this.render);
		this.id = "item-" + this.model.attributes.id;
	},

	render: function() {
		this.$el.html(this.template(this.model.attributes));
		return this;
	}
});

Views.SearchFormView = Backbone.View.extend({
	template: Templates.SearchFormTemplate,

	events: {
		"click a#btn-search" : "searchClick"
	},

	searchClick: function() {
        var search = $('#txt-search').val();
		$('#search-results').show();
        this.searchCollection.url = '/service/products/search/' + search;
        this.searchCollection.fetch();
	},
    
	initialize: function() {<commit_msg>added render for search<commit_after>var Views = {};
Views.ListingView = Backbone.View.extend({
	initialize: function() {
		this.listenTo(this.collection, 'add', this.collectionAdded);
		this.listenTo(this.collection, 'change', this.collectionChanged);
		this.listenTo(this.collection, 'remove', this.collectionRemoved);
		
		this.childViews = [];

		this._addAllModels();
	},

	events: {
		"click span#add-item" : "addItemClick"
	},

	render: function() {
		var fragment = document.createDocumentFragment();

		if(this.childViews.length > 0) {
			_(this.childViews).each(function(currentView) {
				fragment.appendChild(currentView.render().el);
			});
		} else {
			$(Templates.EmptyListingTemplate()).appendTo(fragment);
		}

		this.$('.item-listing').html(fragment);
		return this;
	},

	collectionAdded: function(item) {
		this._addViewForModel(item);
		this.render();
	},

	collectionRemoved: function(item) {
		this.childViews = this.childViews.filter(function(view) {
			return view.model.id !== item.id;
		});
		this.render();
	},

	collectionChanged: function() {
		this.childViews = [];
		this._addAllModels();
	},

	addItemClick: function() {
		
	},

	_addViewForModel: function(item) {
		this.childViews.push(new Views.ItemView({
			model: item
		}));
	},

	_addAllModels: function() {
		this.collection.each(function(item) {
			_addViewForModel(item);
		});
		this.render();
	}
});

Views.ItemView = Backbone.View.extend({
	template: Templates.ItemListingTemplate,

	events: {
		"click button#btn-pledge" : "pledgeClick"
	},

	pledgeClick: function() {
		
	},

	initialize: function() {
		this.listenTo(this.model, "change", this.render);
		this.id = "item-" + this.model.attributes.id;
	},

	render: function() {
		this.$el.html(this.template(this.model.attributes));
		return this;
	}
});

Views.SearchFormView = Backbone.View.extend({
	template: Templates.SearchFormTemplate,

	events: {
		"click a#btn-search" : "searchClick"
	},

	searchClick: function() {
        var search = $('#txt-search').val();
		$('#search-results').show();
        this.searchCollection.url = '/service/products/search/' + search;
        this.searchCollection.fetch();
        this.render();
	},
    
	initialize: function() {
{'fraction_non_alphanumeric': 0.17138970754930855, 'fraction_numerical': 0.0004534119247336205, 'mean_word_length': 4.094688221709007, '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': '5851718', 'n_tokens_mistral': 1596, 'n_tokens_neox': 1447, 'n_words': 218}