<commit_before>window.AjaxNestedForm = {}

class @AjaxNestedForm

	@removeFields: (link, container) ->
		$(link).prev("input[type=hidden]").val("true")
		$(link).closest(container).hide()
		return

	@addFields: (link, association, content, container, position) ->
		new_id = new Date().getTime()
		regexp = new RegExp("new_" + association, "g")
		content_new = content.replace(regexp, new_id)
		if position is "first" then $(container).prepend(content_new) else $(container).append(content_new)
		return<commit_msg>- Add trigger to form<commit_after>window.AjaxNestedForm = {}

class @AjaxNestedForm

	@removeFields: (link, container) ->
		$(link).prev("input[type=hidden]").val("true")
		$(link).closest(container).hide()
		return

	@addFields: (link, association, content, container, position) ->
		new_id = new Date().getTime()
		regexp = new RegExp("new_" + association, "g")
		content_new = $(content.replace(regexp, new_id))
		if position is "first" then $(container).prepend(content_new) else $(container).append(content_new)
		$(document).trigger
			type: "ajax_nested:fieldAdded",
			field: content_new

		return
{'fraction_non_alphanumeric': 0.1623550401427297, 'fraction_numerical': 0.0, 'mean_word_length': 5.6390532544378695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5623860', 'n_tokens_mistral': 393, 'n_tokens_neox': 363, 'n_words': 78}