function radioactivity_node_ajax_code in Radioactivity 6
Generate js/html for radioactivity counter.
NOTE HTML code could be added to the $buffer directly. Would prevent 2x counts on first view. Would be hard to do though.
See also
1 call to radioactivity_node_ajax_code()
- radioactivity_node_block in plugins/
radioactivity_node.module - Implementation of hook_block().
File
- plugins/
radioactivity_node.module, line 318 - Node radioactivity
Code
function radioactivity_node_ajax_code() {
global $base_path;
// is node & node count enabled.
if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == '') {
$nid = arg(1);
}
else {
$nid = 'NULL';
}
$page_js = array(
'radioactivity_node' => array(
'nid' => $nid,
),
);
$site_js = <<<ETO
\$.get(Drupal.settings.basePath + "radioactivity_node.php", {nocache: "1", js: "1", nid: Drupal.settings.radioactivity_node.nid}, function(response) {});
ETO;
// page specific variables
drupal_add_js($page_js, 'setting', 'header');
// site-wide code
drupal_add_js($site_js, 'inline', 'footer');
// no script code
$page_ns = '<noscript><div style="display:inline;"><img src="' . $base_path . 'radioactivity_node.php' . '?nocache=1' . '&nid=' . $nid . '" alt="" /></div></noscript>';
return $page_ns;
}