<commit_before>AutoForm.addInputType 'fileUpload', {
	template: 'afFileUpload'
}

refreshFileInput = (name)->
	callback = ->
		# id = $('.nav-pills[file-input="'+name+'"] > .active > a').attr('href')
		# value = $('.tab-content[file-input="'+name+'"] >' + id + '>div>input').val()
		# $('input[name="' + name + '"]').val(value)
		# console.log name
		value = $('input[name="' + name + '"]').val()
		Session.set 'fileUpload['+name+']', value
	setTimeout callback, 10

getIcon = (file)->
	file = file.toLowerCase()
	icon = 'file-o'
	if file.indexOf('youtube.com') > -1
		icon = 'youtube'
	else if file.indexOf('vimeo.com') > -1
		icon = 'vimeo-square'
	else if file.indexOf('.pdf') > -1
		icon = 'file-pdf-o'
	else if file.indexOf('.doc') > -1 || file.indexOf('.docx') > -1
		icon = 'file-word-o'
	else if file.indexOf('.ppt') > -1
		icon = 'file-powerpoint-o'
	else if file.indexOf('.avi') > -1 || file.indexOf('.mov') > -1 || file.indexOf('.mp4') > -1
		icon = 'file-movie-o'
	else if file.indexOf('.png') > -1 || file.indexOf('.jpg') > -1 || file.indexOf('.gif') > -1 || file.indexOf('.bmp') > -1
		icon = 'file-image-o'
	else if file.indexOf('http://') > -1 || file.indexOf('https://') > -1
		icon = 'link'
	icon

getTemplate = (file)->
	template = 'fileThumbIcon'
	if file.indexOf('.jpg') > -1 || file.indexOf('.png') > -1 || file.indexOf('.gif') > -1
		template = 'fileThumbImg'
	template

# Template.afFileUpload.rendered = () ->
# 	doc = Template.parentData(1)._af.doc
# 	data = Template.currentData()


clearFilesFromSession = ->
	_.each Session.keys, (value, key, index)->
		if key.indexOf('fileUpload') > -1
			Session.set key, ''


AutoForm.addHooks null,<commit_msg>ignore case of file extension<commit_after>AutoForm.addInputType 'fileUpload', {
	template: 'afFileUpload'
}

refreshFileInput = (name)->
	callback = ->
		# id = $('.nav-pills[file-input="'+name+'"] > .active > a').attr('href')
		# value = $('.tab-content[file-input="'+name+'"] >' + id + '>div>input').val()
		# $('input[name="' + name + '"]').val(value)
		# console.log name
		value = $('input[name="' + name + '"]').val()
		Session.set 'fileUpload['+name+']', value
	setTimeout callback, 10

getIcon = (file)->
	file = file.toLowerCase()
	icon = 'file-o'
	if file.indexOf('youtube.com') > -1
		icon = 'youtube'
	else if file.indexOf('vimeo.com') > -1
		icon = 'vimeo-square'
	else if file.indexOf('.pdf') > -1
		icon = 'file-pdf-o'
	else if file.indexOf('.doc') > -1 || file.indexOf('.docx') > -1
		icon = 'file-word-o'
	else if file.indexOf('.ppt') > -1
		icon = 'file-powerpoint-o'
	else if file.indexOf('.avi') > -1 || file.indexOf('.mov') > -1 || file.indexOf('.mp4') > -1
		icon = 'file-movie-o'
	else if file.indexOf('.png') > -1 || file.indexOf('.jpg') > -1 || file.indexOf('.gif') > -1 || file.indexOf('.bmp') > -1
		icon = 'file-image-o'
	else if file.indexOf('http://') > -1 || file.indexOf('https://') > -1
		icon = 'link'
	icon

getTemplate = (file)->
	file = file.toLowerCase()
	template = 'fileThumbIcon'
	if file.indexOf('.jpg') > -1 || file.indexOf('.png') > -1 || file.indexOf('.gif') > -1
		template = 'fileThumbImg'
	template

# Template.afFileUpload.rendered = () ->
# 	doc = Template.parentData(1)._af.doc
# 	data = Template.currentData()


clearFilesFromSession = ->
	_.each Session.keys, (value, key, index)->
		if key.indexOf('fileUpload') > -1
			Session.set key, ''


AutoForm.addHooks null,
{'fraction_non_alphanumeric': 0.23373564910214895, 'fraction_numerical': 0.013541360023550192, 'mean_word_length': 3.5549597855227884, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 65, 'https://': 2, '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': '3374139', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1262, 'n_words': 265}