<commit_before>(function(fm, $, ng, undefined) {

	fm.app.directive("fmTypeField", function($parse, $compile) {
		return {
			restrict: 'A',
			link: function(scope, element, attrs) {
				if($parse(attrs.fmTypeFieldModel)(scope) == null)
					$parse(attrs.fmTypeFieldModel+'='+attrs.fmTypeField+'.default')(scope);

				var update = function() {
					var field = $parse(attrs.fmTypeField)(scope);

					var el;
					switch(field.type) {
						case "textarea":
							el = $('<textarea class="form-control"/>');
							break;
						case "dropdown":
							el = $('<select class="form-control"/>');
							if(field.options) {
								for(var i=0; i<field.options.length; i++) {
									$('<option/>').attr("value", field.options[i].key).text(field.options[i].value).appendTo(el);
								}
							}
							break;
						case "checkbox":
							el = $('<input type="checkbox" ng-true-value="\'1\'" ng-false-value="\'0\'" />');
							break;
						case "input":
						default:
							el = $('<input type="text" class="form-control"/>');
							break;
					}

					el.attr("ng-model", attrs.fmTypeFieldModel);

					if(attrs.fmTypeFieldId)
						el.attr("id", attrs.fmTypeFieldId);

					el.appendTo(element.empty());
					$compile(el)(scope);
					scope.$evalAsync(); // $compile only replaces variables on next digest
				};

				scope.$watch(attrs.fmTypeField+".type", update);
				scope.$watch(attrs.fmTypeField+".options", update, true);
				if(attrs.fmTypeFieldIgnoreDefault == null)
					scope.$watch(attrs.fmTypeField+".default", update);
			}
		};
	});

	fm.app.directive("fmTypeFieldContent", function($parse, fmTypeFields) {
		return {
			restrict: 'A',
			link: function(scope, element, attrs) {
				var update = function() {
					var field = $parse(attrs.fmTypeFieldContent)(scope);
					var value = $parse(attrs.fmTypeFieldModel)(scope);

					element.empty().append(fmTypeFields.formatField(field, value));
				};<commit_msg>Fix strange bug where select boxes in edit marker/line are not initialised properly (#39)<commit_after>(function(fm, $, ng, undefined) {

	fm.app.directive("fmTypeField", function($parse, $compile) {
		return {
			restrict: 'A',
			link: function(scope, element, attrs) {
				if($parse(attrs.fmTypeFieldModel)(scope) == null)
					$parse(attrs.fmTypeFieldModel+'='+attrs.fmTypeField+'.default')(scope);

				var update = function() {
					var field = $parse(attrs.fmTypeField)(scope);

					var el;
					switch(field.type) {
						case "textarea":
							el = $('<textarea class="form-control"/>');
							break;
						case "dropdown":
							el = $('<select class="form-control"/>');
							if(field.options) {
								for(var i=0; i<field.options.length; i++) {
									$('<option/>').attr("value", field.options[i].key).text(field.options[i].value).appendTo(el);
								}
							}
							break;
						case "checkbox":
							el = $('<input type="checkbox" ng-true-value="\'1\'" ng-false-value="\'0\'" />');
							break;
						case "input":
						default:
							el = $('<input type="text" class="form-control"/>');
							break;
					}

					el.attr("ng-model", attrs.fmTypeFieldModel);

					if(attrs.fmTypeFieldId)
						el.attr("id", attrs.fmTypeFieldId);

					el.appendTo(element.empty());

					// For some reason, if we call $compile directly, select boxes will not select the right value
					// with newer versions of angular
					scope.$evalAsync(function() {
						$compile(el)(scope);
					});
				};

				scope.$watch(attrs.fmTypeField+".type", update);
				scope.$watch(attrs.fmTypeField+".options", update, true);
				if(attrs.fmTypeFieldIgnoreDefault == null)
					scope.$watch(attrs.fmTypeField+".default", update);
			}
		};
	});

	fm.app.directive("fmTypeFieldContent", function($parse, fmTypeFields) {
		return {
			restrict: 'A',
			link: function(scope, element, attrs) {
				var update = function() {
					var field = $parse(attrs.fmTypeFieldContent)(scope);
					var value = $parse(attrs.fmTypeFieldModel)(scope);

					element.empty().append(fmTypeFields.formatField(field, value));
				};
{'fraction_non_alphanumeric': 0.1810110974106042, 'fraction_numerical': 0.001972872996300863, 'mean_word_length': 3.126144455747711, 'pattern_counts': {'":': 8, '<': 15, '<?xml version=': 0, '>': 13, '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': '914744', 'n_tokens_mistral': 1719, 'n_tokens_neox': 1276, 'n_words': 237}