<commit_before>ASTool.MappedFieldData = Em.Object.extend({
	fieldName: null,
	extractors: [],
	required: false,
	extracted: false,
	disabled: true,
}),


ASTool.TemplateIndexController = Em.ObjectController.extend(ASTool.BaseControllerMixin,
	ASTool.DocumentViewDataSource, ASTool.DocumentViewListener, {

	needs: ['application', 'items', 'spider_index', 'spider'],

	navigationLabelBinding: 'content.name',

	annotations: [],

	items: [],

	extractors: [],

	annotationsLoaded: false,

	showContinueBrowsing: true,

	showToggleCSS: true,
	toggleCSS: function() {
		//FIXME: Set state correctly
		button = $('.togglecss');
		if (button.hasClass('btn-default')) {
			button.addClass('btn-danger');
			button.removeClass('btn-default');
		} else {
			button.removeClass('btn-danger');
			button.addClass('btn-default');
		}
		this.documentView.toggleCSS();
	},

	showFloatingAnnotationWidgetAt: null,

	floatingAnnotation: null,

	scrapedItem: function() {
		if (!Em.isEmpty(this.get('items'))) {
			return this.get('items').findBy('name', this.get('content.scrapes'));
		} else {
			return null;
		}
	}.property('content.scrapes', 'items.@each'),

	documentView: null,

	currentlySelectedElement: null,

	newReExtractor: null,

	_newTypeExtractor: 'null',

	newTypeExtractor: function(key, type) {
		if (arguments.length > 1) {
			this.set('_newTypeExtractor', type);
			if (type) {
				this.set('newReExtractor', null);
			}
		}
		return this.get('_newTypeExtractor');
	}.property('_newTypeExtractor'),

	createExtractorDisabled: function() {
		return !this.get('newTypeExtractor') && !this.get('newReExtractor');
	}.property('newReExtractor', 'newTypeExtractor'),

	sprites: function() {
		return this.get('annotations').map(function(annotation) {
			if (annotation.get('element')) {
				return ASTool.AnnotationSprite.create({'annotation': annotation});
			} else {
				return null;
			}
		}).filter(function(sprite) { return !!sprite; });
	}.property('annotations.@each.element', 'annotations.@each.highlighted'),

	addAnnotation: function(element, generated) {
		var annotation = ASTool.Annotation.create({
			id: ASTool.shortGuid(),
			selectedElement: element,
			generated: !!generated,
		});
		this.get('annotations').pushObject(annotation);
		return annotation;
	},

	mapAttribute: function(annotation, attribute, field) {
		annotation.removeMappings();
		annotation.addMapping(attribute, field);
	},

	makeSticky: function(annotation, attributeName) {
		var maxSticky = this.get('maxSticky');
		var stickyName = '_sticky' + (maxSticky + 1);
		annotation.addMapping(attributeName, stickyName);
		annotation.addRequired(stickyName);
	},

	editAnnotation: function(annotation) {
		annotation.set('highlighted', false);
		this.saveAnnotations();
		this.transitionToRoute('annotation', annotation);
	},<commit_msg>Add new annotation to top for editing #132<commit_after>ASTool.MappedFieldData = Em.Object.extend({
	fieldName: null,
	extractors: [],
	required: false,
	extracted: false,
	disabled: true,
}),


ASTool.TemplateIndexController = Em.ObjectController.extend(ASTool.BaseControllerMixin,
	ASTool.DocumentViewDataSource, ASTool.DocumentViewListener, {

	needs: ['application', 'items', 'spider_index', 'spider'],

	navigationLabelBinding: 'content.name',

	annotations: [],

	items: [],

	extractors: [],

	annotationsLoaded: false,

	showContinueBrowsing: true,

	showToggleCSS: true,
	toggleCSS: function() {
		//FIXME: Set state correctly
		button = $('.togglecss');
		if (button.hasClass('btn-default')) {
			button.addClass('btn-danger');
			button.removeClass('btn-default');
		} else {
			button.removeClass('btn-danger');
			button.addClass('btn-default');
		}
		this.documentView.toggleCSS();
	},

	showFloatingAnnotationWidgetAt: null,

	floatingAnnotation: null,

	scrapedItem: function() {
		if (!Em.isEmpty(this.get('items'))) {
			return this.get('items').findBy('name', this.get('content.scrapes'));
		} else {
			return null;
		}
	}.property('content.scrapes', 'items.@each'),

	documentView: null,

	currentlySelectedElement: null,

	newReExtractor: null,

	_newTypeExtractor: 'null',

	newTypeExtractor: function(key, type) {
		if (arguments.length > 1) {
			this.set('_newTypeExtractor', type);
			if (type) {
				this.set('newReExtractor', null);
			}
		}
		return this.get('_newTypeExtractor');
	}.property('_newTypeExtractor'),

	createExtractorDisabled: function() {
		return !this.get('newTypeExtractor') && !this.get('newReExtractor');
	}.property('newReExtractor', 'newTypeExtractor'),

	sprites: function() {
		return this.get('annotations').map(function(annotation) {
			if (annotation.get('element')) {
				return ASTool.AnnotationSprite.create({'annotation': annotation});
			} else {
				return null;
			}
		}).filter(function(sprite) { return !!sprite; });
	}.property('annotations.@each.element', 'annotations.@each.highlighted'),

	addAnnotation: function(element, generated) {
		var annotation = ASTool.Annotation.create({
			id: ASTool.shortGuid(),
			selectedElement: element,
			generated: !!generated,
		});
		this.get('annotations').unshiftObject(annotation);
		return annotation;
	},

	mapAttribute: function(annotation, attribute, field) {
		annotation.removeMappings();
		annotation.addMapping(attribute, field);
	},

	makeSticky: function(annotation, attributeName) {
		var maxSticky = this.get('maxSticky');
		var stickyName = '_sticky' + (maxSticky + 1);
		annotation.addMapping(attributeName, stickyName);
		annotation.addRequired(stickyName);
	},

	editAnnotation: function(annotation) {
		annotation.set('highlighted', false);
		this.saveAnnotations();
		this.transitionToRoute('annotation', annotation);
	},
{'fraction_non_alphanumeric': 0.15714285714285714, 'fraction_numerical': 0.0012345679012345679, 'mean_word_length': 5.343400447427293, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '927790', 'n_tokens_mistral': 1977, 'n_tokens_neox': 1757, 'n_words': 313}