Index: mollom/mollom.module =================================================================== --- mollom/mollom.module (revision 35) +++ mollom/mollom.module (working copy) @@ -605,6 +605,7 @@ $element['session_id'] = array( '#type' => 'hidden', '#value' => time() .'-'. $mollom_state['#session_id'], + '#attributes' => array('class' => 'mollom-session-id'), ); cache_set($mollom_state['#session_id'], $mollom_state, 'cache_mollom', time() + 60*30); @@ -773,7 +774,7 @@ '#type' => 'textfield', '#processed' => TRUE, '#title' => t('Word verification'), - '#field_prefix' => 'Mollom CAPTCHA ('. t('play audio CAPTCHA') .')', + '#field_prefix' => 'Mollom CAPTCHA ('. t('play audio CAPTCHA') .')', '#required' => TRUE, '#size' => 10, // The previously entered value is useless because the captcha is regenerated at each form rebuild. Index: mollom/mollom.pages.inc =================================================================== --- mollom/mollom.pages.inc (revision 35) +++ mollom/mollom.pages.inc (working copy) @@ -17,15 +17,15 @@ if ($type == 'audio') { $response = mollom('mollom.getAudioCaptcha', array('author_ip' => ip_address(), 'session_id' => $session_id)); if ($response) { - $output = ''; - $output .= ' ('. t('use image CAPTCHA') .')'; + $output = ''; + $output .= ' ('. t('use image CAPTCHA') .')'; } } elseif ($type == 'image') { $response = mollom('mollom.getImageCaptcha', array('author_ip' => ip_address(), 'session_id' => $session_id)); if ($response) { - $output = 'Mollom CAPTCHA'; - $output .= ' ('. t('play audio CAPTCHA') .')'; + $output = 'Mollom CAPTCHA'; + $output .= ' ('. t('play audio CAPTCHA') .')'; } } Index: mollom/mollom.js =================================================================== --- mollom/mollom.js (revision 35) +++ mollom/mollom.js (working copy) @@ -1,41 +1,45 @@ // $Id: mollom.js,v 1.2.2.5 2009/04/12 19:29:20 dries Exp $ -Drupal.behaviors.mollom = function() { +Drupal.behaviors.mollom = function(context) { // Add onclick.event handlers for CAPTCHA links: - $('a#mollom-audio-captcha').click(getAudioCaptcha); - $('a#mollom-image-captcha').click(getImageCaptcha); + $('a.mollom-audio-captcha', context).click(getAudioCaptcha); + $('a.mollom-image-captcha', context).click(getImageCaptcha); } function getAudioCaptcha() { + var context = $(this).parents('.form-item').parent(); + // Extract the Mollom session ID from the form: - var mollomSessionId = $("input#edit-mollom-session-id").val(); + var mollomSessionId = $('input.mollom-session-id', context).val(); // Retrieve an audio CAPTCHA: var data = $.get(Drupal.settings.basePath + 'mollom/captcha/audio/' + mollomSessionId, function(data) { // When data is successfully loaded, replace // contents of captcha-div with an audio CAPTCHA: - $('a#mollom-captcha').parent().html(data); + $('a.mollom-captcha', context).parent().html(data); // Add an onclick-event handler for the new link: - $('a#mollom-image-captcha').click(getImageCaptcha); + $('a.mollom-image-captcha', context).click(getImageCaptcha); }); return false; } function getImageCaptcha() { + var context = $(this).parents('.form-item').parent(); + // Extract the Mollom session ID from the form: - var mollomSessionId = $('input#edit-mollom-session-id').val(); + var mollomSessionId = $('input.mollom-session-id', context).val(); // Retrieve an image CAPTCHA: var data = $.get(Drupal.settings.basePath + 'mollom/captcha/image/' + mollomSessionId, function(data) { // When data is successfully loaded, replace // contents of captcha-div with an image CAPTCHA: - $('a#mollom-captcha').parent().html(data); + $('a.mollom-captcha', context).parent().html(data); // Add an onclick-event handler for the new link: - $('a#mollom-audio-captcha').click(getAudioCaptcha); + $('a.mollom-audio-captcha', context).click(getAudioCaptcha); }); return false; }