View source
<?php
function template_preprocess_drupalchat(&$variables) {
drupal_add_css(drupal_get_path('module', 'drupalchat') . '/themes/drupalchat.css');
drupal_add_js(drupal_get_path('module', 'drupalchat') . '/themes/js/ba-emotify.js');
drupal_add_js(drupal_get_path('module', 'drupalchat') . '/themes/js/drupalchat.js');
drupal_add_js(array(
'drupalchat' => array(
"polling_method" => variable_get('drupalchat_polling_method', '0'),
),
), 'setting');
$opts = array(
'absolute' => TRUE,
'language' => '',
);
if (variable_get('drupalchat_polling_method', '0') == '0') {
$process_messages_url = url('drupalchat/process-messages', $opts);
drupal_add_js(array(
'drupalchat' => array(
"refresh_rate" => variable_get('drupalchat_refresh_rate', 2),
),
), 'setting');
drupal_add_js(array(
'drupalchat' => array(
"send_rate" => variable_get('drupalchat_send_rate', 2),
),
), 'setting');
}
else {
$process_messages_url = url('drupalchat/process-messages-long-polling', $opts);
drupal_add_js(array(
'drupalchat' => array(
"refresh_rate" => 2,
),
), 'setting');
drupal_add_js(array(
'drupalchat' => array(
"send_rate" => 2,
),
), 'setting');
}
$store_messages_url = url('drupalchat/store-messages', $opts);
$load_messages_url = url('drupalchat/load-messages', $opts);
drupal_add_js(array(
'drupalchat' => array(
"process_messages_url" => $process_messages_url,
),
), 'setting');
drupal_add_js(array(
'drupalchat' => array(
"store_messages_url" => $store_messages_url,
),
), 'setting');
drupal_add_js(array(
'drupalchat' => array(
"load_messages_url" => $load_messages_url,
),
), 'setting');
$smileys_url = url(drupal_get_path('module', 'drupalchat') . '/themes/images/smileys/', $opts);
drupal_add_js(array(
'drupalchat' => array(
"smileys_url" => $smileys_url,
),
), 'setting');
global $user;
drupal_add_js(array(
'drupalchat' => array(
"username" => $user->name,
),
), 'setting');
drupal_add_js(array(
'drupalchat' => array(
"uid" => $user->uid,
),
), 'setting');
drupal_add_js(array(
'drupalchat' => array(
"current_timestamp" => time(),
),
), 'setting');
}