You are here

function livechat_add_js in LiveChat 7

Adds LiveChat tracking code.

1 call to livechat_add_js()
livechat_preprocess_html in ./livechat.module
Implements hook_preprocess_HOOK().

File

./livechat.module, line 96
LiveChat module.

Code

function livechat_add_js() {
  $license = variable_get('livechat_license');
  if (empty($license)) {
    return FALSE;
  }

  // Allow modules to add custom parameters and visitor information.
  $params = array();
  $visitor = array();
  drupal_alter('livechat', $params, $visitor);
  $settings = array(
    'LiveChat' => array(
      'license' => $license,
      'params' => $params,
      'visitor' => $visitor,
    ),
  );

  // Add in the group id if it has been set.
  $group_id = variable_get('livechat_group', '');
  if ($group_id) {
    $settings['LiveChat']['group'] = $group_id;
  }

  // Pass license, parameters and visitor information to the LiveChat script.
  drupal_add_js($settings, 'setting');

  // Add the LiveChat script to the footer.
  drupal_add_js(drupal_get_path('module', 'livechat') . '/livechat.js', array(
    'scope' => 'footer',
  ));
}