You are here

function autofill_js in Autofill 6

Generate custom Autofill JS file.

1 string reference to 'autofill_js'
autofill_menu in ./autofill.module
Implements hook_menu().

File

./autofill.module, line 80
Main module file for the autofill module for Nojoshmo

Code

function autofill_js() {
  $output = '';
  $output .= 'Drupal.behaviors.autofill = function(context){ ';
  $default_color = check_plain(variable_get('autofill_colour_default', '#ccc'));
  $active_color = check_plain(variable_get('autofill_colour_active', '#333'));
  $fields = variable_get('autofill_id_field_combos', array());
  foreach ($fields as $delta => $field) {
    $output .= "\n" . '$("' . check_plain($field['id']) . '").autofill( {
      value: "' . check_plain($field['value']) . '",
      prePopulate: "' . check_plain($field['pre']) . '",
      defaultTextColor: "' . $default_color . '",
      activeTextColor: "' . $active_color . '",
    });';
  }
  $output .= '}';
  header('Content-type: text/javascript;');
  echo $output;
  exit;
}