You are here

function _shoutbox_js_config in Shoutbox 7.2

Same name and namespace in other branches
  1. 6.2 shoutbox.module \_shoutbox_js_config()
  2. 7 shoutbox.module \_shoutbox_js_config()

Unified function to generate JS settings.

1 call to _shoutbox_js_config()
shoutbox_view in ./shoutbox.module
View the shoutbox.

File

./shoutbox.module, line 250
Shoutbox module displays a block for users to create short messages for the whole site. Uses AHAH to update the database and display content.

Code

function _shoutbox_js_config() {

  // Set default path.
  $refresh_path = 'shoutbox/js/view';

  // Allow other modules to alter the path.
  $shout = new stdClass();
  shoutbox_invoke('js path', $shout, $refresh_path);

  // Variable needed by javascript code.
  $js_settings = array(
    'mode' => arg(0) == 'shoutbox' ? 'page' : 'block',
    'refreshDelay' => shoutbox_get_refresh_rate(TRUE),
    'ascending' => variable_get('shoutbox_ascending', TRUE),
    'maxLength' => variable_get('shoutbox_max_length', 255),
    'refreshPath' => url($refresh_path),
    'currentPath' => $_GET['q'],
  );

  // Add JS settings to page.
  drupal_add_js(array(
    'shoutbox' => $js_settings,
  ), array(
    'type' => 'setting',
    'scope' => JS_DEFAULT,
  ));
}