function _drupal_add_js in Drupal 5
Helper function for drupal_add_js().
Related topics
1 call to _drupal_add_js()
- drupal_add_js in includes/
common.inc - Add a JavaScript file, setting or inline code to the page.
File
- includes/
common.inc, line 1771 - Common functions that many Drupal modules will need to reference.
Code
function _drupal_add_js($data, $type, $scope, $defer, $cache) {
static $javascript = array();
if (!isset($javascript[$scope])) {
$javascript[$scope] = array(
'core' => array(),
'module' => array(),
'theme' => array(),
'setting' => array(),
'inline' => array(),
);
}
if (!isset($javascript[$scope][$type])) {
$javascript[$scope][$type] = array();
}
if (!is_null($data)) {
switch ($type) {
case 'setting':
$javascript[$scope][$type][] = $data;
break;
case 'inline':
$javascript[$scope][$type][] = array(
'code' => $data,
'defer' => $defer,
);
break;
default:
$javascript[$scope][$type][$data] = array(
'cache' => $cache,
'defer' => $defer,
);
}
}
return $javascript[$scope];
}