<commit_before>//= require shared_form/form/element/variants

var SharedForm          = SharedForm              || {};
SharedForm.Form         = SharedForm.Form         || {};
SharedForm.Form.Element = SharedForm.Form.Element || {};

Object.extend(SharedForm.Form.Element, {
	initialize: function(objectName) {
		if (objectName)
			this.objectName = this.name
				.sub(new RegExp('^'+objectName), 'object')
				.gsub('[', '["')
				.gsub(']', '"]');
		else
			this.objectName = 'object["'+this.name+'"]';
		if (this.detectLang())
			this.objectNameWithoutLocale = this.objectName.sub('_'+this.lang+'"]', '"]');

		this.variants = Object.extend($H(), SharedForm.Form.Element.Variants);
		this.variants.initial = this.value;

		return this;
	},

	register: function(object, register) {
		var value = eval(this.objectName) ||
		            eval(this.objectNameWithoutLocale);
		if (!value) return;

		if (!Object.isFunction(register))
			register = this.variants.register.bind(this.variants);

		if (Object.isArray(value)) {
			this.multiple = true;

			value.each(function(o) {
				if (o.lang && o.lang != this.lang) return;<commit_msg>Form: improved element value lookup.<commit_after>//= require shared_form/form/element/variants

var SharedForm          = SharedForm              || {};
SharedForm.Form         = SharedForm.Form         || {};
SharedForm.Form.Element = SharedForm.Form.Element || {};

Object.extend(SharedForm.Form.Element, {
	initialize: function(objectName) {
		if (objectName)
			this.objectName = this.name
				.sub(new RegExp('^'+objectName), 'object')
				.gsub('[', '["')
				.gsub(']', '"]');
		else
			this.objectName = 'object["'+this.name+'"]';
		if (this.detectLang())
			this.objectNameWithoutLocale = this.objectName.sub('_'+this.lang+'"]', '"]');

		this.variants = Object.extend($H(), SharedForm.Form.Element.Variants);
		this.variants.initial = this.value;

		return this;
	},

	register: function(object, register) {
		var value;
		try { value = value || eval(this.objectName)              } catch(e) {}
		try { value = value || eval(this.objectNameWithoutLocale) } catch(e) {}
		if (!value) return;

		if (!Object.isFunction(register))
			register = this.variants.register.bind(this.variants);

		if (Object.isArray(value)) {
			this.multiple = true;

			value.each(function(o) {
				if (o.lang && o.lang != this.lang) return;
{'fraction_non_alphanumeric': 0.177316969953449, 'fraction_numerical': 0.0, 'mean_word_length': 3.4688090737240076, 'pattern_counts': {'":': 0, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '808788', 'n_tokens_mistral': 852, 'n_tokens_neox': 762, 'n_words': 131}