 #  else
 #    console.error("No target defined")
 
-#group_encryption = (elements) ->
-#  buffer = collect_sources(elements)
-#  write_target(buffer)
-#elements_with_name_in = (source, reference) ->
-#  return $.grep(source, (element) ->
-#    contains(element.name, reference)
-#  )
 
 
 

submit_handler = (e, form) ->
  e.preventDefault()
  values = get_values(form)
  source_encryption_names = find_names_for(form, "*[data-encrypt-source]")

  #$(form).find("*[data-encrypt]").each (index, element) ->
  #  n = $(element).attr("name")
  #  direct_encryption_names.push n
  ## names angelegt
  ##  arrray anlegen , duchlaufen encrypten
  #group_encryption($(form).find("*[data-encrypt-source]"))
  single_encryption(form, values, (result) ->
    console.log(result)
    form.submit()
  )

get_values = (form) ->
  return $(form).serializeArray()

  for i in [0..values.length-1]
    $("*[name='#{values[i].name}']").val(values[i].value)

group_encryption = (form, values, callback) ->
  callback()
#  buffer = collect_sources(elements)

#  write_target(buffer)
#elements_with_name_in = (source, reference) ->
#  return $.grep(source, (element) ->
#    contains(element.name, reference)
#  )
# Future code for group encrypt function
#find_label = (element) ->
#  id = element.id
