You are here

function timezone_detect_add_js in Timezone Detect 6

Same name and namespace in other branches
  1. 7 timezone_detect.module \timezone_detect_add_js()

Add the javascript that will update the user's timezone via ajax callback.

1 call to timezone_detect_add_js()
timezone_detect_init in ./timezone_detect.module
Implements hook_init().

File

./timezone_detect.module, line 130
Module provides automatic timezone detection via javascript.

Code

function timezone_detect_add_js() {

  // Add jstz.
  $path = drupal_get_path('module', 'timezone_detect');
  drupal_add_js($path . '/jstz.js');

  // Add helper js.
  drupal_add_js($path . '/timezone_detect.js');

  // Store the current timezone for comparison.
  $timezone = !empty($_SESSION['timezone_detect']['current_timezone']) ? $_SESSION['timezone_detect']['current_timezone'] : $GLOBALS['user']->timezone;
  $setting = array(
    'timezone_detect' => array(
      'current_timezone' => $timezone,
    ),
  );
  drupal_add_js($setting, 'setting');
}