diff --git a/disqus.js b/disqus.js index 74d971d..b39f99f 100644 --- a/disqus.js +++ b/disqus.js @@ -24,6 +24,7 @@ Drupal.behaviors.disqus = { // Load the Disqus comments. if (settings.disqus || false) { // Setup the global JavaScript variables for Disqus. + disqus_protocol = settings.disqus.protocol; disqus_shortname = settings.disqus.domain; disqus_url = settings.disqus.url; disqus_title = settings.disqus.title; @@ -51,7 +52,7 @@ Drupal.behaviors.disqus = { // Make the AJAX call to get the Disqus comments. jQuery.ajax({ type: 'GET', - url: 'http://' + disqus_shortname + '.disqus.com/embed.js', + url: disqus_protocol + disqus_shortname + '.disqus.com/embed.js', dataType: 'script', cache: false }); @@ -59,11 +60,12 @@ Drupal.behaviors.disqus = { // Load the comment numbers JavaScript. if (settings.disqusComments || false) { + disqus_protocol = settings.disqusProtocol; disqus_shortname = settings.disqusComments; // Make the AJAX call to get the number of comments. jQuery.ajax({ type: 'GET', - url: 'http://' + disqus_shortname + '.disqus.com/count.js', + url: disqus_protocol + disqus_shortname + '.disqus.com/count.js', dataType: 'script', cache: false }); diff --git a/disqus.module b/disqus.module index 93fb84a..83c9d61 100644 --- a/disqus.module +++ b/disqus.module @@ -89,6 +89,7 @@ function disqus_element_info() { function disqus_element_post_render($children, &$element) { // Construct the settings to be passed in for Disqus. $disqus = array( + 'protocol' => empty($_SERVER['HTTPS']) ? 'http://' : 'https://', 'domain' => $element['#disqus']['domain'], 'url' => $element['#disqus']['url'], 'title' => $element['#disqus']['title'], @@ -265,7 +266,10 @@ function disqus_node_view($node, $view_mode) { // Attach disqus.js to load the Disqus comment count JavaScript. $node->content['links']['#attached']['js'][] = drupal_get_path('module', 'disqus') . '/disqus.js'; $node->content['links']['#attached']['js'][] = array( - 'data' => array('disqusComments' => $node->disqus['domain']), + 'data' => array( + 'disqusComments' => $node->disqus['domain'], + 'disqusProtocol' => empty($_SERVER['HTTPS']) ? 'http://' : 'https://', + ), 'type' => 'setting', ); break;