function _service_links_add_js in Service links 6.2
Same name and namespace in other branches
- 7.2 service_links.module \_service_links_add_js()
Load correctly the needed javascripts.
1 call to _service_links_add_js()
- _service_links_render in ./
service_links.module - The common render function used privately.
File
- ./
service_links.module, line 631 - Adds social network links to the content.
Code
function _service_links_add_js($javascript) {
static $is_https;
static $external_js;
if (!isset($is_https)) {
$is_https = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on';
}
if (!is_array($javascript)) {
$javascript = array(
$javascript,
);
}
if (!isset($external_js)) {
$external_js = array();
}
foreach ($javascript as $js) {
if (strpos($js, '://') !== FALSE) {
if ($is_https) {
// Ensure that we embed the https js library.
$js = str_replace('http://', 'https://', $js);
}
if (!in_array($js, $external_js)) {
drupal_set_html_head('<script type="text/javascript" src="' . $js . '"></script>');
$external_js[] = $js;
}
}
else {
drupal_add_js(service_links_expand_path($js, 'javascript'));
}
}
}